public void AddFrom(IntegerList l)
 {
     for (int i = 0; i < l.Count; i++)
     {
         base.AddObject(l.Items[i], l.Objects[i]);
     }
 }
 internal ClassObject(BaseScripter scripter, int class_id, int owner_id, ClassKind ck)
     : base(scripter, class_id, owner_id)
 {
     this.PatternMethod = null;
     this.UnderlyingType = null;
     this.RType = null;
     this._namespaceNameIndex = -1;
     this.MinValueId = 0;
     this.MaxValueId = 0;
     this.RangeTypeId = 0;
     this.IndexTypeId = 0;
     this.ht = new Hashtable();
     this.AncestorIds = new IntegerList(false);
     this.ImportedType = null;
     this.Class_Kind = ck;
     this.PatternMethod = null;
 }
 private void FindApplicableConstructorList(IntegerList a, IntegerList param_mod, ref FunctionObject best, ref IntegerList applicable_list)
 {
     for (int i = 0; i < base.Members.Count; i++) {
         MemberObject obj2 = base.Members[i];
         if ((obj2.Kind == MemberKind.Constructor) && !obj2.HasModifier(Modifier.Static)) {
             FunctionObject f = (FunctionObject)obj2;
             this.AddApplicableMethod(f, a, param_mod, 0, ref best, ref applicable_list);
         }
     }
     ClassObject ancestorClass = this.AncestorClass;
     if (!base.Imported) {
         if ((ancestorClass != null) && (best == null)) {
             ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list);
         }
     }
     else {
         IntegerList list = new IntegerList(false);
         foreach (ConstructorInfo info in this.ImportedType.GetConstructors()) {
             list.Add(base.Scripter.symbol_table.RegisterConstructor(info, base.Id));
         }
         if (base.Scripter.SearchProtected) {
             foreach (ConstructorInfo info2 in this.ImportedType.GetConstructors(base.Scripter.protected_binding_flags)) {
                 list.Add(base.Scripter.symbol_table.RegisterConstructor(info2, base.Id));
             }
         }
         for (int j = 0; j < list.Count; j++) {
             FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]);
             this.AddApplicableMethod(functionObject, a, param_mod, 0, ref best, ref applicable_list);
         }
         if ((ancestorClass != null) && (best == null)) {
             ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list);
         }
     }
 }
Exemple #4
0
 public bool IsOperator(IntegerList oper_list, out int op)
 {
     op = 0;
     int index = oper_list.IndexOf(this.curr_token.id);
     if (index >= 0)
     {
         op = oper_list[index];
         this.Call_SCANNER();
         return true;
     }
     return false;
 }
 internal IntegerList GetSupportedInterfaceListIds()
 {
     IntegerList list = new IntegerList(false);
     for (int i = 0; i < this.AncestorIds.Count; i++) {
         int id = this.AncestorIds[i];
         ClassObject val = (ClassObject)base.Scripter.GetVal(id);
         if (val.Class_Kind == ClassKind.Interface) {
             list.Add(id);
             IntegerList supportedInterfaceListIds = val.GetSupportedInterfaceListIds();
             list.AddFrom(supportedInterfaceListIds);
         }
     }
     return list;
 }
Exemple #6
0
 public VB_Parser()
 {
     base.language = "VB";
     base.scanner = new VB_Scanner(this);
     base.upcase = true;
     base.AllowKeywordsInMemberAccessExpressions = true;
     this.variable_initializers = new IntegerList(false);
     this.static_variable_initializers = new IntegerList(false);
     this.param_ids = new IntegerList(true);
     this.param_type_ids = new IntegerList(true);
     this.param_mods = new IntegerList(true);
     this.local_variables = new IntegerList(false);
     this.total_modifier_list = new StringList(false);
     this.total_modifier_list.AddObject("Public", Modifier.Public);
     this.total_modifier_list.AddObject("Protected", Modifier.Protected);
     this.total_modifier_list.AddObject("Internal", Modifier.Internal);
     this.total_modifier_list.AddObject("Private", Modifier.Private);
     this.total_modifier_list.AddObject("Shared", Modifier.Static);
     this.total_modifier_list.AddObject("Overridable", Modifier.Virtual);
     this.total_modifier_list.AddObject("NotOverridable", Modifier.Sealed);
     this.total_modifier_list.AddObject("MustOverride", Modifier.Abstract);
     this.total_modifier_list.AddObject("Overrides", Modifier.Override);
     this.total_modifier_list.AddObject("Overloads", Modifier.Overloads);
     this.total_modifier_list.AddObject("ReadOnly", Modifier.ReadOnly);
     this.total_modifier_list.AddObject("Friend", Modifier.Friend);
     this.total_modifier_list.AddObject("Default", Modifier.Default);
     this.total_modifier_list.AddObject("MustInherit", Modifier.Abstract);
     this.total_modifier_list.AddObject("Shadows", Modifier.Shadows);
     this.total_modifier_list.AddObject("NotInheritable", Modifier.Sealed);
     this.total_modifier_list.AddObject("WithEvents", Modifier.WithEvents);
     base.keywords.Add("AddHandler");
     base.keywords.Add("AddressOf");
     base.keywords.Add("Alias");
     base.keywords.Add("And");
     base.keywords.Add("AndAlso");
     base.keywords.Add("Ansi");
     base.keywords.Add("As");
     base.keywords.Add("Assembly");
     base.keywords.Add("Auto");
     base.keywords.Add("Boolean");
     base.keywords.Add("ByRef");
     base.keywords.Add("Byte");
     base.keywords.Add("ByVal");
     base.keywords.Add("Call");
     base.keywords.Add("Case");
     base.keywords.Add("Catch");
     base.keywords.Add("CBool");
     base.keywords.Add("CByte");
     base.keywords.Add("CChar");
     base.keywords.Add("CDate");
     base.keywords.Add("CDbl");
     base.keywords.Add("CDec");
     base.keywords.Add("Char");
     base.keywords.Add("CInt");
     base.keywords.Add("Class");
     base.keywords.Add("CLng");
     base.keywords.Add("CObj");
     base.keywords.Add("Const");
     base.keywords.Add("CShort");
     base.keywords.Add("CSng");
     base.keywords.Add("CStr");
     base.keywords.Add("CType");
     base.keywords.Add("Date");
     base.keywords.Add("Decimal");
     base.keywords.Add("Declare");
     base.keywords.Add("Default");
     base.keywords.Add("Delegate");
     base.keywords.Add("Dim");
     base.keywords.Add("DirectCast");
     base.keywords.Add("Do");
     base.keywords.Add("Double");
     base.keywords.Add("Each");
     base.keywords.Add("Else");
     base.keywords.Add("ElseIf");
     base.keywords.Add("End");
     base.keywords.Add("EndIf");
     base.keywords.Add("Enum");
     base.keywords.Add("Erase");
     base.keywords.Add("Error");
     base.keywords.Add("Event");
     base.keywords.Add("Exit");
     base.keywords.Add("False");
     base.keywords.Add("Finally");
     base.keywords.Add("For");
     base.keywords.Add("Friend");
     base.keywords.Add("Function");
     base.keywords.Add("Get");
     base.keywords.Add("GoSub");
     base.keywords.Add("GoTo");
     base.keywords.Add("Handles");
     base.keywords.Add("If");
     base.keywords.Add("Implements");
     base.keywords.Add("Imports");
     base.keywords.Add("In");
     base.keywords.Add("Inherits");
     base.keywords.Add("Integer");
     base.keywords.Add("Interface");
     base.keywords.Add("Is");
     base.keywords.Add("Let");
     base.keywords.Add("Lib");
     base.keywords.Add("Like");
     base.keywords.Add("Long");
     base.keywords.Add("Loop");
     base.keywords.Add("Me");
     base.keywords.Add("Mod");
     base.keywords.Add("Module");
     base.keywords.Add("MustInherit");
     base.keywords.Add("MustOverride");
     base.keywords.Add("MyBase");
     base.keywords.Add("MyClass");
     base.keywords.Add("Namespace");
     base.keywords.Add("New");
     base.keywords.Add("Next");
     base.keywords.Add("Not");
     base.keywords.Add("Nothing");
     base.keywords.Add("NotInheritable");
     base.keywords.Add("NotOverridable");
     base.keywords.Add("Object");
     base.keywords.Add("On");
     base.keywords.Add("Option");
     base.keywords.Add("Optional");
     base.keywords.Add("Or");
     base.keywords.Add("Else");
     base.keywords.Add("Overloads");
     base.keywords.Add("Overridable");
     base.keywords.Add("Overrides");
     base.keywords.Add("ParamArray");
     base.keywords.Add("Preserve");
     base.keywords.Add("Private");
     base.keywords.Add("Property");
     base.keywords.Add("Protected");
     base.keywords.Add("Public");
     base.keywords.Add("RaiseEvent");
     base.keywords.Add("ReadOnly");
     base.keywords.Add("ReDim");
     base.keywords.Add("REM");
     base.keywords.Add("RemoveHandler");
     base.keywords.Add("Resume");
     base.keywords.Add("Return");
     base.keywords.Add("Select");
     base.keywords.Add("Set");
     base.keywords.Add("Shadows");
     base.keywords.Add("Shared");
     base.keywords.Add("Short");
     base.keywords.Add("Single");
     base.keywords.Add("Static");
     base.keywords.Add("Step");
     base.keywords.Add("Stop");
     base.keywords.Add("String");
     base.keywords.Add("Structure");
     base.keywords.Add("Sub");
     base.keywords.Add("SyncLock");
     base.keywords.Add("Then");
     base.keywords.Add("Throw");
     base.keywords.Add("To");
     base.keywords.Add("True");
     base.keywords.Add("Try");
     base.keywords.Add("TypeOf");
     base.keywords.Add("Unicode");
     base.keywords.Add("Until");
     base.keywords.Add("Variant");
     base.keywords.Add("Wend");
     base.keywords.Add("When");
     base.keywords.Add("While");
     base.keywords.Add("With");
     base.keywords.Add("WithEvents");
     base.keywords.Add("WriteOnly");
     base.keywords.Add("Xor");
     base.keywords.Add("print");
     base.keywords.Add("println");
     this.enum_modifiers = new ModifierList();
     this.enum_modifiers.Add(Modifier.New);
     this.enum_modifiers.Add(Modifier.Public);
     this.enum_modifiers.Add(Modifier.Protected);
     this.enum_modifiers.Add(Modifier.Internal);
     this.enum_modifiers.Add(Modifier.Private);
     this.class_modifiers = new ModifierList();
     this.class_modifiers.Add(Modifier.New);
     this.class_modifiers.Add(Modifier.Public);
     this.class_modifiers.Add(Modifier.Protected);
     this.class_modifiers.Add(Modifier.Internal);
     this.class_modifiers.Add(Modifier.Private);
     this.class_modifiers.Add(Modifier.Abstract);
     this.class_modifiers.Add(Modifier.Sealed);
     this.class_modifiers.Add(Modifier.Friend);
     this.structure_modifiers = new ModifierList();
     this.structure_modifiers.Add(Modifier.Public);
     this.structure_modifiers.Add(Modifier.Protected);
     this.structure_modifiers.Add(Modifier.Internal);
     this.structure_modifiers.Add(Modifier.Private);
     this.structure_modifiers.Add(Modifier.Friend);
     this.structure_modifiers.Add(Modifier.New);
     this.interface_modifiers = new ModifierList();
     this.interface_modifiers.Add(Modifier.New);
     this.interface_modifiers.Add(Modifier.Public);
     this.interface_modifiers.Add(Modifier.Protected);
     this.interface_modifiers.Add(Modifier.Internal);
     this.interface_modifiers.Add(Modifier.Private);
     this.interface_modifiers.Add(Modifier.Friend);
     this.event_modifiers = new ModifierList();
     this.event_modifiers.Add(Modifier.Public);
     this.event_modifiers.Add(Modifier.Protected);
     this.event_modifiers.Add(Modifier.Internal);
     this.event_modifiers.Add(Modifier.Private);
     this.event_modifiers.Add(Modifier.New);
     this.event_modifiers.Add(Modifier.Static);
     this.method_modifiers = new ModifierList();
     this.method_modifiers.Add(Modifier.Public);
     this.method_modifiers.Add(Modifier.Protected);
     this.method_modifiers.Add(Modifier.Internal);
     this.method_modifiers.Add(Modifier.Private);
     this.method_modifiers.Add(Modifier.New);
     this.method_modifiers.Add(Modifier.Static);
     this.method_modifiers.Add(Modifier.Virtual);
     this.method_modifiers.Add(Modifier.Sealed);
     this.method_modifiers.Add(Modifier.Abstract);
     this.method_modifiers.Add(Modifier.Override);
     this.method_modifiers.Add(Modifier.Overloads);
     this.method_modifiers.Add(Modifier.Friend);
     this.method_modifiers.Add(Modifier.Shadows);
     this.property_modifiers = this.method_modifiers.Clone();
     this.property_modifiers.Add(Modifier.Default);
     this.property_modifiers.Add(Modifier.ReadOnly);
     this.property_modifiers.Add(Modifier.WriteOnly);
     this.constructor_modifiers = new ModifierList();
     this.constructor_modifiers.Add(Modifier.Public);
     this.constructor_modifiers.Add(Modifier.Protected);
     this.constructor_modifiers.Add(Modifier.Internal);
     this.constructor_modifiers.Add(Modifier.Private);
     this.constructor_modifiers.Add(Modifier.Static);
     this.constructor_modifiers.Add(Modifier.Friend);
     this.delegate_modifiers = new ModifierList();
     this.delegate_modifiers.Add(Modifier.Public);
     this.delegate_modifiers.Add(Modifier.Protected);
     this.delegate_modifiers.Add(Modifier.Internal);
     this.delegate_modifiers.Add(Modifier.Private);
     this.delegate_modifiers.Add(Modifier.Static);
     this.delegate_modifiers.Add(Modifier.Friend);
     this.delegate_modifiers.Add(Modifier.Shadows);
     this.integral_types = new CSLite_Types();
     this.integral_types.Add("Byte", StandardType.Byte);
     this.integral_types.Add("Short", StandardType.Short);
     this.integral_types.Add("Integer", StandardType.Int);
     this.integral_types.Add("Long", StandardType.Long);
     this.for_loop_stack = new ForLoopStack();
     this.exit_kind_stack = new IntegerStack();
     this.with_stack = new IntegerStack();
 }
 private void Parse_PropertyMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers, ClassKind ck)
 {
     base.DECLARE_SWITCH = true;
     this.Match("property");
     int num = this.Parse_Ident();
     this.param_ids.Clear();
     this.param_type_ids.Clear();
     this.param_mods.Clear();
     IntegerList list = new IntegerList(true);
     if (base.IsCurrText('['))
     {
         this.Match('[');
         if (!base.IsCurrText(']'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(']');
     }
     base.DECLARE_SWITCH = false;
     this.Match(":");
     int num2 = this.Parse_Type();
     base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num, -1, -1);
     this.Gen(base.code.OP_ASSIGN_TYPE, num, num2, 0);
     int id = 0;
     int iD = 0;
     if (base.IsCurrText("read"))
     {
         this.Call_SCANNER();
         id = this.Parse_Ident();
         string name = base.GetName(id);
         base.DiscardInstruction(base.code.OP_EVAL, 0, 0, id);
         base.SetName(id, "");
         id = base.LookupID(name);
         if (id == 0)
         {
             base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { name });
         }
     }
     if (base.IsCurrText("write"))
     {
         this.Call_SCANNER();
         iD = this.Parse_Ident();
         string s = base.GetName(iD);
         base.DiscardInstruction(base.code.OP_EVAL, 0, 0, iD);
         base.SetName(iD, "");
         iD = base.LookupID(s);
         if (iD == 0)
         {
             base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { s });
         }
     }
     base.BeginProperty(num, ml, num2, 0);
     if (id > 0)
     {
         this.valid_this_context = true;
         int num5 = base.NewVar();
         base.SetName(num5, "get_" + base.GetName(num));
         this.BeginMethod(num5, MemberKind.Method, ml, num2);
         list.Clear();
         for (int i = 0; i < this.param_ids.Count; i++)
         {
             base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1);
             int num7 = base.NewVar();
             base.SetName(num7, base.GetName(this.param_ids[i]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num7, this.param_type_ids[i], 0);
             this.Gen(base.code.OP_ADD_PARAM, num5, num7, 0);
             list.Add(num7);
         }
         this.InitMethod(num5);
         if (base.GetKind(id) == MemberKind.Method)
         {
             int res = base.NewRef(base.GetName(id));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, res);
             this.Gen(base.code.OP_BEGIN_CALL, res, 0, 0);
             for (int j = 0; j < this.param_ids.Count; j++)
             {
                 this.Gen(base.code.OP_PUSH, list[j], 0, res);
             }
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, res, this.param_ids.Count, base.CurrResultId);
         }
         else if (base.GetKind(id) == MemberKind.Field)
         {
             if (this.param_ids.Count > 0)
             {
                 base.RaiseError(false, "PAS0002. Incompatible types");
             }
             int num10 = base.NewRef(base.GetName(id));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num10);
             this.Gen(base.code.OP_ASSIGN, base.CurrResultId, num10, base.CurrResultId);
         }
         else
         {
             base.RaiseError(false, "PAS0001. Field or method identifier expected");
         }
         this.EndMethod(num5);
         this.Gen(base.code.OP_ADD_READ_ACCESSOR, num, num5, 0);
         this.valid_this_context = false;
     }
     if (iD > 0)
     {
         int num12;
         this.valid_this_context = true;
         int num11 = base.NewVar();
         base.SetName(num11, "set_" + base.GetName(num));
         this.BeginMethod(num11, MemberKind.Method, ml, num2);
         list.Clear();
         for (int k = 0; k < this.param_ids.Count; k++)
         {
             base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1);
             num12 = base.NewVar();
             base.SetName(num12, base.GetName(this.param_ids[k]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num12, this.param_type_ids[k], 0);
             this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0);
             list.Add(num12);
         }
         num12 = base.NewVar();
         base.SetName(num12, "value");
         this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num12, num2, 0);
         list.Add(num12);
         this.InitMethod(num11);
         if (base.GetKind(iD) == MemberKind.Method)
         {
             int num14 = base.NewRef(base.GetName(iD));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num14);
             this.Gen(base.code.OP_BEGIN_CALL, num14, 0, 0);
             for (int m = 0; m < list.Count; m++)
             {
                 this.Gen(base.code.OP_PUSH, list[m], 0, num14);
             }
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, num14, list.Count, base.CurrResultId);
         }
         else if (base.GetKind(iD) == MemberKind.Field)
         {
             if (this.param_ids.Count > 0)
             {
                 base.RaiseError(false, "PAS0002. Incompatible types");
             }
             int num16 = base.NewRef(base.GetName(iD));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num16);
             this.Gen(base.code.OP_ASSIGN, num16, num12, num16);
         }
         else
         {
             base.RaiseError(false, "PAS0001. Field or method identifier expected");
         }
         this.EndMethod(num11);
         this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, num, num11, 0);
         this.valid_this_context = false;
     }
     this.Match(";");
     if (base.IsCurrText("default"))
     {
         this.Call_SCANNER();
         if (this.param_ids.Count == 0)
         {
             base.RaiseError(false, "VB00004. Properties with no required parameters cannot be declared 'Default'.");
         }
         else
         {
             this.Gen(base.code.OP_SET_DEFAULT, num, 0, 0);
         }
         this.Match(";");
     }
     base.EndProperty(num);
     base.DECLARE_SWITCH = true;
 }
Exemple #8
0
 private void Parse_NamespaceDeclaration()
 {
     this.Match("Namespace");
     IntegerList list = new IntegerList(false);
     do
     {
         int avalue = this.Parse_Ident();
         list.Add(avalue);
         base.BeginNamespace(avalue);
     }
     while (base.CondMatch('.'));
     Label_003A:
     this.Parse_NamespaceMemberDeclaration();
     if (!base.IsCurrText("End"))
     {
         if (base.IsEOF())
         {
             this.Match("End");
         }
         goto Label_003A;
     }
     for (int i = list.Count - 1; i >= 0; i--)
     {
         base.EndNamespace(list[i]);
     }
     this.Match("End");
     this.Match("Namespace");
     this.MatchLineTerminator();
 }
Exemple #9
0
 private IntegerList Parse_VariableIdentifiers(ArrayList bounds_list, ArrayList sl)
 {
     IntegerList list = new IntegerList(false);
     while (true)
     {
         string str;
         IntegerList bounds = new IntegerList(true);
         int avalue = this.Parse_VariableIdentifier(bounds, out str);
         list.Add(avalue);
         bounds_list.Add(bounds);
         sl.Add(str);
         if (!base.CondMatch(','))
         {
             return list;
         }
     }
 }
Exemple #10
0
 internal int FindConstructorId(IntegerList a, IntegerList param_mod, out FunctionObject best)
 {
     if (a == null) {
         a = new IntegerList(false);
     }
     if (param_mod == null) {
         param_mod = new IntegerList(false);
     }
     IntegerList list = new IntegerList(false);
     best = null;
     this.FindApplicableConstructorList(a, param_mod, ref best, ref list);
     this.CompressApplicableMethodList(a, list);
     if (list.Count >= 1) {
         return list[0];
     }
     return 0;
 }
Exemple #11
0
 internal int FindDestructorId(IntegerList a)
 {
     for (int i = 0; i < base.Members.Count; i++) {
         MemberObject obj2 = base.Members[i];
         if (obj2.Kind == MemberKind.Destructor) {
             return obj2.Id;
         }
     }
     return 0;
 }
Exemple #12
0
 internal void AddApplicableMethod(FunctionObject f, IntegerList a, IntegerList param_mod, int res_id, ref FunctionObject best, ref IntegerList applicable_list)
 {
     if (best == null) {
         best = f;
     }
     if (((f.ParamCount <= a.Count) && ((f.ParamCount >= a.Count) || (f.ParamsId != 0))) && ((res_id == 0) || base.Scripter.MatchAssignment(f.ResultId, res_id))) {
         best = f;
         if (f.ParamCount == 0) {
             applicable_list.Add(f.Id);
         }
         else {
             bool flag = true;
             for (int i = 0; i < a.Count; i++) {
                 int num2 = a[i];
                 int paramId = f.GetParamId(i);
                 flag = ((int)f.GetParamMod(i) == param_mod[i]);
                 if (!flag && !f.Imported) {
                     if (base.Scripter.code.GetLanguage(base.Scripter.code.n) != CSLite_Language.VB) {
                         break;
                     }
                     flag = true;
                 }
                 flag = base.Scripter.MatchAssignment(paramId, num2);
                 if (!flag) {
                     if (base.Scripter.code.GetLanguage(base.Scripter.code.n) == CSLite_Language.VB) {
                         int typeId = base.Scripter.symbol_table[paramId].TypeId;
                         int id = base.Scripter.symbol_table[num2].TypeId;
                         ClassObject classObject = base.Scripter.GetClassObject(typeId);
                         ClassObject obj3 = base.Scripter.GetClassObject(id);
                         flag = base.Scripter.MatchTypes(classObject, obj3);
                     }
                     if (!flag) {
                         break;
                     }
                 }
             }
             if (flag) {
                 applicable_list.Add(f.Id);
             }
         }
     }
 }
Exemple #13
0
 internal void CompressApplicableMethodList(IntegerList a, IntegerList applicable_list)
 {
     while (applicable_list.Count >= 2) {
         int id = applicable_list[0];
         FunctionObject functionObject = base.Scripter.GetFunctionObject(id);
         bool flag = true;
         for (int i = 1; i < applicable_list.Count; i++) {
             int num3 = applicable_list[i];
             FunctionObject obj3 = base.Scripter.GetFunctionObject(num3);
             int num4 = 0;
             int num5 = 0;
             for (int j = 0; j < a.Count; j++) {
                 int num7 = a[j];
                 int paramId = functionObject.GetParamId(j);
                 int num9 = obj3.GetParamId(j);
                 int num10 = base.Scripter.conversion.CompareConversions(base.Scripter, num7, paramId, num9);
                 if (num10 > 0) {
                     num4++;
                 }
                 else if (num10 < 0) {
                     num5++;
                 }
             }
             if ((num4 > 0) && (num5 == 0)) {
                 flag = false;
                 applicable_list.DeleteValue(num3);
                 break;
             }
             if ((num5 > 0) && (num4 == 0)) {
                 flag = false;
                 applicable_list.DeleteValue(id);
                 break;
             }
         }
         if (flag) {
             break;
         }
     }
 }
 internal int GetEntryId()
 {
     IntegerList list = new IntegerList(false);
     for (int i = 0; i < this.symbol_table.Card; i++)
     {
         if ((this.symbol_table[i].Kind == MemberKind.Method) && (this.symbol_table[i].Name == "Main"))
         {
             for (int j = 1; j < this.code.Card; j++)
             {
                 if ((this.code[j].op == this.code.OP_CREATE_METHOD) && (this.code[j].arg1 == i))
                 {
                     for (int k = j + 1; this.code[k].op == this.code.OP_ADD_MODIFIER; k++)
                     {
                         if (this.code[k].arg2 == 7)
                         {
                             list.Add(i);
                             break;
                         }
                     }
                 }
             }
         }
     }
     if (list.Count == 0)
     {
         return 0;
     }
     if (list.Count == 1)
     {
         return list[0];
     }
     return -1;
 }
 private void Parse_ArrayTypeDeclaration(int array_id, ModifierList ml)
 {
     base.CheckModifiers(ml, this.structure_modifiers);
     base.BeginArray(array_id, ml);
     this.Match("array");
     IntegerList list = new IntegerList(false);
     list.Add(array_id);
     if (!base.IsCurrText('['))
     {
         this.Gen(base.code.OP_ADD_ARRAY_RANGE, array_id, 8, 0);
         goto Label_00AA;
     }
     this.Match('[');
     Label_0043:
     this.Gen(base.code.OP_ADD_ARRAY_RANGE, array_id, this.Parse_OrdinalType(), 0);
     if (base.IsCurrText(','))
     {
         this.Match(',');
         array_id = base.NewVar();
         base.BeginArray(array_id, ml);
         list.Add(array_id);
         goto Label_0043;
     }
     this.Match(']');
     Label_00AA:
     this.Match("of");
     list.Add(this.Parse_Type());
     for (int i = list.Count - 1; i > 0; i--)
     {
         this.Gen(base.code.OP_ADD_ARRAY_INDEX, list[i - 1], list[i], 0);
         base.EndArray(list[i - 1]);
     }
     this.CreateDefaultConstructor(list[0], false);
 }
 public Pascal_Parser()
 {
     base.language = "Pascal";
     base.scanner = new Pascal_Scanner(this);
     base.upcase = true;
     base.AllowKeywordsInMemberAccessExpressions = true;
     this.variable_initializers = new IntegerList(false);
     this.static_variable_initializers = new IntegerList(false);
     this.param_ids = new IntegerList(true);
     this.param_type_ids = new IntegerList(true);
     this.param_mods = new IntegerList(true);
     this.local_variables = new IntegerList(false);
     this.total_modifier_list = new StringList(false);
     this.total_modifier_list.AddObject("Public", Modifier.Public);
     this.total_modifier_list.AddObject("Protected", Modifier.Protected);
     this.total_modifier_list.AddObject("Internal", Modifier.Internal);
     this.total_modifier_list.AddObject("Private", Modifier.Private);
     this.total_modifier_list.AddObject("Shared", Modifier.Static);
     this.total_modifier_list.AddObject("Override", Modifier.Override);
     this.total_modifier_list.AddObject("Overloads", Modifier.Overloads);
     this.total_modifier_list.AddObject("ReadOnly", Modifier.ReadOnly);
     this.total_modifier_list.AddObject("Shadows", Modifier.Shadows);
     base.keywords.Add("and");
     base.keywords.Add("as");
     base.keywords.Add("begin");
     base.keywords.Add("break");
     base.keywords.Add("case");
     base.keywords.Add("char");
     base.keywords.Add("class");
     base.keywords.Add("const");
     base.keywords.Add("constructor");
     base.keywords.Add("continue");
     base.keywords.Add("decimal");
     base.keywords.Add("default");
     base.keywords.Add("delegate");
     base.keywords.Add("destructor");
     base.keywords.Add("do");
     base.keywords.Add("double");
     base.keywords.Add("downto");
     base.keywords.Add("each");
     base.keywords.Add("else");
     base.keywords.Add("end");
     base.keywords.Add("exit");
     base.keywords.Add("false");
     base.keywords.Add("finally");
     base.keywords.Add("for");
     base.keywords.Add("forward");
     base.keywords.Add("function");
     base.keywords.Add("goto");
     base.keywords.Add("if");
     base.keywords.Add("in");
     base.keywords.Add("integer");
     base.keywords.Add("interface");
     base.keywords.Add("implementation");
     base.keywords.Add("initialization");
     base.keywords.Add("finalization");
     base.keywords.Add("is");
     base.keywords.Add("mod");
     base.keywords.Add("namespace");
     base.keywords.Add("nil");
     base.keywords.Add("not");
     base.keywords.Add("object");
     base.keywords.Add("of");
     base.keywords.Add("on");
     base.keywords.Add("or");
     base.keywords.Add("else");
     base.keywords.Add("override");
     base.keywords.Add("private");
     base.keywords.Add("program");
     base.keywords.Add("procedure");
     base.keywords.Add("property");
     base.keywords.Add("protected");
     base.keywords.Add("public");
     base.keywords.Add("read");
     base.keywords.Add("record");
     base.keywords.Add("repeat");
     base.keywords.Add("set");
     base.keywords.Add("short");
     base.keywords.Add("single");
     base.keywords.Add("static");
     base.keywords.Add("string");
     base.keywords.Add("then");
     base.keywords.Add("to");
     base.keywords.Add("true");
     base.keywords.Add("try");
     base.keywords.Add("type");
     base.keywords.Add("uses");
     base.keywords.Add("unit");
     base.keywords.Add("until");
     base.keywords.Add("var");
     base.keywords.Add("variant");
     base.keywords.Add("while");
     base.keywords.Add("with");
     base.keywords.Add("write");
     base.keywords.Add("xor");
     base.keywords.Add("print");
     base.keywords.Add("println");
     this.enum_modifiers = new ModifierList();
     this.enum_modifiers.Add(Modifier.New);
     this.enum_modifiers.Add(Modifier.Public);
     this.enum_modifiers.Add(Modifier.Protected);
     this.enum_modifiers.Add(Modifier.Internal);
     this.enum_modifiers.Add(Modifier.Private);
     this.class_modifiers = new ModifierList();
     this.class_modifiers.Add(Modifier.New);
     this.class_modifiers.Add(Modifier.Public);
     this.class_modifiers.Add(Modifier.Protected);
     this.class_modifiers.Add(Modifier.Internal);
     this.class_modifiers.Add(Modifier.Private);
     this.class_modifiers.Add(Modifier.Abstract);
     this.class_modifiers.Add(Modifier.Sealed);
     this.class_modifiers.Add(Modifier.Friend);
     this.structure_modifiers = new ModifierList();
     this.structure_modifiers.Add(Modifier.Public);
     this.structure_modifiers.Add(Modifier.Protected);
     this.structure_modifiers.Add(Modifier.Internal);
     this.structure_modifiers.Add(Modifier.Private);
     this.structure_modifiers.Add(Modifier.Friend);
     this.structure_modifiers.Add(Modifier.New);
     this.interface_modifiers = new ModifierList();
     this.interface_modifiers.Add(Modifier.New);
     this.interface_modifiers.Add(Modifier.Public);
     this.interface_modifiers.Add(Modifier.Protected);
     this.interface_modifiers.Add(Modifier.Internal);
     this.interface_modifiers.Add(Modifier.Private);
     this.interface_modifiers.Add(Modifier.Friend);
     this.event_modifiers = new ModifierList();
     this.event_modifiers.Add(Modifier.Public);
     this.event_modifiers.Add(Modifier.Protected);
     this.event_modifiers.Add(Modifier.Internal);
     this.event_modifiers.Add(Modifier.Private);
     this.event_modifiers.Add(Modifier.New);
     this.event_modifiers.Add(Modifier.Static);
     this.method_modifiers = new ModifierList();
     this.method_modifiers.Add(Modifier.Public);
     this.method_modifiers.Add(Modifier.Protected);
     this.method_modifiers.Add(Modifier.Internal);
     this.method_modifiers.Add(Modifier.Private);
     this.method_modifiers.Add(Modifier.New);
     this.method_modifiers.Add(Modifier.Static);
     this.method_modifiers.Add(Modifier.Virtual);
     this.method_modifiers.Add(Modifier.Sealed);
     this.method_modifiers.Add(Modifier.Abstract);
     this.method_modifiers.Add(Modifier.Override);
     this.method_modifiers.Add(Modifier.Overloads);
     this.method_modifiers.Add(Modifier.Friend);
     this.method_modifiers.Add(Modifier.Shadows);
     this.property_modifiers = this.method_modifiers.Clone();
     this.property_modifiers.Add(Modifier.Default);
     this.property_modifiers.Add(Modifier.ReadOnly);
     this.property_modifiers.Add(Modifier.WriteOnly);
     this.constructor_modifiers = new ModifierList();
     this.constructor_modifiers.Add(Modifier.Public);
     this.constructor_modifiers.Add(Modifier.Protected);
     this.constructor_modifiers.Add(Modifier.Internal);
     this.constructor_modifiers.Add(Modifier.Private);
     this.constructor_modifiers.Add(Modifier.Static);
     this.constructor_modifiers.Add(Modifier.Friend);
     this.delegate_modifiers = new ModifierList();
     this.delegate_modifiers.Add(Modifier.Public);
     this.delegate_modifiers.Add(Modifier.Protected);
     this.delegate_modifiers.Add(Modifier.Internal);
     this.delegate_modifiers.Add(Modifier.Private);
     this.delegate_modifiers.Add(Modifier.Static);
     this.delegate_modifiers.Add(Modifier.Friend);
     this.delegate_modifiers.Add(Modifier.Shadows);
     this.integral_types = new CSLite_Types();
     this.integral_types.Add("Byte", StandardType.Byte);
     this.integral_types.Add("Short", StandardType.Short);
     this.integral_types.Add("Integer", StandardType.Int);
     this.integral_types.Add("Long", StandardType.Long);
 }
Exemple #17
0
 private void FindApplicableMethodList(int name_index, IntegerList a, IntegerList param_mod, int res_id, ref FunctionObject best, ref IntegerList applicable_list, bool upcase)
 {
     string upcaseNameByNameIndex = base.Scripter.GetUpcaseNameByNameIndex(name_index);
     for (int i = 0; i < base.Members.Count; i++) {
         MemberObject obj2 = base.Members[i];
         if (obj2.Kind == MemberKind.Method) {
             bool flag;
             if (upcase) {
                 flag = upcaseNameByNameIndex == obj2.UpcaseName;
             }
             else {
                 flag = obj2.NameIndex == name_index;
             }
             if (flag) {
                 FunctionObject f = (FunctionObject)obj2;
                 this.AddApplicableMethod(f, a, param_mod, res_id, ref best, ref applicable_list);
             }
         }
     }
     ClassObject ancestorClass = this.AncestorClass;
     if (!base.Imported) {
         if (ancestorClass != null) {
             ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
         }
     }
     else {
         string str2 = base.Scripter.names[name_index];
         IntegerList list = new IntegerList(false);
         foreach (MethodInfo info in this.ImportedType.GetMethods()) {
             if (str2 == info.Name) {
                 bool flag2 = true;
                 foreach (Attribute attribute in Attribute.GetCustomAttributes(info)) {
                     if (attribute is CSLite_ScriptForbid) {
                         flag2 = false;
                     }
                 }
                 if (flag2) {
                     int avalue = base.Scripter.symbol_table.RegisterMethod(info, base.Id);
                     list.Add(avalue);
                 }
             }
         }
         if (base.Scripter.SearchProtected) {
             foreach (MethodInfo info2 in this.ImportedType.GetMethods(base.Scripter.protected_binding_flags)) {
                 if (str2 == info2.Name) {
                     bool flag3 = true;
                     foreach (Attribute attribute2 in Attribute.GetCustomAttributes(info2)) {
                         if (attribute2 is CSLite_ScriptForbid) {
                             flag3 = false;
                         }
                     }
                     if (flag3) {
                         int num3 = base.Scripter.symbol_table.RegisterMethod(info2, base.Id);
                         list.Add(num3);
                     }
                 }
             }
         }
         for (int j = 0; j < list.Count; j++) {
             FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]);
             this.AddApplicableMethod(functionObject, a, param_mod, res_id, ref best, ref applicable_list);
         }
         if (ancestorClass != null) {
             ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
         }
         for (int k = 0; k < this.AncestorIds.Count; k++) {
             ClassObject classObject = base.Scripter.GetClassObject(this.AncestorIds[k]);
             if (classObject.IsInterface) {
                 classObject.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase);
             }
         }
     }
 }
Exemple #18
0
 internal int FindMethodId(int name_index, IntegerList a, IntegerList param_mod, int res_id, out FunctionObject best, bool upcase)
 {
     if (a == null) {
         a = new IntegerList(false);
     }
     if (param_mod == null) {
         param_mod = new IntegerList(false);
     }
     IntegerList list = new IntegerList(false);
     best = null;
     this.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref list, upcase);
     if (list.Count > 1) {
         this.CompressApplicableMethodList(a, list);
     }
     if (list.Count >= 1) {
         int id = list[0];
         best = base.Scripter.GetFunctionObject(id);
         return id;
     }
     return 0;
 }
Exemple #19
0
 private string Parse_ArrayNameModifier(IntegerList bounds)
 {
     string str = "";
     this.Match('(');
     str = str + "[";
     if (!base.IsCurrText(')'))
     {
         while (true)
         {
             if (!base.IsCurrText(','))
             {
                 int avalue = this.Parse_Expression();
                 bounds.Add(avalue);
             }
             if (!base.CondMatch(','))
             {
                 break;
             }
             str = str + ",";
         }
     }
     this.Match(')');
     return (str + "]");
 }
Exemple #20
0
 internal int FindMethodId(string name, IntegerList a, IntegerList param_mod, int res_id, out FunctionObject best, bool upcase)
 {
     int num = base.Scripter.names.Add(name);
     return this.FindMethodId(num, a, param_mod, res_id, out best, upcase);
 }
Exemple #21
0
 private int Parse_VariableIdentifier(IntegerList bounds, out string s)
 {
     int num = this.Parse_Ident();
     if (base.IsCurrText('('))
     {
         s = this.Parse_ArrayNameModifier(bounds);
         return num;
     }
     s = "";
     return num;
 }
 private int Parse_MultiArrayInitializer(int array_type_id)
 {
     string name = base.GetName(array_type_id);
     int rank = CSLite_System.GetRank(name);
     string elementTypeName = CSLite_System.GetElementTypeName(name);
     int id = base.NewVar();
     base.SetName(id, elementTypeName);
     this.Gen(base.code.OP_EVAL_TYPE, 0, 0, id);
     int res = base.NewVar();
     this.Gen(base.code.OP_CREATE_OBJECT, array_type_id, 0, res);
     this.Gen(base.code.OP_BEGIN_CALL, array_type_id, 0, 0);
     IntegerList list = new IntegerList(true);
     IntegerList list2 = new IntegerList(true);
     IntegerList list3 = new IntegerList(true);
     IntegerList list4 = new IntegerList(true);
     for (int i = 0; i < rank; i++)
     {
         int avalue = base.NewVar(-1);
         list.Add(avalue);
         list2.Add(-1);
         list3.Add(-1);
         list4.Add(0);
         this.Gen(base.code.OP_PUSH, avalue, 0, array_type_id);
     }
     this.Gen(base.code.OP_PUSH, res, 0, 0);
     this.Gen(base.code.OP_CALL, array_type_id, rank, 0);
     int num6 = -1;
     Label_0113:
     if (base.IsCurrText('{'))
     {
         IntegerList list8=null;
         int num16;
         this.Match('{');
         num6++;
         if (num6 == (rank - 1))
         {
             list3[num6] = -1;
             while (true)
             {
                 IntegerList list6=null;
                 int num14;
                 if (base.IsCurrText('}'))
                 {
                     goto Label_0113;
                 }
                 if (list4[num6] == 0)
                 {
                     IntegerList list5=list2;
                     int num13=num6;
                     //(list5 = list2)[num13 = num6] = list5[num13] + 1;
                     list5[num13 ] = list5[num13] + 1;
                 }
                 list6 = list3;
                 num14 = num6;
                 //(list6 = list3)[num14 = num6] = list6[num14] + 1;
                 list6[num14] = list6[num14] + 1;
                 int num7 = base.NewVar();
                 this.Gen(base.code.OP_CREATE_INDEX_OBJECT, res, 0, num7);
                 for (int j = 0; j < rank; j++)
                 {
                     int num9 = base.NewConst(list3[j]);
                     this.Gen(base.code.OP_ADD_INDEX, num7, num9, res);
                 }
                 this.Gen(base.code.OP_SETUP_INDEX_OBJECT, num7, 0, 0);
                 this.Gen(base.code.OP_ASSIGN, num7, this.Parse_Expression(), num7);
                 if (!base.CondMatch(','))
                 {
                     goto Label_0113;
                 }
             }
         }
         if (list4[num6] == 0)
         {
             IntegerList list7=list2;
             int num15=num6;
             //(list7 = list2)[num15 = num6] = list7[num15] + 1;
             list7[num15] = list7[num15] + 1;
         }
         list8 = list3;
         num16 = num6;
         //(list8 = list3)[num16 = num6] = list8[num16] + 1;
         list8[num16] = list8[num16] + 1;
     }
     else if (base.IsCurrText(','))
     {
         IntegerList list10=null;
         int num18;
         this.Match(',');
         if (list4[num6] == 0)
         {
             IntegerList list9= list2;
             int num17= num6;
             //(list9 = list2)[num17 = num6] = list9[num17] + 1;
             list9[num17]=list9[num17] + 1;
         }
         list10 = list3;
         num18 = num6;
         //(list10 = list3)[num18 = num6] = list10[num18] + 1;
         list10[num18] = list10[num18] + 1;
         for (int k = num6 + 1; k < rank; k++)
         {
             list3[k] = -1;
         }
     }
     else if (base.IsCurrText('}'))
     {
         IntegerList list11=null;
         int num19;
         this.Match('}');
         if (list2[num6] != list3[num6])
         {
             base.RaiseError(true, "CS0178. Incorrectly structured array initializer.");
         }
         list4[num6] = 1;
         list11 = list3;
         num19 = num6;
         //(list11 = list3)[num19 = num6] = list11[num19] - 1;
         list11[num19]=list11[num19] - 1;
         num6--;
         if (num6 == -1)
         {
             for (int m = 0; m < rank; m++)
             {
                 base.PutVal(list[m], list2[m] + 1);
             }
             return res;
         }
     }
     else
     {
         this.Match('{');
     }
     goto Label_0113;
 }
Exemple #23
0
 public void Parse_LocalDeclarationStatement(LocalModifier m)
 {
     this.local_variables.Clear();
     base.DECLARE_SWITCH = true;
     base.DECLARATION_CHECK_SWITCH = true;
     ArrayList list = new ArrayList();
     ArrayList list2 = new ArrayList();
     this.Call_SCANNER();
     do
     {
         int num = 0x10;
         do
         {
             int num2 = this.Parse_Ident();
             this.Gen(base.code.OP_DECLARE_LOCAL_VARIABLE, num2, base.CurrSubId, 0);
             this.local_variables.Add(num2);
             if (m == LocalModifier.Static)
             {
                 base.SetStaticLocalVar(num2);
             }
             if (base.IsCurrText('('))
             {
                 IntegerList bounds = new IntegerList(true);
                 string str = this.Parse_ArrayNameModifier(bounds);
                 list.Add(bounds);
                 list2.Add(str);
             }
             else
             {
                 list.Add(null);
                 list2.Add(null);
             }
         }
         while (base.CondMatch(','));
         base.DECLARE_SWITCH = false;
         if (base.IsCurrText("As"))
         {
             this.Match("As");
             bool flag = base.curr_token.id == base.DATETIME_CLASS_id;
             if (base.IsCurrText("New") || flag)
             {
                 if (base.IsCurrText("New"))
                 {
                     this.Match("New");
                     flag = base.curr_token.id == base.DATETIME_CLASS_id;
                 }
                 num = this.Parse_Type();
                 if (this.local_variables.Count == 1)
                 {
                     if (list2[0] != null)
                     {
                         base.RaiseError(true, "VB00003. Arrays cannot be declared with 'New'");
                     }
                     int res = this.local_variables[0];
                     this.Gen(base.code.OP_CREATE_OBJECT, num, 0, res);
                     if (base.IsCurrText('('))
                     {
                         this.Match('(');
                         this.Gen(base.code.OP_CALL, num, this.Parse_ArgumentList(')', num, res), 0);
                         this.Match(')');
                     }
                     else
                     {
                         this.Gen(base.code.OP_BEGIN_CALL, num, 0, 0);
                         if (flag)
                         {
                             this.Gen(base.code.OP_PUSH, base.NewConst(0), 0, num);
                         }
                         this.Gen(base.code.OP_PUSH, res, 0, 0);
                         this.Gen(base.code.OP_CALL, num, 0, 0);
                     }
                 }
                 else
                 {
                     base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
                 }
             }
             else
             {
                 num = this.Parse_TypeEx();
             }
         }
         else if (this.OPTION_STRICT)
         {
             base.RaiseError(false, "VB00006. Option Strict On requires all variable declarations to have an 'As' clause.");
         }
         for (int i = 0; i < this.local_variables.Count; i++)
         {
             int num5 = this.local_variables[i];
             if (list2[i] != null)
             {
                 string str2 = (string) list2[i];
                 int id = num;
                 int num7 = base.NewVar();
                 base.SetName(num7, base.GetName(id) + str2);
                 this.Gen(base.code.OP_EVAL_TYPE, id, 0, num7);
                 this.Gen(base.code.OP_ASSIGN_TYPE, num5, num7, 0);
                 IntegerList list4 = (IntegerList) list[i];
                 this.Gen(base.code.OP_CREATE_OBJECT, num7, 0, num5);
                 int count = list4.Count;
                 if (count > 0)
                 {
                     this.Gen(base.code.OP_BEGIN_CALL, num7, 0, 0);
                     for (int j = 0; j < count; j++)
                     {
                         this.Gen(base.code.OP_INC, list4[j], 0, list4[j]);
                         this.Gen(base.code.OP_PUSH, list4[j], 0, num7);
                     }
                     this.Gen(base.code.OP_PUSH, num5, 0, 0);
                     this.Gen(base.code.OP_CALL, num7, count, 0);
                 }
                 num = num7;
             }
             else
             {
                 this.Gen(base.code.OP_ASSIGN_TYPE, num5, num, 0);
             }
         }
         if (base.IsCurrText('='))
         {
             base.DECLARE_SWITCH = false;
             this.Match('=');
             if (this.local_variables.Count == 1)
             {
                 int num10 = this.local_variables[0];
                 if (base.IsCurrText('{'))
                 {
                     this.Gen(base.code.OP_ASSIGN, num10, this.Parse_ArrayInitializer(num), num10);
                 }
                 else
                 {
                     this.Gen(base.code.OP_ASSIGN, num10, this.Parse_Expression(), num10);
                 }
                 this.Gen(base.code.OP_INIT_STATIC_VAR, num10, 0, 0);
             }
             else
             {
                 base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
             }
             base.DECLARE_SWITCH = true;
         }
         else
         {
             for (int k = 0; k < this.local_variables.Count; k++)
             {
                 int num12 = this.local_variables[k];
                 this.Gen(base.code.OP_CHECK_STRUCT_CONSTRUCTOR, num, 0, num12);
             }
         }
         base.DECLARE_SWITCH = true;
     }
     while (base.CondMatch(','));
     base.DECLARE_SWITCH = false;
     base.DECLARATION_CHECK_SWITCH = false;
     this.MatchStatementTerminator();
 }
 private void Parse_SwitchStmt()
 {
     int label = base.NewLabel();
     int num2 = base.NewLabel();
     IntegerList list = new IntegerList(true);
     IntegerList list2 = new IntegerList(true);
     IntegerStack stack = new IntegerStack();
     int num3 = base.NewVar();
     this.Gen(base.code.OP_ASSIGN, num3, base.TRUE_id, num3);
     base.BreakStack.Push(label);
     this.Match("switch");
     base.BeginBlock();
     this.Match('(');
     int num4 = this.Parse_Expression();
     this.Match(')');
     this.Match('{');
     Label_008D:
     if (base.IsCurrText("case"))
     {
         this.Match("case");
         stack.Push(base.NewLabel());
         int avalue = this.Parse_Expression();
         list.AddObject(avalue, stack.Peek());
         this.Gen(base.code.OP_EQ, num4, avalue, num3);
         this.Gen(base.code.OP_GO_TRUE, stack.Peek(), num3, 0);
     }
     else
     {
         if (!base.IsCurrText("default"))
         {
             while (stack.Count > 0)
             {
                 base.SetLabelHere(stack.Peek());
                 stack.Pop();
             }
             int num6 = base.NewLabel();
             this.Gen(base.code.OP_GO_FALSE, num6, num3, 0);
             while ((!base.IsCurrText("case") && !base.IsCurrText("default")) && !base.IsCurrText('}'))
             {
                 if (base.IsCurrText("goto"))
                 {
                     this.Match("goto");
                     if (base.IsCurrText("case"))
                     {
                         this.Match("case");
                         int num7 = this.Parse_Expression();
                         this.Gen(base.code.OP_GOTO_START, 0, 0, 0);
                         list2.AddObject(num7, base.CodeCard);
                         this.Match(';');
                     }
                     else if (base.IsCurrText("default"))
                     {
                         this.Match("default");
                         this.Gen(base.code.OP_GOTO_START, num2, 0, 0);
                         this.Match(';');
                     }
                     else
                     {
                         int num8 = this.Parse_Ident();
                         this.Gen(base.code.OP_GOTO_START, num8, 0, 0);
                         this.Match(';');
                     }
                 }
                 else
                 {
                     this.Parse_Stmt();
                 }
             }
             base.SetLabelHere(num6);
             if (base.IsCurrText('}'))
             {
                 base.BreakStack.Pop();
                 base.SetLabelHere(label);
                 base.EndBlock();
                 this.Match('}');
                 for (int i = 0; i < list2.Count; i++)
                 {
                     int id = list2[i];
                     int n = (int) list2.Objects[i];
                     object val = base.GetVal(id);
                     bool flag = false;
                     for (int j = 0; j < list.Count; j++)
                     {
                         int num13 = list[j];
                         int num14 = (int) list.Objects[j];
                         object obj3 = base.GetVal(num13);
                         if ((val.GetType() == obj3.GetType()) && (val == obj3))
                         {
                             flag = true;
                             base.GenAt(n, base.code.OP_GOTO_START, num14, 0, 0);
                             break;
                         }
                     }
                     if (!flag)
                     {
                         base.CodeCard = n;
                         base.RaiseErrorEx(true, "CS0159. No such label '{0}' within the scope of the goto statement.", new object[] { val.ToString() });
                     }
                 }
                 return;
             }
             goto Label_008D;
         }
         this.Match("default");
         base.SetLabelHere(num2);
         this.Gen(base.code.OP_ASSIGN, num3, base.TRUE_id, num3);
     }
     this.Match(':');
     goto Label_008D;
 }
 private int Parse_FreeArrayInitializer(int array_type_id, ref IntegerList bounds)
 {
     int num3;
     string name = base.GetName(array_type_id);
     int rank = CSLite_System.GetRank(name);
     string elementTypeName = CSLite_System.GetElementTypeName(name);
     IntegerList list = new IntegerList(true);
     int id = base.NewVar();
     base.SetName(id, elementTypeName);
     this.Gen(base.code.OP_EVAL_TYPE, 0, 0, id);
     int res = base.NewVar();
     this.Gen(base.code.OP_CREATE_OBJECT, array_type_id, 0, res);
     this.Gen(base.code.OP_BEGIN_CALL, array_type_id, 0, 0);
     IntegerList list2 = new IntegerList(true);
     for (int i = 0; i < rank; i++)
     {
         num3 = base.NewVar(0);
         list2.Add(num3);
         this.Gen(base.code.OP_PUSH, num3, 0, array_type_id);
     }
     this.Gen(base.code.OP_PUSH, res, 0, 0);
     this.Gen(base.code.OP_CALL, array_type_id, rank, 0);
     int num6 = 0;
     this.Match('{');
     if (!base.IsCurrText('}'))
     {
         num6 = 0;
         do
         {
             num6++;
             int num7 = base.NewVar();
             int num8 = base.NewConst(num6 - 1);
             this.Gen(base.code.OP_CREATE_INDEX_OBJECT, res, 0, num7);
             this.Gen(base.code.OP_ADD_INDEX, num7, num8, res);
             this.Gen(base.code.OP_SETUP_INDEX_OBJECT, num7, 0, 0);
             num3 = base.NewVar();
             if (base.IsCurrText('{'))
             {
                 num3 = this.Parse_FreeArrayInitializer(id, ref list);
             }
             else
             {
                 num3 = this.Parse_Expression();
             }
             this.Gen(base.code.OP_ASSIGN, num7, num3, num7);
         }
         while (base.CondMatch(','));
     }
     this.Match('}');
     num3 = list2[0];
     base.PutVal(num3, num6);
     bounds.Add(num6);
     for (int j = 1; j < list2.Count; j++)
     {
         num3 = list2[j];
         num6 = list[j - 1];
         base.PutVal(num3, num6);
         bounds.Add(num6);
     }
     return res;
 }
 private IntegerList Parse_DirectiveList()
 {
     IntegerList list = new IntegerList(false);
     while (true)
     {
         while (base.IsCurrText("overload"))
         {
             this.Call_SCANNER();
             list.Add(0);
             this.Match(';');
         }
         if (!base.IsCurrText("forward"))
         {
             return list;
         }
         this.Call_SCANNER();
         list.Add(1);
         this.Match(';');
     }
 }
 private void Parse_NamespaceDeclaration()
 {
     this.Match("namespace");
     IntegerList list = new IntegerList(false);
     do
     {
         int avalue = this.Parse_Ident();
         list.Add(avalue);
         base.BeginNamespace(avalue);
     }
     while (base.CondMatch('.'));
     this.Match('{');
     if (base.IsCurrText("using"))
     {
         this.Parse_UsingDirectives();
     }
     if (!base.IsCurrText('}'))
     {
         this.Parse_NamespaceMemberDeclarations();
     }
     for (int i = list.Count - 1; i >= 0; i--)
     {
         base.EndNamespace(list[i]);
     }
     this.Match('}');
     if (base.IsCurrText(';'))
     {
         this.Match(';');
     }
 }
