Author: jambunathan
Date: 2005-04-02 08:55:00 -0500 (Sat, 02 Apr 2005)
New Revision: 42488
Modified:
trunk/mcs/bmcs/ChangeLog
trunk/mcs/bmcs/Makefile
trunk/mcs/bmcs/convert.cs
trunk/mcs/bmcs/driver.cs
trunk/mcs/bmcs/ecore.cs
trunk/mcs/bmcs/mb-parser.jay
trunk/mcs/bmcs/mb-tokenizer.cs
trunk/mcs/bmcs/rootcontext.cs
trunk/mcs/bmcs/typemanager.cs
Log:
* Makefile: Added '/r:Microsoft.VisualBasic.dll' to the compile
command line.
* driver.cs (UnixParseOption, CSCParseOption): Added
'/optioncompare:[text|binary]' command line option.
* rootcontext.cs (StringComparisonMode): Added. Keeps track of the
'/optioncompare:' command line option.
* typemanager.cs (InitVisualBasicHelperTypes,
InitVisualBasicCodeHelpers): New routines that preload frequently
used types and helper methods available in
Microsoft.Visualbasic.dll.
(IsFixedNumericType, IsFloatingNumericType,IsNumericType): New
VB.NET specific helper routines. Added in anticipation of a future
use.
* ecore.cs (HelperMethodInvocation): Added. Implements the same
functionality as the earlier vaguely named class
'ImplicitInvocation'. This class uses the 'type cache' of
Microsoft.VisualBasic helper methods now available in the
TypeManager.
* convert.cs (WideningConstantConversions): Reimplemented. The
earlier implementation was completely topsy-turvy. Propagated the
changes relating to the introduction of 'HelperMethodInvocation'.
* mb-parser.jay: Added rule and action for 'Like' expression.
* mb-tokenizer.cs (keywords): Cleaned up the extra space in the
'let', 'lib' and 'like' entries.
Modified: trunk/mcs/bmcs/ChangeLog
===================================================================
--- trunk/mcs/bmcs/ChangeLog 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/ChangeLog 2005-04-02 13:55:00 UTC (rev 42488)
@@ -1,3 +1,38 @@
+2005-04-02 Jambunathan K <[EMAIL PROTECTED]>
+
+ * Makefile: Added '/r:Microsoft.VisualBasic.dll' to the compile
+ command line.
+
+ * driver.cs (UnixParseOption, CSCParseOption): Added
+ '/optioncompare:[text|binary]' command line option.
+
+ * rootcontext.cs (StringComparisonMode): Added. Keeps track of the
+ '/optioncompare:' command line option.
+
+ * typemanager.cs (InitVisualBasicHelperTypes,
+ InitVisualBasicCodeHelpers): New routines that preload frequently
+ used types and helper methods available in
+ Microsoft.Visualbasic.dll.
+
+ (IsFixedNumericType, IsFloatingNumericType,IsNumericType): New
+ VB.NET specific helper routines. Added in anticipation of a future
+ use.
+
+ * ecore.cs (HelperMethodInvocation): Added. Implements the same
+ functionality as the earlier vaguely named class
+ 'ImplicitInvocation'. This class uses the 'type cache' of
+ Microsoft.VisualBasic helper methods now available in the
+ TypeManager.
+
+ * convert.cs (WideningConstantConversions): Reimplemented. The
+ earlier implementation was completely topsy-turvy. Propagated the
+ changes relating to the introduction of 'HelperMethodInvocation'.
+
+ * mb-parser.jay: Added rule and action for 'Like' expression.
+
+ * mb-tokenizer.cs (keywords): Cleaned up the extra space in the
+ 'let', 'lib' and 'like' entries.
+
2005-03-26 Jambunathan K <[EMAIL PROTECTED]>
* constant.cs: Added conversions between various constants
Modified: trunk/mcs/bmcs/Makefile
===================================================================
--- trunk/mcs/bmcs/Makefile 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/Makefile 2005-04-02 13:55:00 UTC (rev 42488)
@@ -28,7 +28,7 @@
include ../build/executable.make
bmcs.exe: mb-parser.cs
- gmcs -d:NET_1_1 -d:ONLY_1_1 -debug /target:exe /out:bmcs.exe
mb-parser.cs @bmcs.exe.sources -nowarn:219 -nowarn:162
+ gmcs -d:NET_1_1 -d:ONLY_1_1 -debug /target:exe /out:bmcs.exe
/r:Microsoft.VisualBasic.dll mb-parser.cs @bmcs.exe.sources -nowarn:219
-nowarn:162
winstall: all
cp bmcs.exe $(prefix)/lib/mono/2.0/
Modified: trunk/mcs/bmcs/convert.cs
===================================================================
--- trunk/mcs/bmcs/convert.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/convert.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -572,9 +572,9 @@
// From decimal to float, double
//
if (real_target_type == TypeManager.double_type)
- return new ImplicitInvocation (ec,
"System", "Convert", "ToDouble", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.double_type, TypeManager.convert_to_double_decimal, expr);
if (real_target_type == TypeManager.float_type)
- return new ImplicitInvocation (ec,
"System", "Convert" ,"ToSingle", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.float_type, TypeManager.convert_to_single_decimal, expr);
}
return null;
@@ -1450,26 +1450,26 @@
Type const_expr_type = const_expr.Type;
Location loc = const_expr.Location;
+ if (target_type == TypeManager.byte_type){
+ if (const_expr_type == TypeManager.short_type ||
+ const_expr_type ==
TypeManager.int32_type ||
+ const_expr_type ==
TypeManager.int64_type)
+ return const_expr.ToByte (loc);
+ }
+
if (target_type == TypeManager.short_type){
- if (const_expr_type == TypeManager.byte_type)
- return const_expr.ToShort (loc);
+ if (const_expr_type == TypeManager.int32_type ||
+ const_expr_type ==
TypeManager.int64_type)
+ return const_expr.ToShort (loc);
}
if (target_type == TypeManager.int32_type){
- if (const_expr_type == TypeManager.byte_type ||
- const_expr_type ==
TypeManager.short_type)
+ if (const_expr_type == TypeManager.int64_type)
return const_expr.ToInt (loc);
}
- if (target_type == TypeManager.int64_type){
- if (const_expr_type == TypeManager.byte_type ||
- const_expr_type ==
TypeManager.short_type ||
- const_expr_type ==
TypeManager.int32_type)
- return const_expr.ToLong (loc);
- }
-
- if (target_type == TypeManager.double_type) {
- if (const_expr_type == TypeManager.float_type)
+ if (target_type == TypeManager.float_type) {
+ if (const_expr_type == TypeManager.double_type)
return const_expr.ToDouble (loc);
}
@@ -1774,13 +1774,13 @@
// From decimal to byte, short, int, long
//
if (real_target_type == TypeManager.byte_type)
- return new ImplicitInvocation (ec,
"System", "Convert" , "ToByte", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.byte_type, TypeManager.convert_to_byte_decimal, expr);
if (real_target_type == TypeManager.short_type)
- return new ImplicitInvocation (ec,
"System", "Convert", "ToInt16", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.short_type, TypeManager.convert_to_int16_decimal, expr);
if (real_target_type == TypeManager.int32_type)
- return new ImplicitInvocation (ec,
"System", "Convert", "ToInt32", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.int32_type, TypeManager.convert_to_int32_decimal, expr);
if (real_target_type == TypeManager.int64_type)
- return new ImplicitInvocation (ec,
"System", "Convert", "ToInt64", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.int64_type, TypeManager.convert_to_int64_decimal, expr);
}
return null;
@@ -1816,7 +1816,7 @@
if (real_target_type == TypeManager.double_type)
return new BooleanToNumericCast (expr,
target_type, OpCodes.Conv_R8);
if (real_target_type ==
TypeManager.decimal_type) {
- return new ImplicitInvocation (ec,
"DecimalType", "FromBoolean", loc, expr);
+ return new HelperMethodInvocation (ec,
expr.Location, TypeManager.decimal_type,
TypeManager.msvbcs_decimaltype_from_boolean, expr);
}
} if (real_target_type == TypeManager.bool_type) {
@@ -1833,7 +1833,7 @@
expr_type == TypeManager.double_type)
return new NumericToBooleanCast
(expr, expr_type);
if (expr_type == TypeManager.decimal_type) {
- return new ImplicitInvocation (ec,
"System", "Convert", "ToBoolean", loc, expr);
+ return new HelperMethodInvocation (ec,
expr.Location, TypeManager.bool_type, TypeManager.convert_to_boolean_decimal,
expr);
}
}
@@ -1856,7 +1856,7 @@
// From char to string
//
if (expr_type == TypeManager.char_type)
- return new ImplicitInvocation (ec,
"StringType", "FromChar", loc, expr);
+ return new HelperMethodInvocation (ec,
expr.Location, TypeManager.string_type,
TypeManager.msvbcs_stringtype_from_char, expr);
}
if(expr_type.IsArray && (expr_type.GetElementType() ==
TypeManager.char_type)) {
@@ -1889,28 +1889,28 @@
// float, double, decimal and date
//
- if (real_target_type.IsArray &&
(real_target_type.GetElementType() == TypeManager.char_type))
- return new ImplicitInvocation (ec,
"CharArrayType", "FromString", loc, expr);
+// if (real_target_type.IsArray &&
(real_target_type.GetElementType() == TypeManager.char_type))
+// return new HelperMethodInvocation (ec,
loc, TypeManager.char_array_type,
TypeManager.msvbcs_char_array_type_from_string, loc, expr);
if (real_target_type == TypeManager.bool_type)
- return new ImplicitInvocation (ec,
"BooleanType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.bool_type, TypeManager.msvbcs_booleantype_from_string, expr);
if (real_target_type == TypeManager.byte_type)
- return new ImplicitInvocation (ec,
"ByteType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.byte_type, TypeManager.msvbcs_bytetype_from_string, expr);
if (real_target_type == TypeManager.short_type)
- return new ImplicitInvocation (ec,
"ShortType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.short_type, TypeManager.msvbcs_shorttype_from_string, expr);
if (real_target_type == TypeManager.char_type)
- return new ImplicitInvocation (ec,
"CharType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.char_type, TypeManager.msvbcs_chartype_from_string, expr);
if (real_target_type == TypeManager.int32_type)
- return new ImplicitInvocation (ec,
"IntegerType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.int32_type, TypeManager.msvbcs_integertype_from_string, expr);
if (real_target_type == TypeManager.int64_type)
- return new ImplicitInvocation (ec,
"LongType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.int64_type, TypeManager.msvbcs_longtype_from_string, expr);
if (real_target_type == TypeManager.float_type)
- return new ImplicitInvocation (ec,
"SingleType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.float_type, TypeManager.msvbcs_singletype_from_string, expr);
if (real_target_type == TypeManager.double_type)
- return new ImplicitInvocation (ec,
"DoubleType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.double_type, TypeManager.msvbcs_doubletype_from_string, expr);
if (real_target_type ==
TypeManager.decimal_type)
- return new ImplicitInvocation (ec,
"DecimalType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.decimal_type, TypeManager.msvbcs_decimaltype_from_string,
expr);
if (real_target_type == TypeManager.date_type)
- return new ImplicitInvocation (ec,
"DateType", "FromString", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.date_type, TypeManager.msvbcs_datetype_from_string, expr);
} if (real_target_type == TypeManager.string_type) {
//
@@ -1920,23 +1920,23 @@
//
if (expr_type == TypeManager.bool_type)
- return new ImplicitInvocation (ec,
"StringType", "FromBoolean", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_boolean, expr);
if (expr_type == TypeManager.byte_type)
- return new ImplicitInvocation (ec,
"StringType", "FromByte", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_byte, expr);
if (expr_type == TypeManager.short_type)
- return new ImplicitInvocation (ec,
"StringType", "FromShort", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_short, expr);
if (expr_type == TypeManager.int32_type)
- return new ImplicitInvocation (ec,
"StringType", "FromInteger", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_integer, expr);
if (expr_type == TypeManager.int64_type)
- return new ImplicitInvocation (ec,
"StringType", "FromLong", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_long, expr);
if (expr_type == TypeManager.float_type)
- return new ImplicitInvocation (ec,
"StringType", "FromSingle", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_single, expr);
if (expr_type == TypeManager.double_type)
- return new ImplicitInvocation (ec,
"StringType", "FromDouble", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_double, expr);
if (expr_type == TypeManager.decimal_type)
- return new ImplicitInvocation (ec,
"StringType", "FromDecimal", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_decimal, expr);
if (expr_type == TypeManager.date_type)
- return new ImplicitInvocation (ec,
"StringType", "FromDate", loc, expr);
+ return new HelperMethodInvocation (ec,
loc, TypeManager.string_type, TypeManager.msvbcs_stringtype_from_date, expr);
}
return null;
Modified: trunk/mcs/bmcs/driver.cs
===================================================================
--- trunk/mcs/bmcs/driver.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/driver.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -20,6 +20,7 @@
using System.Text;
using System.Globalization;
using System.Xml;
+ using Microsoft.VisualBasic;
public enum Target {
Library, Exe, Module, WinExe
@@ -237,6 +238,7 @@
//
" -removeintchecks[+|-] Set default
context to unchecked\n" +
" -optionstrict[+|-] Enables stricter
type checking\n" +
+ " -optioncompare:[text|binary] Specifies the
default mode for character comparisons\n" +
"\n" +
"Resources:\n" +
@@ -905,7 +907,24 @@
case "--optionstrict":
RootContext.StricterTypeChecking= true;
return true;
+
+ case "--optioncompare":
+ if ((i + 1) >= args.Length){
+ Usage ();
+ Environment.Exit (1);
+ }
+
+ if (args [++i].Equals ("text"))
+ RootContext.StringComparisonMode =
CompareMethod.Text;
+ else if (args[++i].Equals ("binary"))
+ RootContext.StringComparisonMode =
CompareMethod.Binary;
+ else {
+ Report.Error (5, "Invalid argument to
--optioncompare");
+ Environment.Exit (1);
+ }
+ return true;
+
}
return false;
@@ -1345,6 +1364,21 @@
RootContext.StricterTypeChecking = false;
return true;
+ case "/optioncompare":
+ if (value == ""){
+ Report.Error (5, arg + " requires an
argument");
+ Environment.Exit (1);
+ }
+ if (value.Equals ("text"))
+ RootContext.StringComparisonMode =
CompareMethod.Text;
+ else if (value.Equals ("binary"))
+ RootContext.StringComparisonMode =
CompareMethod.Binary;
+ else {
+ Report.Error (5, "Invalid argument to
/optioncompare");
+ Environment.Exit (1);
+ }
+ return true;
+
}
//Report.Error (2007, String.Format ("Unrecognized
command-line option: '{0}'", option));
//Environment.Exit (1);
Modified: trunk/mcs/bmcs/ecore.cs
===================================================================
--- trunk/mcs/bmcs/ecore.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/ecore.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -1500,33 +1500,27 @@
/// <summary>
- /// ImplicitInvocation of methods or delegates. Used by the
+ /// HelperMethodInvocation of methods or delegates. Used by the
/// VB.NET compiler specifically to emit calls to the
/// Microsoft.VisualBasic.CompilerServices helper routines
/// </summary>
- public class ImplicitInvocation : Expression
+ public class HelperMethodInvocation : Expression
{
- const string DEFAULT_NS_PREFIX =
"Microsoft.VisualBasic.CompilerServices";
-
- Expression child;
+ ArrayList args;
+ MethodInfo method;
- public ImplicitInvocation (EmitContext ec, string klass, string
method, Location l, params Expression [] exprs)
- : this (ec, DEFAULT_NS_PREFIX, klass, method, l, exprs)
+ public HelperMethodInvocation (EmitContext ec, Location l,
Type return_type, MethodInfo method, params Expression [] exprs)
{
- }
-
- public ImplicitInvocation (EmitContext ec, string ns, string
klass, string method, Location l, params Expression [] exprs)
- {
- ArrayList args = new ArrayList ();
- string name = ns + "." + klass + "." + method;
-
+ args = new ArrayList ();
foreach (Expression expr in exprs)
args.Add (new Argument (expr,
Argument.AType.Expression));
- child = new Invocation (StringToExpression (name, l),
args, l).Resolve (ec);
- eclass = child.eclass;
- type = child.Type;
+
+ this.loc = l;
+ this.method = method;
+ type = return_type;
+ eclass = ExprClass.Value;
}
public override Expression DoResolve (EmitContext ec)
@@ -1536,7 +1530,8 @@
public override void Emit (EmitContext ec)
{
- child.Emit (ec);
+ Invocation.EmitArguments (ec, method, args, false,
null);
+ ec.ig.Emit (OpCodes.Call, method);
}
}
@@ -2214,7 +2209,7 @@
//
public class FloatingToFixedCast : ConvCast {
public FloatingToFixedCast (EmitContext ec, Expression child,
Type return_type, Mode mode)
- : base (ec, new ImplicitInvocation (ec, "System",
"Math", "Round", child.Location,
+ : base (ec, new HelperMethodInvocation (ec,
child.Location, TypeManager.double_type, TypeManager.math_round_double,
(child.Type ==
TypeManager.float_type) ?
new OpcodeCast
(child, TypeManager.double_type, OpCodes.Conv_R8) : child),
return_type, mode)
Modified: trunk/mcs/bmcs/mb-parser.jay
===================================================================
--- trunk/mcs/bmcs/mb-parser.jay 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/mb-parser.jay 2005-04-02 13:55:00 UTC (rev 42488)
@@ -4578,6 +4578,11 @@
$$ = new Binary (Binary.Operator.Is,
(Expression) $1, (Expression) $3,
lexer.Location);
}
+ | relational_expression LIKE shift_expression
+ {
+ $$ = new Binary (Binary.Operator.Like,
+ (Expression) $1, (Expression) $3,
lexer.Location);
+ }
| TYPEOF shift_expression IS type
{
$$ = new Is ((Expression) $2, (Expression) $4, lexer.Location);
Modified: trunk/mcs/bmcs/mb-tokenizer.cs
===================================================================
--- trunk/mcs/bmcs/mb-tokenizer.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/mb-tokenizer.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -207,9 +207,9 @@
keywords.Add ("integer", Token.INTEGER);
keywords.Add ("interface", Token.INTERFACE);
keywords.Add ("is", Token.IS);
- keywords.Add ("let ", Token.LET ); // An unused VB.NET
keyword
- keywords.Add ("lib ", Token.LIB );
- keywords.Add ("like ", Token.LIKE );
+ keywords.Add ("let", Token.LET ); // An unused VB.NET
keyword
+ keywords.Add ("lib", Token.LIB );
+ keywords.Add ("like", Token.LIKE );
keywords.Add ("long", Token.LONG);
keywords.Add ("loop", Token.LOOP);
keywords.Add ("me", Token.ME);
Modified: trunk/mcs/bmcs/rootcontext.cs
===================================================================
--- trunk/mcs/bmcs/rootcontext.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/rootcontext.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -15,6 +15,7 @@
using System.Reflection.Emit;
using System.Diagnostics;
using System.Xml;
+using Microsoft.VisualBasic;
namespace Mono.CSharp {
@@ -141,6 +142,12 @@
// The default type checking state
//
static public bool StricterTypeChecking = false;
+
+ //
+ // The default character comparison mode
+ //
+
+ static public CompareMethod StringComparisonMode =
CompareMethod.Binary;
static string MakeFQN (string nsn, string name)
{
Modified: trunk/mcs/bmcs/typemanager.cs
===================================================================
--- trunk/mcs/bmcs/typemanager.cs 2005-04-02 00:29:07 UTC (rev 42487)
+++ trunk/mcs/bmcs/typemanager.cs 2005-04-02 13:55:00 UTC (rev 42488)
@@ -101,6 +101,31 @@
static public Type date_type;
//
+ // Used with VB.NET
+ //
+ static public Type convert_type;
+ static public Type math_type;
+
+ //
+ // Type cache of helper classes in Microsoft.VisualBasic.dll
+ //
+
+ static public Type msvbcs_boolean_type;
+ static public Type msvbcs_byte_type;
+ static public Type msvbcs_short_type;
+ static public Type msvbcs_integer_type;
+ static public Type msvbcs_long_type;
+ static public Type msvbcs_decimal_type;
+ static public Type msvbcs_single_type;
+ static public Type msvbcs_double_type;
+ static public Type msvbcs_string_type;
+ static public Type msvbcs_char_type;
+ static public Type msvbcs_chararray_type;
+ static public Type msvbcs_date_type;
+
+ static public Type msvbcs_comparemethod_type;
+
+ //
// Unlike C#, VB.NET doesn't understand "signed byte",
// "unsigned short" and "unsigned int" as primitive types. The
// NotDefinedAsPrimitiveType just exists to accomodate this fact.
@@ -231,9 +256,47 @@
static public ConstructorInfo decimal_constant_attribute_ctor;
//
- // VB.NET specific
+ // Type cache of helper methods in Microsoft.VisualBasic.dll
//
+ static public MethodInfo convert_to_byte_decimal;
+ static public MethodInfo convert_to_int16_decimal;
+ static public MethodInfo convert_to_int32_decimal;
+ static public MethodInfo convert_to_int64_decimal;
+ static public MethodInfo convert_to_single_decimal;
+ static public MethodInfo convert_to_double_decimal;
+ static public MethodInfo convert_to_boolean_decimal;
+ static public MethodInfo decimal_compare_decimal_decimal;
+ static public MethodInfo datetime_compare_datetime_datetime;
+ static public MethodInfo math_round_double;
+
+ static public MethodInfo msvbcs_booleantype_from_string;
+ static public MethodInfo msvbcs_bytetype_from_string;
+ static public MethodInfo msvbcs_shorttype_from_string;
+ static public MethodInfo msvbcs_integertype_from_string;
+ static public MethodInfo msvbcs_longtype_from_string;
+ static public MethodInfo msvbcs_decimaltype_from_string;
+ static public MethodInfo msvbcs_singletype_from_string;
+ static public MethodInfo msvbcs_doubletype_from_string;
+ static public MethodInfo msvbcs_chartype_from_string;
+ static public MethodInfo msvbcs_datetype_from_string;
+
+ static public MethodInfo msvbcs_stringtype_from_boolean;
+ static public MethodInfo msvbcs_stringtype_from_byte;
+ static public MethodInfo msvbcs_stringtype_from_short;
+ static public MethodInfo msvbcs_stringtype_from_integer;
+ static public MethodInfo msvbcs_stringtype_from_long;
+ static public MethodInfo msvbcs_stringtype_from_decimal;
+ static public MethodInfo msvbcs_stringtype_from_single;
+ static public MethodInfo msvbcs_stringtype_from_double;
+ static public MethodInfo msvbcs_stringtype_from_date;
+ static public MethodInfo msvbcs_stringtype_from_char;
+
+ static public MethodInfo msvbcs_decimaltype_from_boolean;
+
+ static public MethodInfo msvbcs_stringtype_strcmp_string_string_boolean;
+ static public MethodInfo
msvbcs_stringtype_strlike_string_string_comparemethod;
+
static public ConstructorInfo void_datetime_ctor_ticks_arg;
// <remarks>
@@ -1164,7 +1227,9 @@
//
// VB.NET Specific
//
+ convert_type = CoreLookupType ("System.Convert");
date_type = CoreLookupType ("System.DateTime");
+ math_type = CoreLookupType ("System.Math");
multicast_delegate_type = CoreLookupType
("System.MulticastDelegate");
delegate_type = CoreLookupType ("System.Delegate");
@@ -1326,9 +1391,33 @@
//
anonymous_method_type = typeof (AnonymousMethod);
null_type = typeof (NullType);
+
+ InitVisualBasicHelperTypes ();
}
//
+ // This method preloads helper types in Microsoft.VisualBasic.dll for
later use
+ //
+ public static void InitVisualBasicHelperTypes ()
+ {
+ msvbcs_boolean_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.BooleanType");
+ msvbcs_byte_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.ByteType");
+ msvbcs_short_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.ShortType");
+ msvbcs_integer_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.IntegerType");
+ msvbcs_long_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.LongType");
+ msvbcs_decimal_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.DecimalType");
+ msvbcs_single_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.SingleType");
+ msvbcs_double_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.DoubleType");
+
+ msvbcs_char_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.CharType");
+ msvbcs_chararray_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.CharArrayType");
+ msvbcs_date_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.DateType");
+ msvbcs_string_type = CoreLookupType
("Microsoft.VisualBasic.CompilerServices.StringType");
+
+ msvbcs_comparemethod_type = CoreLookupType
("Microsoft.VisualBasic.CompareMethod");
+ }
+
+ //
// The helper methods that are used by the compiler
//
public static void InitCodeHelpers ()
@@ -1375,6 +1464,39 @@
delegate_type, "Remove", delegate_delegate);
//
+ // VB.NET specific
+ //
+
+ Type [] decimal_arg = { decimal_type };
+ convert_to_byte_decimal = GetMethod (
+ convert_type, "ToByte", decimal_arg);
+ convert_to_int16_decimal = GetMethod (
+ convert_type, "ToInt16", decimal_arg);
+ convert_to_int32_decimal = GetMethod (
+ convert_type, "ToInt32", decimal_arg);
+ convert_to_int64_decimal = GetMethod (
+ convert_type, "ToInt64", decimal_arg);
+ convert_to_single_decimal = GetMethod (
+ convert_type, "ToSingle", decimal_arg);
+ convert_to_double_decimal = GetMethod (
+ convert_type, "ToDouble", decimal_arg);
+ convert_to_boolean_decimal = GetMethod (
+ convert_type, "ToBoolean", decimal_arg);
+
+ Type [] decimal_decimal = { decimal_type, decimal_type };
+ decimal_compare_decimal_decimal = GetMethod (
+ decimal_type, "Compare", decimal_decimal);
+
+ Type [] datetime_datetime = { date_type, date_type };
+ datetime_compare_datetime_datetime = GetMethod (
+ date_type, "Compare", datetime_datetime);
+
+ Type [] double_arg = { double_type };
+ math_round_double = GetMethod (
+ math_type, "Round", double_arg);
+
+
+ //
// Void arguments
//
Type [] void_arg = { };
@@ -1475,8 +1597,82 @@
object_ctor = GetConstructor (object_type, void_arg);
InitGenericCodeHelpers ();
+ InitVisualBasicCodeHelpers ();
}
+
+ //
+ // This method preloads helper methods that are used by the VB.NET
compiler
+ //
+ public static void InitVisualBasicCodeHelpers ()
+ {
+ Type [] boolean_arg = { bool_type };
+ Type [] byte_arg = { byte_type };
+ Type [] short_arg = { short_type };
+ Type [] integer_arg = { int32_type };
+ Type [] long_arg = { int64_type };
+ Type [] decimal_arg = { decimal_type };
+ Type [] single_arg = { float_type };
+ Type [] double_arg = { double_type };
+ Type [] char_arg = { char_type };
+ Type [] string_arg = { string_type };
+ Type [] date_arg = { date_type };
+
+ msvbcs_booleantype_from_string = GetMethod (
+ msvbcs_boolean_type, "FromString", string_arg);
+ msvbcs_bytetype_from_string = GetMethod (
+ msvbcs_byte_type, "FromString", string_arg);
+ msvbcs_shorttype_from_string = GetMethod (
+ msvbcs_short_type, "FromString", string_arg);
+ msvbcs_integertype_from_string = GetMethod (
+ msvbcs_integer_type, "FromString", string_arg);
+ msvbcs_longtype_from_string = GetMethod (
+ msvbcs_long_type, "FromString", string_arg);
+ msvbcs_decimaltype_from_string = GetMethod (
+ msvbcs_decimal_type, "FromString", string_arg);
+ msvbcs_singletype_from_string = GetMethod (
+ msvbcs_single_type, "FromString", string_arg);
+ msvbcs_doubletype_from_string = GetMethod (
+ msvbcs_double_type, "FromString", string_arg);
+ msvbcs_chartype_from_string = GetMethod (
+ msvbcs_char_type, "FromString", string_arg);
+ msvbcs_datetype_from_string = GetMethod (
+ msvbcs_date_type, "FromString", string_arg);
+
+ msvbcs_stringtype_from_boolean = GetMethod (
+ msvbcs_string_type, "FromBoolean", boolean_arg);
+ msvbcs_stringtype_from_byte = GetMethod (
+ msvbcs_string_type, "FromByte", byte_arg);
+ msvbcs_stringtype_from_short = GetMethod (
+ msvbcs_string_type, "FromShort", short_arg);
+ msvbcs_stringtype_from_integer = GetMethod (
+ msvbcs_string_type, "FromInteger", integer_arg);
+ msvbcs_stringtype_from_long = GetMethod (
+ msvbcs_string_type, "FromLong", long_arg);
+ msvbcs_stringtype_from_decimal = GetMethod (
+ msvbcs_string_type, "FromDecimal", decimal_arg);
+ msvbcs_stringtype_from_single = GetMethod (
+ msvbcs_string_type, "FromSingle", single_arg);
+ msvbcs_stringtype_from_double = GetMethod (
+ msvbcs_string_type, "FromDouble", double_arg);
+ msvbcs_stringtype_from_date = GetMethod (
+ msvbcs_string_type, "FromDate", date_arg);
+ msvbcs_stringtype_from_char = GetMethod (
+ msvbcs_string_type, "FromChar", char_arg);
+
+ msvbcs_decimaltype_from_boolean = GetMethod (
+ msvbcs_decimal_type, "FromBoolean", boolean_arg);
+
+ Type [] string_string_boolean_arg = { string_type, string_type,
bool_type };
+ msvbcs_stringtype_strcmp_string_string_boolean = GetMethod (
+ msvbcs_string_type, "StrCmp",
string_string_boolean_arg);
+
+ Type [] string_string_comparemethod_arg = { string_type,
string_type, msvbcs_comparemethod_type };
+ msvbcs_stringtype_strlike_string_string_comparemethod =
GetMethod (
+ msvbcs_string_type, "StrLike",
string_string_comparemethod_arg);
+
+ }
+
const BindingFlags instance_and_static = BindingFlags.Static |
BindingFlags.Instance;
/// <remarks>
@@ -1661,6 +1857,36 @@
return false;
}
+ //
+ // The following three methods are used by the VB.NET compiler
+ //
+
+ public static bool IsFixedNumericType (Type type)
+ {
+ if (type == byte_type || type == short_type ||
+ type == int32_type || type == int64_type)
+ return true;
+
+ return false;
+ }
+
+ public static bool IsFloatingNumericType (Type type)
+ {
+ if (type == decimal_type ||
+ type == float_type || type == double_type)
+ return true;
+
+ return false;
+ }
+
+ public static bool IsNumericType (Type type)
+ {
+ if (IsFixedNumericType (type) || IsFloatingNumericType(type))
+ return true;
+
+ return false;
+ }
+
public static bool IsDelegateType (Type t)
{
if (t.IsGenericInstance)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches