public ModifierList Clone() { ModifierList list = new ModifierList(); for (int i = 0; i < this.Count; i++) { list.Add(this[i]); } return list; }
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 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); }
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"); } }
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; }
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(';'); } }
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(';'); } }
private void Parse_InterfaceDeclaration(ModifierList ml) { base.CheckModifiers(ml, this.interface_modifiers); ml.Add(Modifier.Abstract); base.DECLARE_SWITCH = true; this.Match("Interface"); int num = this.Parse_Ident(); this.MatchLineTerminator(); base.BeginInterface(num, ml); if (base.IsCurrText("Inherits")) { this.Parse_ClassBase(num); } while (!base.IsCurrText("End")) { if (base.IsEOF()) { this.Match("End"); } this.Parse_InterfaceMember(num, ml); } base.DECLARE_SWITCH = false; base.EndInterface(num); this.Match("End"); this.Match("Interface"); this.MatchLineTerminator(); }
private void Parse_TypeDeclaration(int class_id, ModifierList owner_modifiers) { bool flag; ModifierList ml = new ModifierList(); ml.Add(Modifier.Public); base.DECLARE_SWITCH = true; this.Match("type"); do { flag = false; int num = this.Parse_Ident(); base.DECLARE_SWITCH = false; this.Match('='); if (base.IsCurrText('(')) { base.DECLARE_SWITCH = true; this.Parse_EnumTypeDeclaration(num); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.curr_token.tokenClass == TokenClass.IntegerConst) { this.Parse_SubrangeTypeDeclaration(num, StandardType.Int); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.curr_token.tokenClass == TokenClass.CharacterConst) { this.Parse_SubrangeTypeDeclaration(num, StandardType.Char); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.curr_token.tokenClass == TokenClass.BooleanConst) { this.Parse_SubrangeTypeDeclaration(num, StandardType.Bool); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.IsCurrText("class")) { base.DECLARE_SWITCH = true; this.Parse_ClassTypeDeclaration(num, ml); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.IsCurrText("record")) { base.DECLARE_SWITCH = true; this.Parse_RecordTypeDeclaration(num, ml); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } else if (base.IsCurrText("array")) { base.DECLARE_SWITCH = true; this.Parse_ArrayTypeDeclaration(num, ml); base.DECLARE_SWITCH = true; this.Match(';'); flag = true; } } while (flag && (base.curr_token.tokenClass != TokenClass.Keyword)); }
private void Parse_ClassMemberDeclaration(int class_id, ModifierList owner_modifiers, bool IsModule, ClassKind ck) { this.Parse_Attributes(); ModifierList ml = new ModifierList(); ml.Add(Modifier.Public); if (base.IsCurrText("private")) { this.Call_SCANNER(); } else if (base.IsCurrText("protected")) { this.Call_SCANNER(); } if (base.IsCurrText("public")) { this.Call_SCANNER(); } if (owner_modifiers.HasModifier(Modifier.Public) && !ml.HasModifier(Modifier.Private)) { ml.Add(Modifier.Public); } if (base.IsCurrText("type")) { this.Parse_TypeDeclaration(class_id, owner_modifiers); } else if (base.IsCurrText("var")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers, IsModule); } else if (base.IsCurrText("const")) { ml.Add(Modifier.Static); this.Parse_ConstantMemberDeclaration(class_id, ml, owner_modifiers, IsModule); } else if (base.IsCurrText("constructor")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck); } else if (base.IsCurrText("destructor")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck); } else if (base.IsCurrText("procedure")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck); } else if (base.IsCurrText("function")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck); } else if (base.IsCurrText("property")) { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_PropertyMemberDeclaration(class_id, ml, owner_modifiers, ck); } else { if (IsModule) { ml.Add(Modifier.Static); } this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers, IsModule); } }
private void Parse_ProgramDeclaration(ModifierList ml) { this.Match("program"); base.DECLARE_SWITCH = true; this.has_constructor = false; base.CheckModifiers(ml, this.class_modifiers); int num = this.Parse_Ident(); this.Match(";"); while (base.IsCurrText("Uses")) { this.Parse_UsesStatement(); } base.BeginClass(num, ml); this.Gen(base.code.OP_ADD_ANCESTOR, num, base.ObjectClassId, 0); this.Parse_ClassBody(num, ml, true); if (this.static_variable_initializers.Count > 0) { this.CreateDefaultStaticConstructor(num); } ml.Add(Modifier.Static); int id = base.NewVar(); base.SetName(id, "Main"); this.BeginMethod(id, MemberKind.Method, ml, 1); this.InitMethod(id); base.MoveSeparator(); this.Gen(base.code.OP_INSERT_STRUCT_CONSTRUCTORS, num, 0, 0); this.Parse_CompoundStatement(); this.EndMethod(id); base.EndClass(num); this.Match("."); }
private void Parse_NonProgramDeclaration(ModifierList ml) { 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_Statements(); this.EndMethod(num2); base.EndClass(id); } }
private void Parse_InterfaceSection(int namespace_id) { bool flag; ModifierList ml = new ModifierList(); ml.Add(Modifier.Static); ModifierList list2 = new ModifierList(); this.Match("interface"); while (base.IsCurrText("Uses")) { this.Parse_UsesStatement(); } base.BeginClass(namespace_id, ml); this.Gen(base.code.OP_ADD_ANCESTOR, namespace_id, base.ObjectClassId, 0); do { flag = false; if (base.IsCurrText("var")) { this.Parse_VariableMemberDeclaration(namespace_id, ml, list2, true); flag = true; } else if (base.IsCurrText("const")) { this.Parse_ConstantMemberDeclaration(namespace_id, ml, list2, true); flag = true; } else if (base.IsCurrText("procedure")) { this.Parse_ProcedureHeading(namespace_id, ml, list2, ClassKind.Class); flag = true; } else if (base.IsCurrText("function")) { this.Parse_FunctionHeading(namespace_id, ml, list2, ClassKind.Class); flag = true; } else if (base.IsCurrText("type")) { this.Parse_TypeDeclaration(namespace_id, list2); flag = true; } } while (flag); }
private void Parse_ImplementationSection(int namespace_id) { bool flag; this.Match("implementation"); while (base.IsCurrText("Uses")) { this.Parse_UsesStatement(); } ModifierList ml = new ModifierList(); ml.Add(Modifier.Static); ModifierList list2 = new ModifierList(); do { flag = false; if (base.IsCurrText("var")) { this.Parse_VariableMemberDeclaration(namespace_id, ml, list2, true); flag = true; } else if (base.IsCurrText("const")) { this.Parse_ConstantMemberDeclaration(namespace_id, ml, list2, true); flag = true; } else if (base.IsCurrText("procedure")) { this.Parse_ProcedureDeclaration(namespace_id, ml, list2, ClassKind.Class); flag = true; } else if (base.IsCurrText("function")) { this.Parse_FunctionDeclaration(namespace_id, ml, list2, ClassKind.Class); flag = true; } else if (base.IsCurrText("type")) { this.Parse_TypeDeclaration(namespace_id, list2); flag = true; } } while (flag); }
private void Parse_EnumTypeDeclaration(int enum_id) { int currLevel = base.CurrLevel; int id = base.NewVar(); ModifierList ml = new ModifierList(); ml.Add(Modifier.Public); ml.Add(Modifier.Static); base.DECLARE_SWITCH = true; int num3 = 8; base.BeginEnum(enum_id, ml, num3); this.Gen(base.code.OP_ADD_UNDERLYING_TYPE, enum_id, num3, 0); int v = -1; this.static_variable_initializers.Clear(); this.Match("("); do { int num7; if (base.IsEOF()) { this.Match(")"); } int num5 = this.Parse_Ident(); base.SetName(id, base.GetName(num5)); base.BeginField(num5, ml, enum_id); int num6 = base.NewVar(); this.BeginMethod(num6, MemberKind.Method, ml, 1); this.InitMethod(num6); this.static_variable_initializers.Add(num6); if (base.IsCurrText('=')) { base.DECLARE_SWITCH = false; this.Match('='); num7 = this.Parse_ConstantExpression(); base.DECLARE_SWITCH = true; object val = base.GetVal(num7); if (val != null) { v = (int) val; } this.Gen(base.code.OP_ASSIGN, num5, num7, num5); base.SetTypeId(num7, num3); this.Gen(base.code.OP_ASSIGN, id, num7, id); } else { v++; num7 = base.NewConst(v); this.Gen(base.code.OP_ASSIGN, num5, num7, num5); base.SetTypeId(num7, num3); this.Gen(base.code.OP_ASSIGN, id, num7, id); } this.EndMethod(num6); base.EndField(num5); base.EndField(id); base.DECLARE_SWITCH = true; } while (!this.NotMatch(",")); this.CreateDefaultStaticConstructor(enum_id); base.DECLARE_SWITCH = true; base.EndEnum(enum_id); this.Match(")"); }