Beispiel #1
0
 public ModifierList Clone()
 {
     ModifierList list = new ModifierList();
     for (int i = 0; i < this.Count; i++)
     {
         list.Add(this[i]);
     }
     return list;
 }
Beispiel #2
0
 internal MemberObject(BaseScripter scripter, int id, int owner_id)
     : base(scripter)
 {
     this.ImplementsId = 0;
     this.PCodeLine = 0;
     this.Modifiers = new ModifierList();
     this.Members = new MemberList(scripter);
     this.Id = id;
     this.OwnerId = owner_id;
     this.Kind = scripter.symbol_table[this.Id].Kind;
     this.NameIndex = scripter.symbol_table[this.Id].NameIndex;
     this.Imported = false;
 }
 private void Parse_ClassDeclaration(ModifierList ml)
 {
     base.DECLARE_SWITCH = true;
     this.has_constructor = false;
     base.CheckModifiers(ml, this.class_modifiers);
     this.Match("class");
     int num = this.Parse_Ident();
     if (ml.HasModifier(Modifier.Abstract) && ml.HasModifier(Modifier.Sealed))
     {
         base.RaiseError(false, "CS0502. The class '{0}' is abstract and sealed.");
     }
     base.BeginClass(num, ml);
     if (base.IsCurrText(':'))
     {
         this.Parse_ClassBase(num);
     }
     else
     {
         this.Gen(base.code.OP_ADD_ANCESTOR, num, base.ObjectClassId, 0);
     }
     this.Parse_ClassBody(num, ml);
     if (this.static_variable_initializers.Count > 0)
     {
         this.CreateDefaultStaticConstructor(num);
     }
     if (!this.has_constructor)
     {
         this.CreateDefaultConstructor(num, false);
     }
     base.EndClass(num);
     if (base.IsCurrText(';'))
     {
         this.Match(';');
     }
 }
 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);
 }
 private void CreateDefaultStaticConstructor(int class_id)
 {
     ModifierList ml = new ModifierList();
     ml.Add(Modifier.Static);
     int num = base.NewVar();
     this.BeginMethod(num, MemberKind.Constructor, ml, 1);
     this.InitMethod(num);
     for (int i = 0; i < this.static_variable_initializers.Count; i++)
     {
         int num3 = this.static_variable_initializers[i];
         this.Gen(base.code.OP_BEGIN_CALL, num3, 0, 0);
         this.Gen(base.code.OP_PUSH, class_id, 0, 0);
         this.Gen(base.code.OP_CALL, num3, 0, 0);
     }
     this.EndMethod(num);
 }
 private void Add_InstanceVariableInitializer(int id, int type_id, ModifierList ml)
 {
     int num = 0;
     if (type_id == 2)
     {
         num = base.NewConst(false);
     }
     else if (type_id == 3)
     {
         num = base.NewConst((byte) 0);
     }
     else if (type_id == 4)
     {
         num = base.NewConst(' ');
     }
     else if (type_id == 5)
     {
         num = base.NewConst(0M);
     }
     else if (type_id == 6)
     {
         num = base.NewConst(0.0);
     }
     else if (type_id == 7)
     {
         num = base.NewConst(0f);
     }
     else if (type_id == 8)
     {
         num = base.NewConst(0);
     }
     else if (type_id == 9)
     {
         num = base.NewConst(0L);
     }
     else if (type_id == 10)
     {
         num = base.NewConst((sbyte) 0);
     }
     else if (type_id == 11)
     {
         num = base.NewConst((short) 0);
     }
     else if (type_id == 12)
     {
         num = base.NewConst("");
     }
     else if (type_id == 13)
     {
         num = base.NewConst(0);
     }
     else if (type_id == 14)
     {
         num = base.NewConst((ulong) 0L);
     }
     else if (type_id == 15)
     {
         num = base.NewConst((ushort) 0);
     }
     if (num > 0)
     {
         int num2 = base.NewVar();
         this.BeginMethod(num2, MemberKind.Method, ml, 1);
         this.InitMethod(num2);
         int num3 = id;
         if (!ml.HasModifier(Modifier.Static))
         {
             num3 = base.NewVar();
             base.SetName(num3, base.GetName(id));
             this.Gen(base.code.OP_EVAL, 0, 0, num3);
             this.variable_initializers.Add(num2);
         }
         else
         {
             this.static_variable_initializers.Add(num2);
         }
         this.Gen(base.code.OP_ASSIGN, num3, num, num3);
         this.EndMethod(num2);
     }
 }
 private void Parse_StructMemberDeclaration(int struct_id, ModifierList owner_modifiers)
 {
     this.Parse_MemberDeclaration(struct_id, ClassKind.Struct, owner_modifiers);
 }
 private void Parse_PropertyAccessorDeclarations(int id, int type_id, ModifierList ml)
 {
     this.ACCESSOR_SWITCH = true;
     if (type_id == 1)
     {
         base.RaiseError(true, "CS0547. '{0}' : property or indexer cannot have void type.");
     }
     this.Match('{');
     int num = 0;
     int num2 = 0;
     Label_0028:
     if (base.IsCurrText('['))
     {
         this.Parse_Attributes();
     }
     if (base.IsCurrText("get"))
     {
         int num3 = base.NewVar();
         base.SetName(num3, "get_" + base.GetName(id));
         this.BeginMethod(num3, MemberKind.Method, ml, type_id);
         num++;
         if (num > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         this.Match("get");
         for (int i = 0; i < this.param_ids.Count; i++)
         {
             int num5 = base.NewVar();
             base.SetName(num5, base.GetName(this.param_ids[i]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num5, this.param_type_ids[i], 0);
             this.Gen(base.code.OP_ADD_PARAM, num3, num5, 0);
         }
         if (base.IsCurrText(';'))
         {
             if (!ml.HasModifier(Modifier.Extern) && !ml.HasModifier(Modifier.Abstract))
             {
                 base.RaiseErrorEx(false, "CS0501. '{0}' must declare a body because it is not marked abstract or extern.", new object[] { base.GetName(num3) });
             }
             this.Match(';');
         }
         else
         {
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num3);
                 base.RaiseErrorEx(true, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             this.InitMethod(num3);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num3);
         this.Gen(base.code.OP_ADD_READ_ACCESSOR, id, num3, 0);
         goto Label_0028;
     }
     if (base.IsCurrText("set"))
     {
         int num7;
         int num6 = base.NewVar();
         base.SetName(num6, "set_" + base.GetName(id));
         this.BeginMethod(num6, MemberKind.Method, ml, 1);
         num2++;
         if (num2 > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         this.Match("set");
         for (int j = 0; j < this.param_ids.Count; j++)
         {
             num7 = base.NewVar();
             base.SetName(num7, base.GetName(this.param_ids[j]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num7, this.param_type_ids[j], 0);
             this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         }
         num7 = base.NewVar();
         base.SetName(num7, "value");
         this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num7, type_id, 0);
         if (base.IsCurrText(';'))
         {
             if (!ml.HasModifier(Modifier.Extern) && !ml.HasModifier(Modifier.Abstract))
             {
                 base.RaiseErrorEx(false, "CS0501. '{0}' must declare a body because it is not marked abstract or extern.", new object[] { base.GetName(num6) });
             }
             this.Match(';');
         }
         else
         {
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string str2 = base.GetName(num6);
                 base.RaiseErrorEx(true, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { str2 });
             }
             this.InitMethod(num6);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num6);
         this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, id, num6, 0);
         goto Label_0028;
     }
     if ((num + num2) == 0)
     {
         base.RaiseErrorEx(true, "CS0548. '{0}' : property or indexer must have at least one accessor.", new object[] { base.GetName(id) });
     }
     this.Match('}');
     this.ACCESSOR_SWITCH = true;
 }
Beispiel #9
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();
 }
Beispiel #10
0
 private void Parse_VariableMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers)
 {
     if (base.IsCurrText("Dim"))
     {
         this.Match("Dim");
     }
     do
     {
         this.Parse_VariableDeclarator(ml);
     }
     while (base.CondMatch(','));
     this.MatchLineTerminator();
 }
Beispiel #11
0
 private void Parse_VariableDeclarator(ModifierList ml)
 {
     ArrayList list = new ArrayList();
     ArrayList sl = new ArrayList();
     IntegerList list3 = this.Parse_VariableIdentifiers(list, sl);
     int objectClassId = base.ObjectClassId;
     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;
                 objectClassId = this.Parse_Type();
             }
             else
             {
                 objectClassId = this.Parse_TypeEx();
             }
             if (list3.Count == 1)
             {
                 string str = (string) sl[0];
                 if ((str != null) && (str != ""))
                 {
                     base.RaiseError(true, "VB00003. Arrays cannot be declared with 'New'");
                 }
                 int num2 = list3[0];
                 this.Gen(base.code.OP_ASSIGN_TYPE, num2, objectClassId, 0);
                 base.BeginField(num2, ml, objectClassId);
                 base.DECLARE_SWITCH = false;
                 int num3 = base.NewVar();
                 this.BeginMethod(num3, MemberKind.Method, ml, 1);
                 this.InitMethod(num3);
                 int id = num2;
                 if (!ml.HasModifier(Modifier.Static))
                 {
                     id = base.NewVar();
                     base.SetName(id, base.GetName(num2));
                     this.Gen(base.code.OP_EVAL, 0, 0, id);
                     this.variable_initializers.Add(num3);
                 }
                 else
                 {
                     this.static_variable_initializers.Add(num3);
                 }
                 this.Gen(base.code.OP_CREATE_OBJECT, objectClassId, 0, id);
                 if (base.IsCurrText('('))
                 {
                     this.Match('(');
                     this.Gen(base.code.OP_CALL, objectClassId, this.Parse_ArgumentList(')', objectClassId, id), 0);
                     this.Match(')');
                 }
                 else
                 {
                     this.Gen(base.code.OP_BEGIN_CALL, objectClassId, 0, 0);
                     if (flag)
                     {
                         this.Gen(base.code.OP_PUSH, base.NewConst(0), 0, objectClassId);
                     }
                     this.Gen(base.code.OP_PUSH, id, 0, 0);
                     this.Gen(base.code.OP_CALL, objectClassId, 0, 0);
                 }
                 this.EndMethod(num3);
                 base.DECLARE_SWITCH = true;
                 base.EndField(num2);
             }
             else
             {
                 base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
             }
             return;
         }
         objectClassId = 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 < list3.Count; i++)
     {
         int num6 = list3[i];
         if (((string) sl[i]) != "")
         {
             base.BeginField(num6, ml, objectClassId);
             int num7 = base.NewVar();
             this.BeginMethod(num7, MemberKind.Method, ml, 1);
             this.InitMethod(num7);
             int num8 = num6;
             if (!ml.HasModifier(Modifier.Static))
             {
                 num8 = base.NewVar();
                 base.SetName(num8, base.GetName(num6));
                 this.Gen(base.code.OP_EVAL, 0, 0, num8);
                 this.variable_initializers.Add(num7);
             }
             else
             {
                 this.static_variable_initializers.Add(num7);
             }
             string str2 = (string) sl[i];
             int num9 = objectClassId;
             int num10 = base.NewVar();
             base.SetName(num10, base.GetName(num9) + str2);
             this.Gen(base.code.OP_EVAL_TYPE, num9, 0, num10);
             this.Gen(base.code.OP_ASSIGN_TYPE, num8, num10, 0);
             this.Gen(base.code.OP_ASSIGN_TYPE, num6, num10, 0);
             IntegerList list4 = (IntegerList) list[i];
             this.Gen(base.code.OP_CREATE_OBJECT, num10, 0, num8);
             int count = list4.Count;
             if (count > 0)
             {
                 this.Gen(base.code.OP_BEGIN_CALL, num10, 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, num10);
                 }
                 this.Gen(base.code.OP_PUSH, num8, 0, 0);
                 this.Gen(base.code.OP_CALL, num10, count, 0);
             }
             objectClassId = num10;
             this.EndMethod(num7);
             base.EndField(num6);
         }
         else
         {
             this.Gen(base.code.OP_ASSIGN_TYPE, num6, objectClassId, 0);
             base.BeginField(num6, ml, objectClassId);
             base.EndField(num6);
         }
     }
     if (base.IsCurrText("="))
     {
         this.Match('=');
         if (list3.Count == 1)
         {
             int num13 = list3[0];
             this.Gen(base.code.OP_ASSIGN_TYPE, num13, objectClassId, 0);
             this.Parse_VariableInitializer(num13, objectClassId, ml);
         }
         else
         {
             base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
         }
     }
 }
Beispiel #12
0
 private void Parse_SubDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     int num;
     this.Match("Sub");
     this.PushExitKind(ExitKind.Sub);
     int num2 = 1;
     this.valid_this_context = true;
     if (base.IsCurrText("New"))
     {
         IntegerList list;
         bool flag = ml.HasModifier(Modifier.Static);
         base.CheckModifiers(ml, this.constructor_modifiers);
         if (flag && this.HasAccessModifier(ml))
         {
             base.RaiseErrorEx(false, "CS0515. '{0}' : access modifiers are not allowed on static constructors.", new object[] { base.GetName(class_id) });
         }
         num = base.NewVar();
         this.Call_SCANNER();
         this.BeginMethod(num, MemberKind.Constructor, ml, 1);
         if (base.IsCurrText('('))
         {
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 if (flag)
                 {
                     base.RaiseErrorEx(false, "CS0132. '{0}' : a static constructor must be parameterless.", new object[] { base.GetName(class_id) });
                 }
                 this.Parse_ParameterList(num, false);
             }
             this.Match(')');
         }
         this.InitMethod(num);
         if (flag)
         {
             list = this.static_variable_initializers;
         }
         else
         {
             list = this.variable_initializers;
         }
         for (int i = 0; i < list.Count; i++)
         {
             int num4 = list[i];
             this.Gen(base.code.OP_BEGIN_CALL, num4, 0, 0);
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, num4, 0, 0);
         }
         base.DECLARE_SWITCH = false;
         this.MatchLineTerminator();
         this.Parse_Block();
         this.EndMethod(num);
         this.valid_this_context = false;
         if (flag)
         {
             this.static_variable_initializers.Clear();
         }
         else
         {
             this.has_constructor = true;
         }
         base.DECLARE_SWITCH = true;
         this.Match("End");
         this.Match("Sub");
         this.PopExitKind();
         this.MatchLineTerminator();
     }
     else
     {
         num = this.Parse_Ident();
         this.CheckMethodModifiers(num, class_id, ml, owner_ml);
         this.BeginMethod(num, MemberKind.Method, ml, num2);
         if (this.explicit_intf_id > 0)
         {
             this.Gen(base.code.OP_ADD_EXPLICIT_INTERFACE, num, this.explicit_intf_id, 0);
         }
         if (base.IsCurrText('('))
         {
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 this.Parse_ParameterList(num, false);
             }
             this.Match(')');
         }
         if (ml.HasModifier(Modifier.Extern))
         {
             base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(num) });
         }
         if (ck != ClassKind.Interface)
         {
             this.InitMethod(num);
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num);
                 base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
             }
             if (base.IsCurrText("Handles"))
             {
                 this.Parse_HandlesClause();
             }
             else if (base.IsCurrText("Implements"))
             {
                 this.Parse_ImplementsClause(num);
             }
             base.DECLARE_SWITCH = false;
             this.MatchLineTerminator();
             this.Parse_Block();
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
             }
             this.Match("End");
             this.Match("Sub");
         }
         this.EndMethod(num);
         this.valid_this_context = false;
         base.DECLARE_SWITCH = true;
         this.PopExitKind();
         this.MatchLineTerminator();
     }
 }
Beispiel #13
0
 private void Parse_StructureDeclaration(ModifierList ml)
 {
     base.DECLARE_SWITCH = true;
     this.has_constructor = false;
     base.CheckModifiers(ml, this.structure_modifiers);
     this.Match("Structure");
     int num = this.Parse_Ident();
     this.MatchLineTerminator();
     base.BeginStruct(num, ml);
     this.Gen(base.code.OP_ADD_ANCESTOR, num, base.ObjectClassId, 0);
     if (!base.IsCurrText("End"))
     {
         this.Parse_ClassBody(num, ml, false);
     }
     if (this.static_variable_initializers.Count > 0)
     {
         this.CreateDefaultStaticConstructor(num);
     }
     if (!this.has_constructor)
     {
         this.CreateDefaultConstructor(num, false);
     }
     base.EndStruct(num);
     this.Match("End");
     this.Match("Structure");
     this.MatchLineTerminator();
 }
Beispiel #14
0
 private void Parse_PropertyMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers, ClassKind ck)
 {
     this.Match("Property");
     int num = this.Parse_Ident();
     this.param_ids.Clear();
     this.param_type_ids.Clear();
     this.param_mods.Clear();
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(')');
     }
     int num2 = 0x10;
     if (base.IsCurrText("As"))
     {
         this.Match("As");
         this.Parse_Attributes();
         num2 = this.Parse_TypeEx();
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num, -1, -1);
         this.Gen(base.code.OP_ASSIGN_TYPE, num, num2, 0);
     }
     base.BeginProperty(num, ml, num2, 0);
     if (ml.HasModifier(Modifier.Default))
     {
         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);
         }
     }
     if (base.IsCurrText("Implements"))
     {
         this.Parse_ImplementsClause(num);
     }
     int num3 = 0;
     int num4 = 0;
     Label_0110:
     this.MatchLineTerminator();
     this.Parse_Attributes();
     if (base.IsCurrText("Get"))
     {
         this.curr_prop_id = num;
         this.Match("Get");
         base.DECLARE_SWITCH = false;
         this.valid_this_context = true;
         this.MatchLineTerminator();
         int id = base.NewVar();
         base.SetName(id, "get_" + base.GetName(num));
         this.BeginMethod(id, MemberKind.Method, ml, num2);
         num3++;
         if (num3 > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         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, id, num7, 0);
         }
         this.InitMethod(id);
         this.Parse_Block();
         this.EndMethod(id);
         this.Gen(base.code.OP_ADD_READ_ACCESSOR, num, id, 0);
         base.DECLARE_SWITCH = true;
         this.valid_this_context = false;
         this.Match("End");
         this.Match("Get");
         this.curr_prop_id = 0;
         goto Label_0110;
     }
     if (base.IsCurrText("Set"))
     {
         this.valid_this_context = true;
         this.Match("Set");
         int num8 = base.NewVar();
         base.SetName(num8, "set_" + base.GetName(num));
         this.BeginMethod(num8, MemberKind.Method, ml, num2);
         num4++;
         if (num4 > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         if (this.IsLineTerminator())
         {
             int num9;
             for (int j = 0; j < this.param_ids.Count; j++)
             {
                 num9 = base.NewVar();
                 base.SetName(num9, base.GetName(this.param_ids[j]));
                 this.Gen(base.code.OP_ASSIGN_TYPE, num9, this.param_type_ids[j], 0);
                 this.Gen(base.code.OP_ADD_PARAM, num8, num9, 0);
             }
             num9 = base.NewVar();
             base.SetName(num9, "value");
             this.Gen(base.code.OP_ADD_PARAM, num8, num9, 0);
             this.Gen(base.code.OP_ASSIGN_TYPE, num9, num2, 0);
             base.DECLARE_SWITCH = false;
             this.InitMethod(num8);
             this.MatchLineTerminator();
         }
         else
         {
             if (base.IsCurrText('('))
             {
                 for (int k = 0; k < this.param_ids.Count; k++)
                 {
                     int 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, num8, num12, 0);
                 }
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     this.Parse_ParameterList(num8, false);
                 }
                 this.Match(')');
             }
             base.DECLARE_SWITCH = false;
             this.InitMethod(num8);
             this.MatchLineTerminator();
         }
         this.Parse_Block();
         this.EndMethod(num8);
         this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, num, num8, 0);
         base.DECLARE_SWITCH = true;
         this.valid_this_context = false;
         this.Match("End");
         this.Match("Set");
         goto Label_0110;
     }
     base.EndProperty(num);
     if ((num3 + num4) == 0)
     {
         if (ml.HasModifier(Modifier.Abstract))
         {
             return;
         }
         base.RaiseErrorEx(true, "CS0548. '{0}' : property or indexer must have at least one accessor.", new object[] { base.GetName(num) });
     }
     this.Match("End");
     this.Match("Property");
     this.MatchLineTerminator();
 }
Beispiel #15
0
 private void Parse_MethodMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     base.DECLARE_SWITCH = true;
     if (base.IsCurrText("Sub"))
     {
         this.Parse_SubDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("Function"))
     {
         this.Parse_FunctionDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("Declare"))
     {
         this.Parse_ExternalMethodDeclaration(class_id, ml, owner_ml);
     }
     else
     {
         this.Match("Sub");
     }
 }
Beispiel #16
0
 private void Parse_MemberDeclaration(int class_id, ClassKind ck, ModifierList owner_ml)
 {
     int num27;
     int num28;
     string name = base.GetName(class_id);
     base.DECLARE_SWITCH = true;
     if (base.IsCurrText('['))
     {
         this.Parse_Attributes();
     }
     ModifierList ml = this.Parse_Modifiers();
     bool flag = ml.HasModifier(Modifier.Static);
     int k = base.ReadToken();
     string text = base.curr_token.Text;
     k += base.ReadToken();
     string str3 = base.curr_token.Text;
     base.Backup_SCANNER(k);
     if ((((base.IsCurrText("enum") | base.IsCurrText("class")) | base.IsCurrText("struct")) | base.IsCurrText("interface")) | base.IsCurrText("delegate"))
     {
         this.Parse_TypeDeclaration(ml);
     }
     else if (!base.IsCurrText("const"))
     {
         ModifierList list2;
         if (!base.IsCurrText("event"))
         {
             if (base.IsCurrText("implicit"))
             {
                 base.CheckModifiers(ml, this.operator_modifiers);
                 this.Match("implicit");
                 this.Match("operator");
                 if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
                 {
                     base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { "op_Implicit" });
                 }
                 int num11 = this.Parse_Type();
                 int num12 = base.NewVar();
                 base.SetName(num12, "op_Implicit");
                 this.BeginMethod(num12, MemberKind.Method, ml, num11);
                 this.Match('(');
                 if (this.Parse_FormalParameterList(num12, false) != 1)
                 {
                     base.RaiseErrorEx(false, "CS1535. Overloaded unary operator '{0}' only takes one parameter.", new object[] { "implicit" });
                 }
                 this.Match(')');
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num12);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num12);
                 goto Label_1519;
             }
             if (base.IsCurrText("explicit"))
             {
                 base.CheckModifiers(ml, this.operator_modifiers);
                 this.Match("explicit");
                 this.Match("operator");
                 if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
                 {
                     base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { "op_Explicit" });
                 }
                 int num14 = this.Parse_Type();
                 int num15 = base.NewVar();
                 base.SetName(num15, "op_Explicit");
                 this.BeginMethod(num15, MemberKind.Method, ml, num14);
                 this.Match('(');
                 if (this.Parse_FormalParameterList(num15, false) != 1)
                 {
                     base.RaiseErrorEx(false, "CS1535. Overloaded unary operator '{0}' only takes one parameter.", new object[] { "explicit" });
                 }
                 this.Match(')');
                 string str6 = base.GetName(num14);
                 string str7 = base.GetName(this.param_type_ids[0]);
                 if ((str6 == name) && (str7 == name))
                 {
                     base.RaiseError(false, "CS0556. User-defined conversion must convert to or from the enclosing type.");
                 }
                 if ((str6 != name) && (str7 != name))
                 {
                     base.RaiseError(false, "CS0556. User-defined conversion must convert to or from the enclosing type.");
                 }
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num15);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num15);
                 goto Label_1519;
             }
             if (base.IsCurrText("~"))
             {
                 if (ck == ClassKind.Struct)
                 {
                     base.RaiseError(false, "CS0575. Only class types can contain destructors.");
                 }
                 base.CheckModifiers(ml, this.destructor_modifiers);
                 this.Match("~");
                 int num17 = this.Parse_Ident();
                 if (base.GetName(class_id) != base.GetName(num17))
                 {
                     base.RaiseError(false, "CS0574. Name of destructor must match name of class.");
                 }
                 this.BeginMethod(num17, MemberKind.Method, ml, 1);
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     this.Parse_FormalParameterList(num17, false);
                 }
                 this.Match(')');
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num17);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num17);
                 goto Label_1519;
             }
             if ((base.GetName(class_id) == base.curr_token.Text) && (text == "("))
             {
                 IntegerList list3;
                 base.CheckModifiers(ml, this.constructor_modifiers);
                 if (flag && this.HasAccessModifier(ml))
                 {
                     base.RaiseErrorEx(false, "CS0515. '{0}' : access modifiers are not allowed on static constructors.", new object[] { base.GetName(class_id) });
                 }
                 int num18 = this.Parse_Ident();
                 this.valid_this_context = true;
                 this.BeginMethod(num18, MemberKind.Constructor, ml, 1);
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     if (flag)
                     {
                         base.RaiseErrorEx(false, "CS0132. '{0}' : a static constructor must be parameterless.", new object[] { base.GetName(class_id) });
                     }
                     this.Parse_FormalParameterList(num18, false);
                 }
                 else if (ck == ClassKind.Struct)
                 {
                     base.RaiseError(false, "CS0568. Structs cannot contain explicit parameterless constructors.");
                 }
                 this.Match(')');
                 this.InitMethod(num18);
                 if (flag)
                 {
                     list3 = this.static_variable_initializers;
                 }
                 else
                 {
                     list3 = this.variable_initializers;
                 }
                 for (int i = 0; i < list3.Count; i++)
                 {
                     int num20 = list3[i];
                     this.Gen(base.code.OP_BEGIN_CALL, num20, 0, 0);
                     this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
                     this.Gen(base.code.OP_CALL, num20, 0, 0);
                 }
                 if (base.IsCurrText(':'))
                 {
                     this.Match(':');
                     if (flag)
                     {
                         base.RaiseErrorEx(false, "CS0514. '{0}' : static constructor cannot have an explicit this or base constructor call.", new object[] { base.GetName(class_id) });
                     }
                     if (base.IsCurrText("base"))
                     {
                         if (ck == ClassKind.Struct)
                         {
                             base.RaiseErrorEx(false, "CS0522. '{0}' : structs cannot call base class constructors.", new object[] { base.GetName(class_id) });
                         }
                         this.Match("base");
                         int num21 = base.NewVar();
                         int num22 = base.NewVar();
                         this.Gen(base.code.OP_EVAL_BASE_TYPE, class_id, 0, num22);
                         this.Gen(base.code.OP_ASSIGN_NAME, num21, num22, num21);
                         int num23 = base.NewVar();
                         this.Gen(base.code.OP_CAST, num22, base.CurrThisID, num23);
                         this.Gen(base.code.OP_CREATE_REFERENCE, num23, 0, num21);
                         base.DECLARE_SWITCH = false;
                         this.Match('(');
                         this.Gen(base.code.OP_CALL_BASE, num21, this.Parse_ArgumentList(")", num21, num23), 0);
                         base.DECLARE_SWITCH = true;
                         this.Match(')');
                     }
                     else if (base.IsCurrText("this"))
                     {
                         this.Match("this");
                         base.DECLARE_SWITCH = false;
                         this.Match('(');
                         this.Gen(base.code.OP_CALL, num18, this.Parse_ArgumentList(")", num18, base.CurrThisID), 0);
                         base.DECLARE_SWITCH = true;
                         this.Match(')');
                     }
                     else
                     {
                         base.RaiseError(true, "CS1018. Keyword this or base expected.");
                     }
                 }
                 else if (!flag)
                 {
                     int num24 = base.NewVar();
                     int num25 = base.NewVar();
                     this.Gen(base.code.OP_EVAL_BASE_TYPE, class_id, 0, num25);
                     this.Gen(base.code.OP_ASSIGN_NAME, num24, num25, num24);
                     int num26 = base.NewVar();
                     this.Gen(base.code.OP_CAST, num25, base.CurrThisID, num26);
                     this.Gen(base.code.OP_CREATE_REFERENCE, num26, 0, num24);
                     this.Gen(base.code.OP_BEGIN_CALL, num24, 0, 0);
                     this.Gen(base.code.OP_PUSH, num26, 0, 0);
                     this.Gen(base.code.OP_CALL, num24, 0, 0);
                 }
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.Parse_Block();
                 }
                 this.EndMethod(num18);
                 this.valid_this_context = false;
                 if (flag)
                 {
                     this.static_variable_initializers.Clear();
                 }
                 else
                 {
                     this.has_constructor = true;
                 }
                 goto Label_1519;
             }
             num27 = this.Parse_Type();
             num28 = 0;
             if (!(str3 == "."))
             {
                 goto Label_0CD9;
             }
             if (ml.HasModifier(Modifier.Public))
             {
                 base.RaiseErrorEx(false, "CS0106. The modifier '{0}' is not valid for this item.", new object[] { "public" });
             }
             ml.Add(Modifier.Public);
             num28 = this.Parse_Ident();
             this.Gen(base.code.OP_EVAL_TYPE, 0, 0, num28);
             while (true)
             {
                 base.REF_SWITCH = true;
                 if (!base.CondMatch('.'))
                 {
                     goto Label_0CD2;
                 }
                 int num29 = base.ReadToken();
                 string str8 = base.curr_token.Text;
                 base.Backup_SCANNER(num29);
                 if (str8 != ".")
                 {
                     goto Label_0CD2;
                 }
                 int num30 = num28;
                 num28 = this.Parse_Ident();
                 this.Gen(base.code.OP_CREATE_TYPE_REFERENCE, num30, 0, num28);
             }
         }
         this.Match("event");
         base.CheckModifiers(ml, this.method_modifiers);
         int num4 = this.Parse_Type();
         int id = this.Parse_Ident();
         if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
         {
             string str4 = base.GetName(id);
             base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str4, name });
         }
         if (base.IsCurrText('{'))
         {
             base.BeginEvent(id, ml, num4, 0);
             this.Gen(base.code.OP_ADD_MODIFIER, id, 1, 0);
             this.param_ids.Clear();
             this.param_type_ids.Clear();
             this.param_mods.Clear();
             this.Parse_EventAccessorDeclarations(id, num4, ml);
             base.EndEvent(id);
             goto Label_1519;
         }
     Label_0249:
         list2 = ml.Clone();
         list2.Delete(Modifier.Public);
         base.BeginField(id, list2, num4);
         string str5 = base.GetName(id);
         base.SetName(id, "__" + str5);
         if (base.IsCurrText('='))
         {
             this.Parse_InstanceVariableInitializer(id, num4, ml);
         }
         base.EndField(id);
         int num10 = base.NewVar();
         base.SetName(num10, str5);
         base.BeginEvent(num10, ml, num4, 0);
         this.Gen(base.code.OP_ADD_EVENT_FIELD, num10, id, 0);
         int num6 = base.NewVar();
         base.SetName(num6, "add_" + str5);
         this.BeginMethod(num6, MemberKind.Method, list2, 1);
         int num7 = base.NewVar();
         base.SetName(num7, "value");
         this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num7, num4, 0);
         this.InitMethod(num6);
         int num8 = base.NewVar();
         base.SetName(num8, base.GetName(id));
         int res = base.NewVar();
         this.Gen(base.code.OP_EVAL, 0, 0, num8);
         this.Gen(base.code.OP_PLUS, num8, num7, res);
         this.Gen(base.code.OP_ASSIGN, num8, res, num8);
         this.EndMethod(num6);
         this.Gen(base.code.OP_ADD_ADD_ACCESSOR, num10, num6, 0);
         num6 = base.NewVar();
         base.SetName(num6, "remove_" + str5);
         this.BeginMethod(num6, MemberKind.Method, list2, 1);
         num7 = base.NewVar();
         base.SetName(num7, "value");
         this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num7, num4, 0);
         this.InitMethod(num6);
         num8 = base.NewVar();
         base.SetName(num8, base.GetName(id));
         res = base.NewVar();
         this.Gen(base.code.OP_EVAL, 0, 0, num8);
         this.Gen(base.code.OP_MINUS, num8, num7, res);
         this.Gen(base.code.OP_ASSIGN, num8, res, num8);
         this.EndMethod(num6);
         this.Gen(base.code.OP_ADD_REMOVE_ACCESSOR, num10, num6, 0);
         base.EndEvent(num10);
         if (base.IsCurrText(','))
         {
             this.Call_SCANNER();
             id = this.Parse_Ident();
             goto Label_0249;
         }
         this.Match(';');
     }
     else
     {
         this.Match("const");
         base.CheckModifiers(ml, this.constant_modifiers);
         ml.Add(Modifier.Static);
         int num2 = this.Parse_Type();
         do
         {
             int num3 = this.Parse_Ident();
             if (flag)
             {
                 base.RaiseErrorEx(false, "CS0504. The constant '{0}' cannot be marked static.", new object[] { base.GetName(num3) });
             }
             if (!base.IsCurrText('='))
             {
                 base.RaiseError(true, "CS0145. A const field requires a value to be provided.");
             }
             base.BeginField(num3, ml, num2);
             base.DECLARE_SWITCH = false;
             this.Parse_InstanceVariableInitializer(num3, num2, ml);
             base.EndField(num3);
             base.DECLARE_SWITCH = true;
         }
         while (base.CondMatch(','));
         this.Match(';');
     }
     goto Label_1519;
     Label_0CD2:
     base.REF_SWITCH = false;
     Label_0CD9:
     if (base.IsCurrText("this"))
     {
         base.CheckModifiers(ml, this.method_modifiers);
         this.Match("this");
         int num31 = base.NewVar();
         base.SetName(num31, "Item");
         if (num27 == 1)
         {
             base.RaiseError(false, "CS0620. Indexers can't have void type.");
         }
         if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
         {
             string str9 = base.GetName(num31);
             base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str9, name });
         }
         this.Match('[');
         int num32 = this.Parse_FormalParameterList(num31, true);
         this.Match(']');
         this.valid_this_context = true;
         base.BeginProperty(num31, ml, num27, num32);
         this.Parse_PropertyAccessorDeclarations(num31, num27, ml);
         base.EndProperty(num31);
         this.valid_this_context = false;
     }
     else if (!base.IsCurrText("operator"))
     {
         int num39;
         if (base.IsCurrText('('))
         {
             base.RaiseError(true, "CS1520. Class, struct, or interface method must have a return type.");
         }
     Label_0F95:
         num39 = this.Parse_Ident();
         if (base.IsCurrText(';'))
         {
             if (num27 == 1)
             {
                 base.RaiseError(false, "CS0670. Field cannot have void type.");
             }
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             this.Add_InstanceVariableInitializer(num39, num27, ml);
             base.EndField(num39);
             this.Match(';');
         }
         else if (base.IsCurrText(','))
         {
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             base.EndField(num39);
             this.Match(',');
             do
             {
                 num39 = this.Parse_Ident();
                 base.BeginField(num39, ml, num27);
                 if (base.IsCurrText('='))
                 {
                     if (!ml.HasModifier(Modifier.Static) && (ck == ClassKind.Struct))
                     {
                         base.RaiseErrorEx(false, "CS0573. '{0}' : cannot have instance field initializers in structs.", new object[] { base.GetName(num39) });
                     }
                     this.Parse_InstanceVariableInitializer(num39, num27, ml);
                 }
                 else
                 {
                     this.Add_InstanceVariableInitializer(num39, num27, ml);
                 }
                 base.EndField(num39);
             }
             while (base.CondMatch(','));
             this.Match(';');
         }
         else if (base.IsCurrText('='))
         {
             if (num27 == 1)
             {
                 base.RaiseError(false, "CS0670. Field cannot have void type.");
             }
             if (!ml.HasModifier(Modifier.Static) && (ck == ClassKind.Struct))
             {
                 base.RaiseErrorEx(false, "CS0573. '{0}' : cannot have instance field initializers in structs.", new object[] { base.GetName(num39) });
             }
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             this.Parse_InstanceVariableInitializer(num39, num27, ml);
             base.EndField(num39);
             if (base.IsCurrText(','))
             {
                 this.Match(',');
                 goto Label_0F95;
             }
             this.Match(';');
         }
         else if (base.IsCurrText('('))
         {
             base.CheckModifiers(ml, this.method_modifiers);
             if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
             {
                 string str12 = base.GetName(num39);
                 base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str12, name });
             }
             if (flag && ((ml.HasModifier(Modifier.Abstract) || ml.HasModifier(Modifier.Virtual)) || ml.HasModifier(Modifier.Override)))
             {
                 base.RaiseErrorEx(false, "CS0112. A static member '{0}' cannot be marked as override, virtual or abstract.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Override) && (ml.HasModifier(Modifier.Virtual) || ml.HasModifier(Modifier.New)))
             {
                 base.RaiseErrorEx(false, "CS0113. A member '{0}' marked as override cannot be marked as new or virtual.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Extern) && ml.HasModifier(Modifier.Abstract))
             {
                 base.RaiseErrorEx(false, "CS0180. '{0}' cannot be both extern and abstract.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Sealed) && !ml.HasModifier(Modifier.Override))
             {
                 base.RaiseErrorEx(false, "CS0238. '{0}' cannot be sealed because it is not an override.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Abstract) && ml.HasModifier(Modifier.Virtual))
             {
                 base.RaiseErrorEx(false, "CS0503. The abstract method '{0}' cannot be marked virtual.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Virtual) && owner_ml.HasModifier(Modifier.Sealed))
             {
                 base.RaiseErrorEx(false, "CS0549. '{0}' is a new virtual member in sealed class '{1}'.", new object[] { base.GetName(num39) });
             }
             int num40 = num39;
             this.valid_this_context = true;
             this.BeginMethod(num40, MemberKind.Method, ml, num27);
             if (num28 > 0)
             {
                 this.Gen(base.code.OP_ADD_EXPLICIT_INTERFACE, num40, num28, 0);
             }
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 this.Parse_FormalParameterList(num40, false);
             }
             this.Match(')');
             if (base.IsCurrText(';'))
             {
                 if (!ml.HasModifier(Modifier.Extern) && !ml.HasModifier(Modifier.Abstract))
                 {
                     base.RaiseErrorEx(false, "CS0501. '{0}' must declare a body because it is not marked abstract or extern.", new object[] { base.GetName(num40) });
                 }
                 this.Match(';');
             }
             else
             {
                 if (ml.HasModifier(Modifier.Extern))
                 {
                     base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(num40) });
                 }
                 this.InitMethod(num40);
                 if (ml.HasModifier(Modifier.Abstract))
                 {
                     string str13 = base.GetName(num40);
                     base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { str13 });
                 }
                 if (base.GetName(num39) == "Main")
                 {
                     this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
                 }
                 this.Parse_MethodBlock();
                 if (base.GetName(num39) == "Main")
                 {
                     this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
                 }
             }
             this.EndMethod(num40);
             this.valid_this_context = false;
         }
         else if (base.IsCurrText('{'))
         {
             base.CheckModifiers(ml, this.method_modifiers);
             if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
             {
                 string str14 = base.GetName(num39);
                 base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str14, name });
             }
             this.valid_this_context = true;
             base.BeginProperty(num39, ml, num27, 0);
             this.param_ids.Clear();
             this.param_type_ids.Clear();
             this.param_mods.Clear();
             this.Parse_PropertyAccessorDeclarations(num39, num27, ml);
             base.EndProperty(num39);
             this.valid_this_context = false;
         }
         else
         {
             this.Parse_TypeDeclaration(ml);
         }
     }
     else
     {
         base.CheckModifiers(ml, this.operator_modifiers);
         this.Match("operator");
         if (num27 == 1)
         {
             base.RaiseError(false, "CS0590. User-defined operators cannot return void.");
         }
         if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
         {
             base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { base.curr_token.Text });
         }
         string s = base.curr_token.Text;
         this.Call_SCANNER();
         int num33 = base.NewVar();
         this.BeginMethod(num33, MemberKind.Method, ml, num27);
         this.Match('(');
         int num34 = this.Parse_FormalParameterList(num33, false);
         string str11 = "";
         switch (num34)
         {
             case 1:
             {
                 int index = this.overloadable_unary_operators.IndexOf(s);
                 if (index == -1)
                 {
                     base.RaiseError(true, "CS1019. Overloadable unary operator expected.");
                 }
                 int num36 = (int) this.overloadable_unary_operators.Objects[index];
                 str11 = (string) base.code.overloadable_unary_operators_str[num36];
                 break;
             }
             case 2:
             {
                 int num37 = this.overloadable_binary_operators.IndexOf(s);
                 if (num37 == -1)
                 {
                     base.RaiseError(true, "CS1020. Overloadable binary operator expected.");
                 }
                 int num38 = (int) this.overloadable_binary_operators.Objects[num37];
                 str11 = (string) base.code.overloadable_binary_operators_str[num38];
                 break;
             }
             default:
                 base.RaiseErrorEx(true, "CS1534. Overloaded binary operator '{0}' only takes two parameters.", new object[] { s });
                 break;
         }
         base.SetName(num33, str11);
         this.Match(')');
         if (base.IsCurrText(';'))
         {
             this.Match(';');
         }
         else
         {
             this.InitMethod(num33);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num33);
     }
     Label_1519:
     base.DECLARE_SWITCH = false;
 }
Beispiel #17
0
 private ModifierList Parse_Modifiers()
 {
     int num2;
     ModifierList list = new ModifierList();
     int num = 0;
     Label_000D:
     num2 = this.total_modifier_list.IndexOf(base.curr_token.Text);
     switch (base.curr_token.Text)
     {
         case "private":
         case "protected":
         case "public":
         case "internal":
             num++;
             break;
     }
     if (num2 >= 0)
     {
         Modifier m = (Modifier) this.total_modifier_list.Objects[num2];
         if (list.HasModifier(m))
         {
             string str2 = this.total_modifier_list[(int) m];
             base.RaiseErrorEx(false, "CS1004. Duplicate '{0}' modifier.", new object[] { str2 });
         }
         list.Add(m);
         this.Call_SCANNER();
         goto Label_000D;
     }
     if (num > 1)
     {
         base.RaiseError(false, "CS0107. More than one protection modifier.");
     }
     if (list.HasModifier(Modifier.Private) && (list.HasModifier(Modifier.Virtual) || list.HasModifier(Modifier.Abstract)))
     {
         base.RaiseError(false, "CS0621. Virtual or abstract members cannot be private.");
     }
     return list;
 }
Beispiel #18
0
 private void CheckMethodModifiers(int id, int class_id, ModifierList ml, ModifierList owner_ml)
 {
     base.CheckModifiers(ml, this.method_modifiers);
     if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
     {
         string name = base.GetName(id);
         string str2 = base.GetName(class_id);
         base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { name, str2 });
     }
     if (ml.HasModifier(Modifier.Static) && ((ml.HasModifier(Modifier.Abstract) || ml.HasModifier(Modifier.Virtual)) || ml.HasModifier(Modifier.Override)))
     {
         base.RaiseErrorEx(false, "CS0112. A static member '{0}' cannot be marked as override, virtual or abstract.", new object[] { base.GetName(id) });
     }
     if (ml.HasModifier(Modifier.Override) && (ml.HasModifier(Modifier.Virtual) || ml.HasModifier(Modifier.New)))
     {
         base.RaiseErrorEx(false, "CS0113. A member '{0}' marked as override cannot be marked as new or virtual.", new object[] { base.GetName(id) });
     }
     if (ml.HasModifier(Modifier.Extern) && ml.HasModifier(Modifier.Abstract))
     {
         base.RaiseErrorEx(false, "CS0180. '{0}' cannot be both extern and abstract.", new object[] { base.GetName(id) });
     }
     if (ml.HasModifier(Modifier.Sealed) && !ml.HasModifier(Modifier.Override))
     {
         base.RaiseErrorEx(false, "CS0238. '{0}' cannot be sealed because it is not an override.", new object[] { base.GetName(id) });
     }
     if (ml.HasModifier(Modifier.Abstract) && ml.HasModifier(Modifier.Virtual))
     {
         base.RaiseErrorEx(false, "CS0503. The abstract method '{0}' cannot be marked virtual.", new object[] { base.GetName(id) });
     }
     if (ml.HasModifier(Modifier.Virtual) && owner_ml.HasModifier(Modifier.Sealed))
     {
         base.RaiseErrorEx(false, "CS0549. '{0}' is a new virtual member in sealed class '{1}'.", new object[] { base.GetName(id) });
     }
 }
Beispiel #19
0
 private void Parse_StructDeclaration(ModifierList ml)
 {
     base.CheckModifiers(ml, this.structure_modifiers);
     this.Match("struct");
     int num = this.Parse_Ident();
     base.BeginStruct(num, ml);
     if (base.IsCurrText(':'))
     {
         this.Parse_ClassBase(num);
     }
     else
     {
         this.Gen(base.code.OP_ADD_ANCESTOR, num, base.ObjectClassId, 0);
     }
     this.Parse_StructBody(num, ml);
     if (this.static_variable_initializers.Count > 0)
     {
         this.CreateDefaultStaticConstructor(num);
     }
     this.CreateDefaultConstructor(num, true);
     base.EndStruct(num);
     if (base.IsCurrText(';'))
     {
         this.Match(';');
     }
 }
Beispiel #20
0
 private bool HasAccessModifier(ModifierList ml)
 {
     return ((ml.HasModifier(Modifier.Public) || ml.HasModifier(Modifier.Private)) || ml.HasModifier(Modifier.Protected));
 }
Beispiel #21
0
 private void Parse_TypeDeclaration(ModifierList ml)
 {
     if (base.IsCurrText("class"))
     {
         this.Parse_ClassDeclaration(ml);
     }
     else if (base.IsCurrText("struct"))
     {
         this.Parse_StructDeclaration(ml);
     }
     else if (base.IsCurrText("interface"))
     {
         this.Parse_InterfaceDeclaration(ml);
     }
     else if (base.IsCurrText("enum"))
     {
         this.Parse_EnumDeclaration(ml);
     }
     else if (base.IsCurrText("delegate"))
     {
         this.Parse_DelegateDeclaration(ml);
     }
     else if (base.scripter.SIGN_BRIEF_SYNTAX)
     {
         base.DECLARE_SWITCH = false;
         ml.Add(Modifier.Public);
         int id = base.NewVar();
         base.SetName(id, "__Main");
         base.BeginClass(id, ml);
         this.Gen(base.code.OP_ADD_ANCESTOR, id, base.ObjectClassId, 0);
         ml.Add(Modifier.Static);
         int num2 = base.NewVar();
         base.SetName(num2, "Main");
         this.BeginMethod(num2, MemberKind.Method, ml, 1);
         this.InitMethod(num2);
         base.MoveSeparator();
         this.Parse_StatementList();
         this.EndMethod(num2);
         base.EndClass(id);
     }
     else
     {
         this.Match("class");
     }
 }
Beispiel #22
0
 private void Parse_DelegateDeclaration(ModifierList ml)
 {
     base.CheckModifiers(ml, this.delegate_modifiers);
     base.DECLARE_SWITCH = true;
     this.Match("delegate");
     int num = this.Parse_Type();
     int num2 = this.Parse_Ident();
     base.BeginDelegate(num2, ml);
     this.Match('(');
     int num3 = base.NewVar();
     this.BeginMethod(num3, MemberKind.Method, ml, num);
     this.Gen(base.code.OP_ADD_PATTERN, num2, num3, 0);
     if (!base.IsCurrText(')'))
     {
         this.Parse_FormalParameterList(num3, false);
     }
     this.Match(')');
     this.InitMethod(num3);
     int num4 = base.NewVar();
     int res = base.NewVar();
     int resultId = base.GetResultId(num3);
     int thisId = base.GetThisId(num3);
     int num8 = base.NewLabel();
     int l = base.NewLabel();
     this.Gen(base.code.OP_FIND_FIRST_DELEGATE, thisId, num4, res);
     this.Gen(base.code.OP_GO_NULL, num8, num4, 0);
     for (int i = 0; i < this.param_ids.Count; i++)
     {
         this.Gen(base.code.OP_PUSH, this.param_ids[i], this.param_mods[i], num4);
     }
     this.Gen(base.code.OP_PUSH, res, 0, 0);
     this.Gen(base.code.OP_CALL_SIMPLE, num4, this.param_ids.Count, resultId);
     base.SetLabelHere(l);
     this.Gen(base.code.OP_FIND_NEXT_DELEGATE, thisId, num4, res);
     this.Gen(base.code.OP_GO_NULL, num8, num4, 0);
     for (int j = 0; j < this.param_ids.Count; j++)
     {
         this.Gen(base.code.OP_PUSH, this.param_ids[j], this.param_mods[j], num4);
     }
     this.Gen(base.code.OP_PUSH, res, 0, 0);
     this.Gen(base.code.OP_CALL_SIMPLE, num4, this.param_ids.Count, resultId);
     this.Gen(base.code.OP_GO, l, 0, 0);
     base.SetLabelHere(num8);
     this.EndMethod(num3);
     base.EndDelegate(num2);
     base.DECLARE_SWITCH = false;
     this.Match(';');
 }
Beispiel #23
0
 private void CreateDefaultConstructor(int class_id, bool is_struct)
 {
     ModifierList ml = new ModifierList();
     ml.Add(Modifier.Public);
     int id = base.NewVar();
     base.SetName(id, base.GetName(class_id));
     this.BeginMethod(id, MemberKind.Constructor, ml, 1);
     this.InitMethod(id);
     for (int i = 0; i < this.variable_initializers.Count; i++)
     {
         int num3 = this.variable_initializers[i];
         this.Gen(base.code.OP_BEGIN_CALL, num3, 0, 0);
         this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
         this.Gen(base.code.OP_CALL, num3, 0, 0);
     }
     if (!is_struct)
     {
         int num4 = base.NewVar();
         int res = base.NewVar();
         this.Gen(base.code.OP_EVAL_BASE_TYPE, class_id, num4, res);
         int num6 = base.NewVar();
         this.Gen(base.code.OP_CAST, res, base.CurrThisID, num6);
         this.Gen(base.code.OP_BEGIN_CALL, num4, 0, 0);
         this.Gen(base.code.OP_PUSH, num6, 0, 0);
         this.Gen(base.code.OP_CALL, num4, 0, 0);
     }
     this.EndMethod(id);
 }
Beispiel #24
0
 private void Parse_EnumDeclaration(ModifierList ml)
 {
     base.CheckModifiers(ml, this.enum_modifiers);
     ml.Add(Modifier.Static);
     base.DECLARE_SWITCH = true;
     this.Match("enum");
     int num = this.Parse_Ident();
     int num2 = 8;
     if (base.IsCurrText(':'))
     {
         this.Match(':');
         num2 = this.Parse_IntegralType();
         if (num2 == 4)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
     }
     base.BeginEnum(num, ml, num2);
     this.Gen(base.code.OP_ADD_UNDERLYING_TYPE, num, num2, 0);
     this.Match('{');
     if (!base.IsCurrText('}'))
     {
         int v = -1;
         this.static_variable_initializers.Clear();
         do
         {
             int num6;
             if (base.IsCurrText('}'))
             {
                 break;
             }
             if (base.IsCurrText('['))
             {
                 this.Parse_Attributes();
             }
             int num4 = this.Parse_Ident();
             base.BeginField(num4, ml, num);
             int num5 = base.NewVar();
             this.BeginMethod(num5, MemberKind.Method, ml, 1);
             this.InitMethod(num5);
             this.static_variable_initializers.Add(num5);
             if (base.IsCurrText('='))
             {
                 base.DECLARE_SWITCH = false;
                 this.Match('=');
                 num6 = this.Parse_ConstantExpression();
                 base.DECLARE_SWITCH = true;
                 object val = base.GetVal(num6);
                 if (val != null)
                 {
                     v = (int) val;
                 }
                 this.Gen(base.code.OP_ASSIGN, num4, num6, num4);
                 base.SetTypeId(num6, num2);
             }
             else
             {
                 v++;
                 num6 = base.NewConst(v);
                 this.Gen(base.code.OP_ASSIGN, num4, num6, num4);
                 base.SetTypeId(num6, num2);
             }
             this.EndMethod(num5);
             base.EndField(num4);
         }
         while (base.CondMatch(','));
         this.CreateDefaultStaticConstructor(num);
     }
     base.DECLARE_SWITCH = false;
     base.EndEnum(num);
     this.Match('}');
     if (base.IsCurrText(';'))
     {
         this.Match(';');
     }
 }
Beispiel #25
0
 private bool HasAccessModifier(ModifierList ml)
 {
     return ml.HasModifier(Modifier.Public);
 }