Exemple #28
0
 internal int FindOverloadableImplicitOperatorId(int actual_id, int res_id)
 {
     bool upcase = false;
     int num = base.Scripter.names.Add("op_Implicit");
     IntegerList a = new IntegerList(false);
     a.Add(actual_id);
     IntegerList list2 = new IntegerList(false);
     list2.Add(0);
     IntegerList list3 = new IntegerList(false);
     FunctionObject best = null;
     this.FindApplicableMethodList(num, a, list2, res_id, ref best, ref list3, upcase);
     this.CompressApplicableMethodList(a, list3);
     if (list3.Count >= 1) {
         int id = list3[0];
         best = base.Scripter.GetFunctionObject(id);
         return id;
     }
     return 0;
 }
 public CSharp_Parser()
 {
     base.language = "CSharp";
     base.scanner = new CSharp_Scanner(this);
     base.upcase = false;
     this.variable_initializers = new IntegerList(false);
     this.static_variable_initializers = new IntegerList(false);
     this.param_ids = new IntegerList(true);
     this.param_type_ids = new IntegerList(true);
     this.param_mods = new IntegerList(true);
     this.local_variables = new IntegerList(false);
     base.keywords.Add("abstract");
     base.keywords.Add("as");
     base.keywords.Add("base");
     base.keywords.Add("bool");
     base.keywords.Add("break");
     base.keywords.Add("byte");
     base.keywords.Add("case");
     base.keywords.Add("catch");
     base.keywords.Add("char");
     base.keywords.Add("checked");
     base.keywords.Add("class");
     base.keywords.Add("const");
     base.keywords.Add("continue");
     base.keywords.Add("decimal");
     base.keywords.Add("default");
     base.keywords.Add("delegate");
     base.keywords.Add("do");
     base.keywords.Add("double");
     base.keywords.Add("else");
     base.keywords.Add("enum");
     base.keywords.Add("event");
     base.keywords.Add("explicit");
     base.keywords.Add("extern");
     base.keywords.Add("false");
     base.keywords.Add("finally");
     base.keywords.Add("fixed");
     base.keywords.Add("float");
     base.keywords.Add("for");
     base.keywords.Add("foreach");
     base.keywords.Add("goto");
     base.keywords.Add("if");
     base.keywords.Add("implicit");
     base.keywords.Add("in");
     base.keywords.Add("int");
     base.keywords.Add("interface");
     base.keywords.Add("internal");
     base.keywords.Add("is");
     base.keywords.Add("lock");
     base.keywords.Add("long");
     base.keywords.Add("namespace");
     base.keywords.Add("new");
     base.keywords.Add("null");
     base.keywords.Add("object");
     base.keywords.Add("operator");
     base.keywords.Add("out");
     base.keywords.Add("override");
     base.keywords.Add("params");
     base.keywords.Add("private");
     base.keywords.Add("protected");
     base.keywords.Add("public");
     base.keywords.Add("readonly");
     base.keywords.Add("ref");
     base.keywords.Add("return");
     base.keywords.Add("sbyte");
     base.keywords.Add("sealed");
     base.keywords.Add("short");
     base.keywords.Add("sizeof");
     base.keywords.Add("stackalloc");
     base.keywords.Add("static");
     base.keywords.Add("string");
     base.keywords.Add("struct");
     base.keywords.Add("switch");
     base.keywords.Add("this");
     base.keywords.Add("throw");
     base.keywords.Add("true");
     base.keywords.Add("try");
     base.keywords.Add("typeof");
     base.keywords.Add("uint");
     base.keywords.Add("ulong");
     base.keywords.Add("unchecked");
     base.keywords.Add("unsafe");
     base.keywords.Add("ushort");
     base.keywords.Add("using");
     base.keywords.Add("virtual");
     base.keywords.Add("void");
     base.keywords.Add("while");
     base.keywords.Add("print");
     base.keywords.Add("println");
     base.keywords.Add("function");
     this.total_modifier_list = new StringList(false);
     this.total_modifier_list.AddObject("new", Modifier.New);
     this.total_modifier_list.AddObject("public", Modifier.Public);
     this.total_modifier_list.AddObject("protected", Modifier.Protected);
     this.total_modifier_list.AddObject("internal", Modifier.Internal);
     this.total_modifier_list.AddObject("private", Modifier.Private);
     this.total_modifier_list.AddObject("abstract", Modifier.Abstract);
     this.total_modifier_list.AddObject("sealed", Modifier.Sealed);
     this.total_modifier_list.AddObject("static", Modifier.Static);
     this.total_modifier_list.AddObject("readonly", Modifier.ReadOnly);
     this.total_modifier_list.AddObject("volatile", Modifier.Volatile);
     this.total_modifier_list.AddObject("override", Modifier.Override);
     this.total_modifier_list.AddObject("virtual", Modifier.Virtual);
     this.total_modifier_list.AddObject("extern", Modifier.Extern);
     this.class_modifiers = new ModifierList();
     this.class_modifiers.Add(Modifier.New);
     this.class_modifiers.Add(Modifier.Public);
     this.class_modifiers.Add(Modifier.Protected);
     this.class_modifiers.Add(Modifier.Internal);
     this.class_modifiers.Add(Modifier.Private);
     this.class_modifiers.Add(Modifier.Abstract);
     this.class_modifiers.Add(Modifier.Sealed);
     this.constant_modifiers = new ModifierList();
     this.constant_modifiers.Add(Modifier.New);
     this.constant_modifiers.Add(Modifier.Public);
     this.constant_modifiers.Add(Modifier.Protected);
     this.constant_modifiers.Add(Modifier.Internal);
     this.constant_modifiers.Add(Modifier.Private);
     this.field_modifiers = new ModifierList();
     this.field_modifiers.Add(Modifier.New);
     this.field_modifiers.Add(Modifier.Public);
     this.field_modifiers.Add(Modifier.Protected);
     this.field_modifiers.Add(Modifier.Internal);
     this.field_modifiers.Add(Modifier.Private);
     this.field_modifiers.Add(Modifier.Static);
     this.field_modifiers.Add(Modifier.ReadOnly);
     this.field_modifiers.Add(Modifier.Volatile);
     this.method_modifiers = new ModifierList();
     this.method_modifiers.Add(Modifier.New);
     this.method_modifiers.Add(Modifier.Public);
     this.method_modifiers.Add(Modifier.Protected);
     this.method_modifiers.Add(Modifier.Internal);
     this.method_modifiers.Add(Modifier.Private);
     this.method_modifiers.Add(Modifier.Static);
     this.method_modifiers.Add(Modifier.Virtual);
     this.method_modifiers.Add(Modifier.Sealed);
     this.method_modifiers.Add(Modifier.Override);
     this.method_modifiers.Add(Modifier.Abstract);
     this.method_modifiers.Add(Modifier.Extern);
     this.operator_modifiers = new ModifierList();
     this.operator_modifiers.Add(Modifier.Public);
     this.operator_modifiers.Add(Modifier.Static);
     this.operator_modifiers.Add(Modifier.Extern);
     this.constructor_modifiers = new ModifierList();
     this.constructor_modifiers.Add(Modifier.Public);
     this.constructor_modifiers.Add(Modifier.Protected);
     this.constructor_modifiers.Add(Modifier.Internal);
     this.constructor_modifiers.Add(Modifier.Private);
     this.constructor_modifiers.Add(Modifier.Extern);
     this.constructor_modifiers.Add(Modifier.Static);
     this.destructor_modifiers = new ModifierList();
     this.destructor_modifiers.Add(Modifier.Extern);
     this.structure_modifiers = new ModifierList();
     this.structure_modifiers.Add(Modifier.New);
     this.structure_modifiers.Add(Modifier.Public);
     this.structure_modifiers.Add(Modifier.Protected);
     this.structure_modifiers.Add(Modifier.Internal);
     this.structure_modifiers.Add(Modifier.Private);
     this.interface_modifiers = new ModifierList();
     this.interface_modifiers.Add(Modifier.New);
     this.interface_modifiers.Add(Modifier.Public);
     this.interface_modifiers.Add(Modifier.Protected);
     this.interface_modifiers.Add(Modifier.Internal);
     this.interface_modifiers.Add(Modifier.Private);
     this.enum_modifiers = new ModifierList();
     this.enum_modifiers.Add(Modifier.New);
     this.enum_modifiers.Add(Modifier.Public);
     this.enum_modifiers.Add(Modifier.Protected);
     this.enum_modifiers.Add(Modifier.Internal);
     this.enum_modifiers.Add(Modifier.Private);
     this.delegate_modifiers = new ModifierList();
     this.delegate_modifiers.Add(Modifier.New);
     this.delegate_modifiers.Add(Modifier.Public);
     this.delegate_modifiers.Add(Modifier.Protected);
     this.delegate_modifiers.Add(Modifier.Internal);
     this.delegate_modifiers.Add(Modifier.Private);
     this.standard_types = new CSLite_Types();
     this.standard_types.Add("", StandardType.None);
     this.standard_types.Add("void", StandardType.Void);
     this.standard_types.Add("bool", StandardType.Bool);
     this.standard_types.Add("byte", StandardType.Byte);
     this.standard_types.Add("char", StandardType.Char);
     this.standard_types.Add("decimal", StandardType.Decimal);
     this.standard_types.Add("double", StandardType.Double);
     this.standard_types.Add("float", StandardType.Float);
     this.standard_types.Add("int", StandardType.Int);
     this.standard_types.Add("long", StandardType.Long);
     this.standard_types.Add("sbyte", StandardType.Sbyte);
     this.standard_types.Add("short", StandardType.Short);
     this.standard_types.Add("string", StandardType.String);
     this.standard_types.Add("uint", StandardType.Uint);
     this.standard_types.Add("ulong", StandardType.Ulong);
     this.standard_types.Add("ushort", StandardType.Ushort);
     this.standard_types.Add("object", StandardType.Object);
     this.integral_types = new CSLite_Types();
     this.integral_types.Add("sbyte", StandardType.Sbyte);
     this.integral_types.Add("byte", StandardType.Byte);
     this.integral_types.Add("short", StandardType.Short);
     this.integral_types.Add("ushort", StandardType.Ushort);
     this.integral_types.Add("int", StandardType.Int);
     this.integral_types.Add("uint", StandardType.Uint);
     this.integral_types.Add("long", StandardType.Long);
     this.integral_types.Add("ulong", StandardType.Ulong);
     this.integral_types.Add("char", StandardType.Char);
     this.assign_operators = new Hashtable();
     this.relational_operators = new Hashtable();
     this.shift_operators = new Hashtable();
     this.additive_operators = new Hashtable();
     this.multiplicative_operators = new Hashtable();
     this.overloadable_unary_operators = new StringList(true);
     this.overloadable_binary_operators = new StringList(false);
 }
Exemple #30
0
 internal int FindOverloadableUnaryOperatorId(string operator_name, int arg1)
 {
     if (base.Id > 0x10) {
         IntegerList list = new IntegerList(false);
         FunctionObject best = null;
         IntegerList a = new IntegerList(true);
         a.Add(arg1);
         IntegerList list3 = new IntegerList(true);
         list3.Add(0);
         int num = base.Scripter.names.Add(operator_name);
         this.FindApplicableMethodList(num, a, list3, 0, ref best, ref list, false);
         this.CompressApplicableMethodList(a, list);
         if (list.Count >= 1) {
             return list[0];
         }
     }
     return 0;
 }