Beispiel #26
0
 private void Parse_EventAccessorDeclarations(int id, int type_id, ModifierList ml)
 {
     this.ACCESSOR_SWITCH = true;
     this.Match('{');
     int num = 0;
     int num2 = 0;
     Label_0018:
     if (base.IsCurrText('['))
     {
         this.Parse_Attributes();
     }
     if (base.IsCurrText("add"))
     {
         int num3 = base.NewVar();
         base.SetName(num3, "add_" + base.GetName(id));
         this.BeginMethod(num3, MemberKind.Method, ml, type_id);
         num++;
         if (num > 1)
         {
             base.RaiseError(true, "CS1007. Property accessor already defined.");
         }
         this.Match("add");
         int num4 = base.NewVar();
         base.SetName(num4, "value");
         this.Gen(base.code.OP_ADD_PARAM, num3, num4, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num4, type_id, 0);
         if (base.IsCurrText(';'))
         {
             this.Match(';');
         }
         else
         {
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num3);
                 base.RaiseErrorEx(true, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             this.InitMethod(num3);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num3);
         this.Gen(base.code.OP_ADD_ADD_ACCESSOR, id, num3, 0);
         goto Label_0018;
     }
     if (base.IsCurrText("remove"))
     {
         int num5 = base.NewVar();
         base.SetName(num5, "remove_" + base.GetName(id));
         this.BeginMethod(num5, MemberKind.Method, ml, 1);
         num2++;
         if (num2 > 1)
         {
             base.RaiseError(true, "CS1007. Property accessor already defined.");
         }
         this.Match("remove");
         int num6 = base.NewVar();
         base.SetName(num6, "value");
         this.Gen(base.code.OP_ADD_PARAM, num5, num6, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num6, type_id, 0);
         if (base.IsCurrText(';'))
         {
             this.Match(';');
         }
         else
         {
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string str2 = base.GetName(num5);
                 base.RaiseErrorEx(true, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { str2 });
             }
             this.InitMethod(num5);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num5);
         this.Gen(base.code.OP_ADD_REMOVE_ACCESSOR, id, num5, 0);
         goto Label_0018;
     }
     if ((num == 0) && (num2 == 0))
     {
         base.RaiseError(true, "CS1055. An add or remove accessor expected.");
     }
     if ((num == 0) || (num2 == 0))
     {
         base.RaiseErrorEx(true, "CS0065. '{0}' : event property must have both add and remove accessors.", new object[] { base.GetName(id) });
     }
     this.Match('}');
     this.ACCESSOR_SWITCH = true;
 }
Beispiel #27
0
 private void Parse_ClassBody(int class_id, ModifierList owner_modifiers)
 {
     this.variable_initializers.Clear();
     this.static_variable_initializers.Clear();
     this.Match('{');
     while (true)
     {
         if (base.IsCurrText('}'))
         {
             break;
         }
         this.Parse_ClassMemberDeclaration(class_id, owner_modifiers);
     }
     this.Match('}');
 }
Beispiel #28
0
 private void Parse_InstanceVariableInitializer(int id, int type_id, ModifierList ml)
 {
     base.DECLARE_SWITCH = false;
     this.Match('=');
     int num = base.NewVar();
     this.BeginMethod(num, MemberKind.Method, ml, 1);
     this.InitMethod(num);
     int num2 = id;
     if (!ml.HasModifier(Modifier.Static))
     {
         num2 = base.NewVar();
         base.SetName(num2, base.GetName(id));
         this.Gen(base.code.OP_EVAL, 0, 0, num2);
         this.variable_initializers.Add(num);
     }
     else
     {
         this.static_variable_initializers.Add(num);
     }
     if (base.IsCurrText('{'))
     {
         this.Gen(base.code.OP_ASSIGN, num2, this.Parse_ArrayInitializer(type_id), num2);
     }
     else
     {
         this.Gen(base.code.OP_ASSIGN, num2, this.Parse_Expression(), num2);
     }
     this.EndMethod(num);
     base.DECLARE_SWITCH = true;
 }
Beispiel #29
0
 private void Parse_ClassMemberDeclaration(int class_id, ModifierList owner_modifiers)
 {
     this.Parse_MemberDeclaration(class_id, ClassKind.Class, owner_modifiers);
 }
Beispiel #30
0
 private void Parse_InterfaceDeclaration(ModifierList ml)
 {
     base.CheckModifiers(ml, this.interface_modifiers);
     base.DECLARE_SWITCH = true;
     this.Match("interface");
     int num = this.Parse_Ident();
     base.BeginInterface(num, ml);
     if (base.IsCurrText(':'))
     {
         this.Parse_ClassBase(num);
     }
     this.Match('{');
     while (!base.IsCurrText('}'))
     {
         if (base.IsCurrText('['))
         {
             this.Parse_Attributes();
         }
         ModifierList list = new ModifierList();
         if (base.IsCurrText("new"))
         {
             this.Match("new");
             list.Add(Modifier.New);
         }
         list.Add(Modifier.Abstract);
         if (base.IsCurrText("event"))
         {
             this.Match("event");
             int num2 = this.Parse_Type();
             int num3 = this.Parse_Ident();
             base.BeginEvent(num3, list, num2, 0);
             base.EndEvent(num3);
             if (base.IsCurrText('='))
             {
                 base.RaiseErrorEx(true, "CS0068. '{0}': event in interface cannot have initializer.", new object[] { base.GetName(num3) });
             }
             if (base.IsCurrText('{'))
             {
                 base.RaiseErrorEx(true, "CS0069. '{0}': event in interface cannot have add or remove accessors.", new object[] { base.GetName(num3) });
             }
             this.Match(';');
         }
         else if ((base.IsCurrText("class") || base.IsCurrText("struct")) || (base.IsCurrText("enum") || base.IsCurrText("delegate")))
         {
             base.RaiseErrorEx(true, "CS0524. '{0}' : interfaces cannot declare types.", new object[] { base.GetName(num) });
         }
         else
         {
             int id = this.Parse_Type();
             if ((base.GetName(id) == base.GetName(num)) && base.IsCurrText('('))
             {
                 base.RaiseError(true, "CS0526. Interfaces cannot contain constructors.");
             }
             if (base.IsCurrText('('))
             {
                 base.RaiseError(true, "CS1520. Class, struct, or interface method must have a return type.");
             }
             else if (base.IsCurrText("this"))
             {
                 if (id == 1)
                 {
                     base.RaiseError(false, "CS0620. Indexers can't have void type.");
                 }
                 base.CheckModifiers(list, this.method_modifiers);
                 this.Match("this");
                 int num5 = base.NewVar();
                 base.SetName(num5, "Item");
                 this.Match('[');
                 int num6 = this.Parse_FormalParameterList(num5, true);
                 this.Match(']');
                 this.valid_this_context = true;
                 base.BeginProperty(num5, list, id, num6);
                 this.Gen(base.code.OP_ADD_MODIFIER, num5, 1, 0);
                 this.Parse_PropertyAccessorDeclarations(num5, id, list);
                 base.EndProperty(num5);
                 this.valid_this_context = false;
             }
             else if (base.IsCurrText("operator"))
             {
                 base.RaiseError(true, "CS0567. Interfaces cannot contain operators.");
             }
             else
             {
                 int num7 = this.Parse_Ident();
                 if (base.IsCurrText('('))
                 {
                     int num8 = num7;
                     this.BeginMethod(num8, MemberKind.Method, list, id);
                     this.Gen(base.code.OP_ADD_MODIFIER, num8, 1, 0);
                     this.Match('(');
                     if (!base.IsCurrText(')'))
                     {
                         this.Parse_FormalParameterList(num8, false);
                     }
                     this.Match(')');
                     this.EndMethod(num8);
                     if (base.IsCurrText('{'))
                     {
                         base.RaiseErrorEx(true, "CS0531. '{0}' : interface members cannot have a definition.", new object[] { base.GetName(num8) });
                     }
                     this.Match(';');
                 }
                 else if (base.IsCurrText('{'))
                 {
                     this.valid_this_context = true;
                     base.BeginProperty(num7, list, id, 0);
                     this.Gen(base.code.OP_ADD_MODIFIER, num7, 1, 0);
                     this.param_ids.Clear();
                     this.param_type_ids.Clear();
                     this.param_mods.Clear();
                     this.Parse_PropertyAccessorDeclarations(num7, id, list);
                     base.EndProperty(num7);
                     this.valid_this_context = false;
                 }
                 else if (base.IsCurrText('=') || base.IsCurrText(';'))
                 {
                     base.RaiseError(true, "CS0525. Interfaces cannot contain fields.");
                 }
                 else
                 {
                     this.Match('(');
                 }
             }
         }
     }
     base.DECLARE_SWITCH = false;
     base.EndInterface(num);
     this.Match('}');
     if (base.IsCurrText(';'))
     {
         this.Match(';');
     }
 }