private void FindApplicableConstructorList(IntegerList a, IntegerList param_mod, ref FunctionObject best, ref IntegerList applicable_list) { for (int i = 0; i < base.Members.Count; i++) { MemberObject obj2 = base.Members[i]; if ((obj2.Kind == MemberKind.Constructor) && !obj2.HasModifier(Modifier.Static)) { FunctionObject f = (FunctionObject)obj2; this.AddApplicableMethod(f, a, param_mod, 0, ref best, ref applicable_list); } } ClassObject ancestorClass = this.AncestorClass; if (!base.Imported) { if ((ancestorClass != null) && (best == null)) { ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list); } } else { IntegerList list = new IntegerList(false); foreach (ConstructorInfo info in this.ImportedType.GetConstructors()) { list.Add(base.Scripter.symbol_table.RegisterConstructor(info, base.Id)); } if (base.Scripter.SearchProtected) { foreach (ConstructorInfo info2 in this.ImportedType.GetConstructors(base.Scripter.protected_binding_flags)) { list.Add(base.Scripter.symbol_table.RegisterConstructor(info2, base.Id)); } } for (int j = 0; j < list.Count; j++) { FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]); this.AddApplicableMethod(functionObject, a, param_mod, 0, ref best, ref applicable_list); } if ((ancestorClass != null) && (best == null)) { ancestorClass.FindApplicableConstructorList(a, param_mod, ref best, ref applicable_list); } } }
private void FindApplicableMethodList(int name_index, IntegerList a, IntegerList param_mod, int res_id, ref FunctionObject best, ref IntegerList applicable_list, bool upcase) { string upcaseNameByNameIndex = base.Scripter.GetUpcaseNameByNameIndex(name_index); for (int i = 0; i < base.Members.Count; i++) { MemberObject obj2 = base.Members[i]; if (obj2.Kind == MemberKind.Method) { bool flag; if (upcase) { flag = upcaseNameByNameIndex == obj2.UpcaseName; } else { flag = obj2.NameIndex == name_index; } if (flag) { FunctionObject f = (FunctionObject)obj2; this.AddApplicableMethod(f, a, param_mod, res_id, ref best, ref applicable_list); } } } ClassObject ancestorClass = this.AncestorClass; if (!base.Imported) { if (ancestorClass != null) { ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase); } } else { string str2 = base.Scripter.names[name_index]; IntegerList list = new IntegerList(false); foreach (MethodInfo info in this.ImportedType.GetMethods()) { if (str2 == info.Name) { bool flag2 = true; foreach (Attribute attribute in Attribute.GetCustomAttributes(info)) { if (attribute is CSLite_ScriptForbid) { flag2 = false; } } if (flag2) { int avalue = base.Scripter.symbol_table.RegisterMethod(info, base.Id); list.Add(avalue); } } } if (base.Scripter.SearchProtected) { foreach (MethodInfo info2 in this.ImportedType.GetMethods(base.Scripter.protected_binding_flags)) { if (str2 == info2.Name) { bool flag3 = true; foreach (Attribute attribute2 in Attribute.GetCustomAttributes(info2)) { if (attribute2 is CSLite_ScriptForbid) { flag3 = false; } } if (flag3) { int num3 = base.Scripter.symbol_table.RegisterMethod(info2, base.Id); list.Add(num3); } } } } for (int j = 0; j < list.Count; j++) { FunctionObject functionObject = base.Scripter.GetFunctionObject(list[j]); this.AddApplicableMethod(functionObject, a, param_mod, res_id, ref best, ref applicable_list); } if (ancestorClass != null) { ancestorClass.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase); } for (int k = 0; k < this.AncestorIds.Count; k++) { ClassObject classObject = base.Scripter.GetClassObject(this.AncestorIds[k]); if (classObject.IsInterface) { classObject.FindApplicableMethodList(name_index, a, param_mod, res_id, ref best, ref applicable_list, upcase); } } } }
internal int FindOverloadableUnaryOperatorId(string operator_name, int arg1) { if (base.Id > 0x10) { IntegerList list = new IntegerList(false); FunctionObject best = null; IntegerList a = new IntegerList(true); a.Add(arg1); IntegerList list3 = new IntegerList(true); list3.Add(0); int num = base.Scripter.names.Add(operator_name); this.FindApplicableMethodList(num, a, list3, 0, ref best, ref list, false); this.CompressApplicableMethodList(a, list); if (list.Count >= 1) { return list[0]; } } return 0; }
internal IntegerList GetSupportedInterfaceListIds() { IntegerList list = new IntegerList(false); for (int i = 0; i < this.AncestorIds.Count; i++) { int id = this.AncestorIds[i]; ClassObject val = (ClassObject)base.Scripter.GetVal(id); if (val.Class_Kind == ClassKind.Interface) { list.Add(id); IntegerList supportedInterfaceListIds = val.GetSupportedInterfaceListIds(); list.AddFrom(supportedInterfaceListIds); } } return list; }
private int Parse_MultiArrayInitializer(int array_type_id) { string name = base.GetName(array_type_id); int rank = CSLite_System.GetRank(name); string elementTypeName = CSLite_System.GetElementTypeName(name); int id = base.NewVar(); base.SetName(id, elementTypeName); this.Gen(base.code.OP_EVAL_TYPE, 0, 0, id); int res = base.NewVar(); this.Gen(base.code.OP_CREATE_OBJECT, array_type_id, 0, res); this.Gen(base.code.OP_BEGIN_CALL, array_type_id, 0, 0); IntegerList list = new IntegerList(true); IntegerList list2 = new IntegerList(true); IntegerList list3 = new IntegerList(true); IntegerList list4 = new IntegerList(true); for (int i = 0; i < rank; i++) { int avalue = base.NewVar(-1); list.Add(avalue); list2.Add(-1); list3.Add(-1); list4.Add(0); this.Gen(base.code.OP_PUSH, avalue, 0, array_type_id); } this.Gen(base.code.OP_PUSH, res, 0, 0); this.Gen(base.code.OP_CALL, array_type_id, rank, 0); int num6 = -1; Label_0113: if (base.IsCurrText('{')) { IntegerList list8=null; int num16; this.Match('{'); num6++; if (num6 == (rank - 1)) { list3[num6] = -1; while (true) { IntegerList list6=null; int num14; if (base.IsCurrText('}')) { goto Label_0113; } if (list4[num6] == 0) { IntegerList list5=list2; int num13=num6; //(list5 = list2)[num13 = num6] = list5[num13] + 1; list5[num13 ] = list5[num13] + 1; } list6 = list3; num14 = num6; //(list6 = list3)[num14 = num6] = list6[num14] + 1; list6[num14] = list6[num14] + 1; int num7 = base.NewVar(); this.Gen(base.code.OP_CREATE_INDEX_OBJECT, res, 0, num7); for (int j = 0; j < rank; j++) { int num9 = base.NewConst(list3[j]); this.Gen(base.code.OP_ADD_INDEX, num7, num9, res); } this.Gen(base.code.OP_SETUP_INDEX_OBJECT, num7, 0, 0); this.Gen(base.code.OP_ASSIGN, num7, this.Parse_Expression(), num7); if (!base.CondMatch(',')) { goto Label_0113; } } } if (list4[num6] == 0) { IntegerList list7=list2; int num15=num6; //(list7 = list2)[num15 = num6] = list7[num15] + 1; list7[num15] = list7[num15] + 1; } list8 = list3; num16 = num6; //(list8 = list3)[num16 = num6] = list8[num16] + 1; list8[num16] = list8[num16] + 1; } else if (base.IsCurrText(',')) { IntegerList list10=null; int num18; this.Match(','); if (list4[num6] == 0) { IntegerList list9= list2; int num17= num6; //(list9 = list2)[num17 = num6] = list9[num17] + 1; list9[num17]=list9[num17] + 1; } list10 = list3; num18 = num6; //(list10 = list3)[num18 = num6] = list10[num18] + 1; list10[num18] = list10[num18] + 1; for (int k = num6 + 1; k < rank; k++) { list3[k] = -1; } } else if (base.IsCurrText('}')) { IntegerList list11=null; int num19; this.Match('}'); if (list2[num6] != list3[num6]) { base.RaiseError(true, "CS0178. Incorrectly structured array initializer."); } list4[num6] = 1; list11 = list3; num19 = num6; //(list11 = list3)[num19 = num6] = list11[num19] - 1; list11[num19]=list11[num19] - 1; num6--; if (num6 == -1) { for (int m = 0; m < rank; m++) { base.PutVal(list[m], list2[m] + 1); } return res; } } else { this.Match('{'); } goto Label_0113; }
public void CheckTypesEx(int init_n, int init_level, IntegerStack init_class_stack) { ClassObject classObject; IntegerStack stack; FunctionObject obj9; int num52; if (this.scripter.IsError()) { return; } IntegerList a = new IntegerList(true); IntegerList list2 = new IntegerList(true); IntegerList pos = new IntegerList(true); IntegerList list4 = new IntegerList(false); IntegerList l = new IntegerList(false); ClassObject obj2 = null; if (init_class_stack == null) { stack = new IntegerStack(); } else { stack = init_class_stack.Clone(); } if (stack.Count == 0) { classObject = null; } else { classObject = this.GetClassObject(stack.Peek()); } this.n = init_n; int num = init_level; Label_0079: this.n++; if (this.n >= this.Card) { goto Label_22C6; } this.r = (ProgRec) this.prog[this.n]; int op = this.r.op; if ((op == this.OP_SEPARATOR) || (op == this.OP_LABEL)) { goto Label_0079; } if (op != this.OP_CREATE_INDEX_OBJECT) { if (op == this.OP_ADD_INDEX) { if (((this.symbol_table[this.r.res].TypeId != 12) || (this[this.n + 1].op != this.OP_ADD_INDEX)) || (this[this.n + 1].res != this.r.res)) { goto Label_04A6; } int num7 = 1; while ((this[this.n + num7].op == this.OP_ADD_INDEX) && (this[this.n + num7].res == this.r.res)) { num7++; } this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { "this", num7 }); goto Label_22C6; } if (op == this.OP_SETUP_INDEX_OBJECT) { int n = this.n; int num9 = 0; do { n--; if ((this[n].op == this.OP_ADD_INDEX) && (this[n].arg1 == this.r.arg1)) { num9++; } } while ((this[n].op != this.OP_CREATE_INDEX_OBJECT) || (this[n].res != this.r.arg1)); int typeId = this.symbol_table[this[n].arg1].TypeId; int rank = CSLite_System.GetRank(this.symbol_table[typeId].Name); if ((rank > 0) && (rank != num9)) { this.scripter.CreateErrorObjectEx("CS0022. Wrong number of indices inside [], expected '{0}'.", new object[] { rank.ToString() }); goto Label_22C6; } } } else { int num3 = this.symbol_table[this.r.arg1].TypeId; string name = this.symbol_table[num3].Name; string elementTypeName = CSLite_System.GetElementTypeName(name); int num4 = 0; PropertyObject obj4 = null; if (elementTypeName == "") { ClassObject obj5 = this.GetClassObject(num3); if (obj5.IsPascalArray) { name = obj5.ImportedType.Name + "[]"; elementTypeName = this.symbol_table[obj5.IndexTypeId].Name; } } if (elementTypeName == "") { obj4 = this.GetClassObject(num3).FindIndexer(); if (obj4 == null) { this.scripter.CreateErrorObjectEx("CS0021. Cannot apply indexing with [] to an expression of type '{0}'.", new object[] { name }); goto Label_22C6; } num4 = this.symbol_table[obj4.Id].TypeId; } else { for (int k = num3; k >= 0; k--) { if ((this.symbol_table[k].Kind == MemberKind.Type) && (this.symbol_table[k].Name == elementTypeName)) { num4 = k; break; } } } if (num4 == 0) { elementTypeName = CSLite_System.GetElementTypeName(this.symbol_table[num3].FullName); bool upcase = this.GetUpcase(); MemberObject obj6 = this.FindType(this.RecreateLevelStack(this.n), elementTypeName, upcase); if (obj6 == null) { this.scripter.CreateErrorObjectEx("CS0246. The type or namespace name '{0}' could not be found (are you missing a using directive or an assembly reference?).", new object[] { elementTypeName }); goto Label_22C6; } num4 = obj6.Id; } this.symbol_table[this.r.res].TypeId = num4; } Label_04A6: if (((op == this.OP_CREATE_INDEX_OBJECT) || (op == this.OP_ADD_INDEX)) || (op == this.OP_SETUP_INDEX_OBJECT)) { goto Label_0079; } for (int i = 1; i <= 2; i++) { int num13; if (i == 1) { num13 = this.r.arg1; } else { num13 = this.r.arg2; } if (this.symbol_table[num13].Kind == MemberKind.Index) { l.Clear(); int avalue = this.n; while (true) { if ((this[avalue].op == this.OP_CREATE_INDEX_OBJECT) && (this[avalue].res == num13)) { break; } avalue--; } int num15 = this[avalue].arg1; l.Add(avalue); int num16 = this.symbol_table[num15].TypeId; PropertyObject obj8 = this.GetClassObject(num16).FindIndexer(); if (obj8 != null) { while (true) { if ((this[avalue].op == this.OP_SETUP_INDEX_OBJECT) && (this[avalue].arg1 == num13)) { break; } if ((this[avalue].op == this.OP_ADD_INDEX) && (this[avalue].arg1 == num13)) { l.Add(avalue); } avalue++; } l.Add(avalue); if ((this.r.op == this.OP_ASSIGN) && (i == 1)) { if (obj8.WriteId == 0) { this.scripter.CreateErrorObject("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor."); break; } int num17 = this.r.arg2; this.InsertOperators(this.n, obj8.ParamCount + 3); this.n--; this.n++; this[this.n].op = this.OP_BEGIN_CALL; this[this.n].arg1 = obj8.WriteId; this[this.n].arg2 = 0; this[this.n].res = 0; for (int m = 1; m < (l.Count - 1); m++) { this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this[l[m]].arg2; this[this.n].arg2 = 0; this[this.n].res = obj8.WriteId; } this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num17; this[this.n].arg2 = 0; this[this.n].res = obj8.WriteId; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num15; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_BASE; this[this.n].arg1 = obj8.WriteId; this[this.n].arg2 = l.Count - 1; this[this.n].res = 0; this.r = (ProgRec) this.prog[this.n]; op = this.r.op; } else { if (obj8.ReadId == 0) { this.scripter.CreateErrorObject("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor."); break; } int num19 = this.AppVar(this.symbol_table[num13].Level, this.symbol_table[num13].TypeId); if (i == 1) { this.r.arg1 = num19; } else { this.r.arg2 = num19; } this.InsertOperators(this.n, obj8.ParamCount + 3); this.n--; this.n++; this[this.n].op = this.OP_BEGIN_CALL; this[this.n].arg1 = obj8.ReadId; this[this.n].arg2 = 0; this[this.n].res = 0; for (int num20 = 1; num20 < (l.Count - 1); num20++) { this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this[l[num20]].arg2; this[this.n].arg2 = 0; this[this.n].res = obj8.ReadId; } this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num15; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_BASE; this[this.n].arg1 = obj8.ReadId; this[this.n].arg2 = l.Count - 2; this[this.n].res = num19; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[obj8.ReadId].TypeId; this.r = (ProgRec) this.prog[this.n]; op = this.r.op; } list4.AddFrom(l); } } } if (op == this.OP_CREATE_METHOD) { num = this.r.arg1; goto Label_0079; } if (op != this.OP_CALL_SIMPLE) { if ((op == this.OP_CALL) || (op == this.OP_CALL_BASE)) { this.CheckOP_CALL(classObject, num, a, list2, pos); if (!this.scripter.IsError()) { goto Label_0079; } goto Label_22C6; } if (op == this.OP_CHECK_STRUCT_CONSTRUCTOR) { ClassObject obj12 = this.GetClassObject(this.r.arg1); if (obj12.IsStruct && !obj12.Imported) { FunctionObject obj13; this.r.op = this.OP_CREATE_OBJECT; int num35 = obj12.FindConstructorId(null, null, out obj13); if (num35 == 0) { this.scripter.CreateErrorObjectEx("CS0143. The type '{0}' has no constructors defined.", new object[] { obj12.Name }); } this.n++; this.InsertOperators(this.n, 2); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.res; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num35; this[this.n].arg2 = 0; this[this.n].res = 0; } else { this.r.op = this.OP_NOP; } } else if (op == this.OP_INSERT_STRUCT_CONSTRUCTORS) { ClassObject obj14 = this.GetClassObject(this.r.arg1); for (int num36 = 0; num36 < obj14.Members.Count; num36++) { MemberObject obj15 = obj14.Members[num36]; if (obj15.Kind == MemberKind.Field) { int num37 = this.symbol_table[obj15.Id].TypeId; ClassObject obj16 = this.GetClassObject(num37); if (obj16.IsStruct && !obj16.Imported) { if (obj16.IsPascalArray) { this.n++; this.InsertOperators(this.n, 1); this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].arg1 = num37; this[this.n].arg2 = 0; this[this.n].res = obj15.Id; } else { FunctionObject obj17; int num38 = obj16.FindConstructorId(null, null, out obj17); if (num38 == 0) { this.scripter.CreateErrorObjectEx("CS0143. The type '{0}' has no constructors defined.", new object[] { obj16.Name }); } this.n++; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].arg1 = num37; this[this.n].arg2 = 0; this[this.n].res = obj15.Id; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = obj15.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num38; this[this.n].arg2 = 0; this[this.n].res = 0; } } } } } else { if (op == this.OP_CAST) { this.CheckOP_CAST(); if (!this.scripter.IsError()) { goto Label_0079; } goto Label_22C6; } if (op == this.OP_TO_SBYTE) { this.symbol_table[this.r.res].TypeId = 10; } else if (op == this.OP_TO_BYTE) { this.symbol_table[this.r.res].TypeId = 3; } else if (op == this.OP_TO_USHORT) { this.symbol_table[this.r.res].TypeId = 15; } else if (op == this.OP_TO_SHORT) { this.symbol_table[this.r.res].TypeId = 11; } else if (op == this.OP_TO_UINT) { this.symbol_table[this.r.res].TypeId = 13; } else if (op == this.OP_TO_INT) { this.symbol_table[this.r.res].TypeId = 8; } else if (op == this.OP_TO_ULONG) { this.symbol_table[this.r.res].TypeId = 14; } else if (op == this.OP_TO_LONG) { this.symbol_table[this.r.res].TypeId = 9; } else if (op == this.OP_TO_CHAR) { this.symbol_table[this.r.res].TypeId = 4; } else if (op == this.OP_TO_FLOAT) { this.symbol_table[this.r.res].TypeId = 7; } else if (op == this.OP_TO_DOUBLE) { this.symbol_table[this.r.res].TypeId = 6; } else if (op == this.OP_TO_DECIMAL) { this.symbol_table[this.r.res].TypeId = 5; } else if (op == this.OP_TO_STRING) { this.symbol_table[this.r.res].TypeId = 12; } else if (op == this.OP_TO_BOOLEAN) { this.symbol_table[this.r.res].TypeId = 2; } else { if (op == this.OP_INC) { this.CheckOP_INC(); if (!this.scripter.IsError()) { goto Label_0079; } goto Label_22C6; } if (op == this.OP_DEC) { this.CheckOP_DEC(); if (!this.scripter.IsError()) { goto Label_0079; } goto Label_22C6; } if (op == this.OP_ASSIGN_COND_TYPE) { this.CheckOP_ASSIGN_COND_TYPE(); } else if (op == this.OP_ADD_EXPLICIT_INTERFACE) { this.OperAddExplicitInterface(); } else if (op == this.OP_END_CLASS) { stack.Pop(); if (stack.Count > 0) { int num39 = stack.Peek(); classObject = this.GetClassObject(num39); } else { classObject = null; } } else { if (op != this.OP_CREATE_CLASS) { if (op == this.OP_CREATE_OBJECT) { ClassObject obj27 = this.GetClassObject(this.r.arg1); if (!obj27.Abstract && !obj27.IsInterface) { goto Label_0079; } this.scripter.CreateErrorObjectEx("CS0144. Cannot create an instance of the abstract class or interface '{0}'.", new object[] { obj27.Name }); } else { if (op == this.OP_END_USING) { if ((obj2 != null) && (obj2.Id == this.r.arg1)) { obj2 = null; } goto Label_0079; } if (op == this.OP_ASSIGN) { this.CheckOP_ASSIGN(obj2); if (!this.scripter.IsError()) { goto Label_0079; } } else { if (op == this.OP_UNARY_MINUS) { if (!this.SetupDetailedUnaryOperator(op, "-", this.detailed_negation_operators)) { goto Label_22C6; } if (this[this.n].op != this.OP_CALL_SIMPLE) { this.r = this[this.n]; int num48 = this.GetTypeId(this.r.arg1); int num49 = this.GetTypeId(this.r.res); if ((num48 != num49) && IsNumericTypeId(num49)) { this.InsertNumericConversion(num49, 1); } } goto Label_0079; } if (op == this.OP_NOT) { if (this.SetupDetailedUnaryOperator(op, "!", this.detailed_logical_negation_operators)) { goto Label_0079; } } else { if (op == this.OP_COMPLEMENT) { if (!this.SetupDetailedUnaryOperator(op, "~", this.detailed_bitwise_complement_operators)) { goto Label_22C6; } if (this[this.n].op != this.OP_CALL_SIMPLE) { this.r = this[this.n]; int num50 = this.GetTypeId(this.r.arg1); int num51 = this.GetTypeId(this.r.res); if ((num50 != num51) && IsNumericTypeId(num51)) { this.InsertNumericConversion(num51, 1); } } goto Label_0079; } if (op == this.OP_PLUS) { this.CheckOP_PLUS(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_MINUS) { this.CheckOP_MINUS(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_MULT) { this.CheckOP_MULT(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_EXPONENT) { this.CheckOP_EXP(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_DIV) { this.CheckOP_DIV(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_MOD) { this.CheckOP_MOD(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_LEFT_SHIFT) { this.CheckOP_LEFT_SHIFT(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_RIGHT_SHIFT) { this.CheckOP_RIGHT_SHIFT(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_BITWISE_AND) { this.CheckOP_BITWISE_AND(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_BITWISE_OR) { this.CheckOP_BITWISE_OR(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_BITWISE_XOR) { this.CheckOP_BITWISE_XOR(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_LOGICAL_AND) { this.CheckOP_LOGICAL_AND(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_LOGICAL_OR) { this.CheckOP_LOGICAL_OR(); if (!this.scripter.IsError()) { goto Label_0079; } } else { if (op == this.OP_LT) { if (!this.SetupDetailedBinaryOperator(op, "<", this.detailed_lt_operators)) { goto Label_22C6; } this.symbol_table[this.r.res].TypeId = 2; goto Label_0079; } if (op == this.OP_LE) { if (!this.SetupDetailedBinaryOperator(op, "<=", this.detailed_le_operators)) { goto Label_22C6; } this.symbol_table[this.r.res].TypeId = 2; goto Label_0079; } if (op == this.OP_GT) { if (!this.SetupDetailedBinaryOperator(op, ">", this.detailed_gt_operators)) { goto Label_22C6; } this.symbol_table[this.r.res].TypeId = 2; goto Label_0079; } if (op == this.OP_GE) { if (!this.SetupDetailedBinaryOperator(op, ">=", this.detailed_ge_operators)) { goto Label_22C6; } this.symbol_table[this.r.res].TypeId = 2; goto Label_0079; } if (op == this.OP_EQ) { this.CheckOP_EQ(); if (!this.scripter.IsError()) { goto Label_0079; } } else if (op == this.OP_NE) { this.CheckOP_NE(); if (!this.scripter.IsError()) { goto Label_0079; } } else { if (op == this.OP_IS) { this.symbol_table[this.r.res].TypeId = 2; goto Label_0079; } if (op == this.OP_AS) { if (this.symbol_table[this.r.arg2].Kind != MemberKind.Type) { this.scripter.CreateErrorObject("CS1031. Type expected."); goto Label_22C6; } ClassObject obj28 = this.GetClassObject(this.symbol_table[this.r.arg1].TypeId); ClassObject obj29 = this.GetClassObject(this.r.arg2); if (obj29.IsValueType) { this.scripter.CreateErrorObjectEx("CS0077. The as operator must be used with a reference type ('{0}' is a value type).", new object[] { obj29.Name }); goto Label_22C6; } if (!this.scripter.conversion.ExistsImplicitReferenceConversion(obj29, obj28)) { this.scripter.CreateErrorObjectEx("CS0039. Cannot convert type '{0}' to '{1}'.", new object[] { obj29.Name, obj28.Name }); goto Label_22C6; } this.symbol_table[this.r.res].TypeId = this.r.arg2; goto Label_0079; } if (op == this.OP_CREATE_REFERENCE) { this.CheckOP_CREATE_REFERENCE(classObject); if (this.scripter.IsError()) { goto Label_22C6; } goto Label_0079; } if (op == this.OP_DECLARE_LOCAL_VARIABLE) { this.OperDeclareLocalVariable(); goto Label_0079; } if (op != this.OP_ADDRESS_OF) { goto Label_0079; } this.ProcessAddressOf(); if (!this.scripter.IsError()) { goto Label_0079; } } } } } } goto Label_22C6; } bool flag3 = this.GetUpcase(this.n); ClassObject obj18 = this.GetClassObject(this.r.arg1); if (obj18.Class_Kind == ClassKind.Enum) { obj2 = obj18; } classObject = obj18; stack.Push(classObject.Id); if (obj18.IsClass || obj18.IsStruct) { int num40 = 0; for (int num41 = 0; num41 < obj18.AncestorIds.Count; num41++) { int num42 = obj18.AncestorIds[num41]; ClassObject obj19 = this.GetClassObject(num42); if (!obj19.IsInterface) { num40++; if (num40 > 1) { this.scripter.CreateErrorObjectEx("CS0527. '{0}' : type in interface list is not an interface.", new object[] { obj19.Name }); break; } } } IntegerList supportedInterfaceListIds = obj18.GetSupportedInterfaceListIds(); if (obj18.AncestorClass.HasModifier(Modifier.Abstract)) { supportedInterfaceListIds.Add(obj18.AncestorClass.Id); } for (int num43 = 0; num43 < supportedInterfaceListIds.Count; num43++) { int num44 = supportedInterfaceListIds[num43]; ClassObject obj20 = this.GetClassObject(num44); for (int num45 = 0; num45 < obj20.Members.Count; num45++) { MemberObject obj21 = obj20.Members[num45]; if (obj21.HasModifier(Modifier.Abstract)) { if (((obj21.Kind == MemberKind.Method) || (obj21.Kind == MemberKind.Constructor)) || (obj21.Kind == MemberKind.Destructor)) { bool flag4 = false; FunctionObject fy = (FunctionObject) obj21; for (int num46 = 0; num46 < obj18.Members.Count; num46++) { MemberObject obj23 = obj18.Members[num46]; if (obj23.Public && (obj21.Kind == obj23.Kind)) { if (CSLite_System.CompareStrings(obj21.Name, obj23.Name, flag3)) { FunctionObject fx = (FunctionObject) obj23; if (FunctionObject.CompareHeaders(fx, fy)) { flag4 = true; break; } } if (obj23.ImplementsId != 0) { string str6 = this.symbol_table[obj23.ImplementsId].Name; if (CSLite_System.CompareStrings(obj21.Name, str6, flag3)) { flag4 = true; break; } } } } if (flag4) { continue; } if (obj20.IsInterface) { this.scripter.CreateErrorObjectEx("CS0535. '{0}' does not implement interface member '{1}'.", new object[] { obj18.FullName, obj20.FullName + "." + fy.Name }); } else if (obj20.IsClass) { this.scripter.CreateErrorObjectEx("CS0534. '{0}' does not implement inherited abstract member '{1}'.", new object[] { obj18.FullName, obj20.FullName + "." + fy.Name }); } break; } if (obj21.Kind == MemberKind.Property) { bool flag5 = false; PropertyObject obj25 = (PropertyObject) obj21; for (int num47 = 0; num47 < obj18.Members.Count; num47++) { MemberObject obj26 = obj18.Members[num47]; if (obj26.Public && (obj21.Kind == obj26.Kind)) { if (CSLite_System.CompareStrings(obj21.Name, obj26.Name, flag3)) { flag5 = true; break; } if (obj26.ImplementsId != 0) { string str7 = this.symbol_table[obj26.ImplementsId].Name; if (CSLite_System.CompareStrings(obj21.Name, str7, flag3)) { flag5 = true; break; } } } } if (!flag5) { if (obj20.IsInterface) { this.scripter.CreateErrorObjectEx("CS0535. '{0}' does not implement interface member '{1}'.", new object[] { obj18.FullName, obj20.FullName + "." + obj25.Name }); } else if (obj20.IsClass) { this.scripter.CreateErrorObjectEx("CS0534. '{0}' does not implement inherited abstract member '{1}'.", new object[] { obj18.FullName, obj20.FullName + "." + obj25.Name }); } break; } } } } } } } } } goto Label_0079; } this.r.op = this.OP_CALL; int id = this.r.arg1; if (this.symbol_table[id].Kind != MemberKind.Method) { goto Label_0079; } int num22 = this.r.arg2; a.Clear(); list2.Clear(); pos.Clear(); if (num22 > 0) { int num23 = this.n - 1; do { if ((this[num23].op == this.OP_PUSH) && (this[num23].res == id)) { pos.Add(num23); a.Add(this[num23].arg1); list2.Add(this[num23].arg2); if (a.Count == num22) { goto Label_0C8B; } } num23--; } while (num23 != 0); this.scripter.CreateErrorObject("CS0001. Internal compiler error."); return; } Label_0C8B: obj9 = this.GetFunctionObject(id); bool flag2 = true; for (int j = 0; j < num22; j++) { int paramId = obj9.GetParamId(j); int num26 = a[j]; if (!obj9.Imported) { flag2 = ((int)obj9.GetParamMod(j) == list2[j]); } else { flag2 = true; } if (!flag2) { this.n = pos[j]; ParamMod paramMod = obj9.GetParamMod(j); ParamMod mod2 = (ParamMod) list2[j]; int num27 = this.symbol_table[paramId].TypeId; int num28 = this.symbol_table[num26].TypeId; string str4 = this.symbol_table[num27].Name; string str5 = this.symbol_table[num28].Name; switch (paramMod) { case ParamMod.RetVal: str4 = "ref " + str4; break; case ParamMod.Out: str4 = "out " + str4; break; } if (mod2 == ParamMod.RetVal) { str5 = "ref " + str5; } else if (mod2 == ParamMod.Out) { str5 = "out " + str5; } this.scripter.CreateErrorObjectEx("CS0029. Cannot impllicitly convert type '{0}' to '{1}'.", new object[] { str4, str5 }); break; } flag2 = this.scripter.MatchAssignment(paramId, num26); if (!flag2) { this.n = pos[j]; int num29 = this.symbol_table[paramId].TypeId; int num30 = this.symbol_table[num26].TypeId; ClassObject obj10 = this.GetClassObject(num29); ClassObject obj11 = this.GetClassObject(num30); int num31 = obj10.FindOverloadableImplicitOperatorId(num26, paramId); if (num31 > 0) { int currMethodId = this.GetCurrMethodId(); int num33 = this.AppVar(currMethodId, num29); int res = this[this.n].res; this[this.n].arg1 = num33; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num26; this[this.n].arg2 = 0; this[this.n].res = num31; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = obj10.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num31; this[this.n].arg2 = 1; this[this.n].res = num33; while (this[this.n].arg1 != res) { this.n++; } goto Label_0079; } this.scripter.CreateErrorObjectEx("CS0029. Cannot impllicitly convert type '{0}' to '{1}'.", new object[] { obj11.Name, obj10.Name }); break; } } if (flag2) { goto Label_0079; } Label_22C6: num52 = 0; while (num52 < list4.Count) { this.n = list4[num52]; this[this.n].op = this.OP_NOP; num52++; } }
private void Parse_ArrayTypeDeclaration(int array_id, ModifierList ml) { base.CheckModifiers(ml, this.structure_modifiers); base.BeginArray(array_id, ml); this.Match("array"); IntegerList list = new IntegerList(false); list.Add(array_id); if (!base.IsCurrText('[')) { this.Gen(base.code.OP_ADD_ARRAY_RANGE, array_id, 8, 0); goto Label_00AA; } this.Match('['); Label_0043: this.Gen(base.code.OP_ADD_ARRAY_RANGE, array_id, this.Parse_OrdinalType(), 0); if (base.IsCurrText(',')) { this.Match(','); array_id = base.NewVar(); base.BeginArray(array_id, ml); list.Add(array_id); goto Label_0043; } this.Match(']'); Label_00AA: this.Match("of"); list.Add(this.Parse_Type()); for (int i = list.Count - 1; i > 0; i--) { this.Gen(base.code.OP_ADD_ARRAY_INDEX, list[i - 1], list[i], 0); base.EndArray(list[i - 1]); } this.CreateDefaultConstructor(list[0], false); }
private IntegerList Parse_VariableIdentifiers(ArrayList bounds_list, ArrayList sl) { IntegerList list = new IntegerList(false); while (true) { string str; IntegerList bounds = new IntegerList(true); int avalue = this.Parse_VariableIdentifier(bounds, out str); list.Add(avalue); bounds_list.Add(bounds); sl.Add(str); if (!base.CondMatch(',')) { return list; } } }
private IntegerList Parse_DirectiveList() { IntegerList list = new IntegerList(false); while (true) { while (base.IsCurrText("overload")) { this.Call_SCANNER(); list.Add(0); this.Match(';'); } if (!base.IsCurrText("forward")) { return list; } this.Call_SCANNER(); list.Add(1); this.Match(';'); } }
private void Parse_PropertyMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers, ClassKind ck) { base.DECLARE_SWITCH = true; this.Match("property"); int num = this.Parse_Ident(); this.param_ids.Clear(); this.param_type_ids.Clear(); this.param_mods.Clear(); IntegerList list = new IntegerList(true); if (base.IsCurrText('[')) { this.Match('['); if (!base.IsCurrText(']')) { this.Parse_ParameterList(num, false); } this.Match(']'); } base.DECLARE_SWITCH = false; this.Match(":"); int num2 = this.Parse_Type(); base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num, -1, -1); this.Gen(base.code.OP_ASSIGN_TYPE, num, num2, 0); int id = 0; int iD = 0; if (base.IsCurrText("read")) { this.Call_SCANNER(); id = this.Parse_Ident(); string name = base.GetName(id); base.DiscardInstruction(base.code.OP_EVAL, 0, 0, id); base.SetName(id, ""); id = base.LookupID(name); if (id == 0) { base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { name }); } } if (base.IsCurrText("write")) { this.Call_SCANNER(); iD = this.Parse_Ident(); string s = base.GetName(iD); base.DiscardInstruction(base.code.OP_EVAL, 0, 0, iD); base.SetName(iD, ""); iD = base.LookupID(s); if (iD == 0) { base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { s }); } } base.BeginProperty(num, ml, num2, 0); if (id > 0) { this.valid_this_context = true; int num5 = base.NewVar(); base.SetName(num5, "get_" + base.GetName(num)); this.BeginMethod(num5, MemberKind.Method, ml, num2); list.Clear(); for (int i = 0; i < this.param_ids.Count; i++) { base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1); int num7 = base.NewVar(); base.SetName(num7, base.GetName(this.param_ids[i])); this.Gen(base.code.OP_ASSIGN_TYPE, num7, this.param_type_ids[i], 0); this.Gen(base.code.OP_ADD_PARAM, num5, num7, 0); list.Add(num7); } this.InitMethod(num5); if (base.GetKind(id) == MemberKind.Method) { int res = base.NewRef(base.GetName(id)); this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, res); this.Gen(base.code.OP_BEGIN_CALL, res, 0, 0); for (int j = 0; j < this.param_ids.Count; j++) { this.Gen(base.code.OP_PUSH, list[j], 0, res); } this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0); this.Gen(base.code.OP_CALL, res, this.param_ids.Count, base.CurrResultId); } else if (base.GetKind(id) == MemberKind.Field) { if (this.param_ids.Count > 0) { base.RaiseError(false, "PAS0002. Incompatible types"); } int num10 = base.NewRef(base.GetName(id)); this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num10); this.Gen(base.code.OP_ASSIGN, base.CurrResultId, num10, base.CurrResultId); } else { base.RaiseError(false, "PAS0001. Field or method identifier expected"); } this.EndMethod(num5); this.Gen(base.code.OP_ADD_READ_ACCESSOR, num, num5, 0); this.valid_this_context = false; } if (iD > 0) { int num12; this.valid_this_context = true; int num11 = base.NewVar(); base.SetName(num11, "set_" + base.GetName(num)); this.BeginMethod(num11, MemberKind.Method, ml, num2); list.Clear(); for (int k = 0; k < this.param_ids.Count; k++) { base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1); num12 = base.NewVar(); base.SetName(num12, base.GetName(this.param_ids[k])); this.Gen(base.code.OP_ASSIGN_TYPE, num12, this.param_type_ids[k], 0); this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0); list.Add(num12); } num12 = base.NewVar(); base.SetName(num12, "value"); this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0); this.Gen(base.code.OP_ASSIGN_TYPE, num12, num2, 0); list.Add(num12); this.InitMethod(num11); if (base.GetKind(iD) == MemberKind.Method) { int num14 = base.NewRef(base.GetName(iD)); this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num14); this.Gen(base.code.OP_BEGIN_CALL, num14, 0, 0); for (int m = 0; m < list.Count; m++) { this.Gen(base.code.OP_PUSH, list[m], 0, num14); } this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0); this.Gen(base.code.OP_CALL, num14, list.Count, base.CurrResultId); } else if (base.GetKind(iD) == MemberKind.Field) { if (this.param_ids.Count > 0) { base.RaiseError(false, "PAS0002. Incompatible types"); } int num16 = base.NewRef(base.GetName(iD)); this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num16); this.Gen(base.code.OP_ASSIGN, num16, num12, num16); } else { base.RaiseError(false, "PAS0001. Field or method identifier expected"); } this.EndMethod(num11); this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, num, num11, 0); this.valid_this_context = false; } this.Match(";"); if (base.IsCurrText("default")) { this.Call_SCANNER(); if (this.param_ids.Count == 0) { base.RaiseError(false, "VB00004. Properties with no required parameters cannot be declared 'Default'."); } else { this.Gen(base.code.OP_SET_DEFAULT, num, 0, 0); } this.Match(";"); } base.EndProperty(num); base.DECLARE_SWITCH = true; }
public IntegerList Clone() { IntegerList list = new IntegerList(base.DupYes); for (int i = 0; i < base.Count; i++) { list.Add(this[i]); } return list; }
private void CheckOP_CREATE_REFERENCE(ClassObject current_class) { MemberObject memberByNameIndex; int num35; if (this.symbol_table[this.r.arg1].Kind != MemberKind.Type) { EventObject obj9; int num10; this.scripter.Dump(); int typeId = this.symbol_table[this.r.arg1].TypeId; ClassObject classObjectEx = this.GetClassObjectEx(typeId); int nameIndex = this.symbol_table[this.r.res].NameIndex; string name = this.symbol_table[this.r.res].Name; bool upcase = this.GetUpcase(this.n); memberByNameIndex = classObjectEx.GetMemberByNameIndex(nameIndex, upcase); if (((memberByNameIndex == null) && upcase) && ((name.ToUpper() == "NEW") && this.PascalOrBasic(this.n))) { FunctionObject obj4; IntegerList a = new IntegerList(false); IntegerList list2 = new IntegerList(false); classObjectEx.FindConstructorId(a, list2, out obj4); if (obj4 != null) { memberByNameIndex = obj4; } } if (memberByNameIndex == null) { this.scripter.CreateErrorObjectEx("CS0103. The name '{0}' does not exist in the class or namespace '{1}'.", new object[] { name, classObjectEx.Name }); return; } if (memberByNameIndex.Static) { memberByNameIndex = classObjectEx.GetInstanceMemberByNameIndex(nameIndex, upcase); if (memberByNameIndex == null) { this.scripter.CreateErrorObjectEx("CS0176. Static member '{0}' cannot be accessed with an instance reference; qualify it with a type name instead.", new object[] { name }); return; } } if (memberByNameIndex.Private) { if (current_class == null) { this.scripter.CreateErrorObject("CS0001. Internal compiler error."); return; } if (classObjectEx.Id != current_class.Id) { this.scripter.CreateErrorObjectEx("CS0122. '{0}' is inaccessible due to its protection level.", new object[] { memberByNameIndex.Name }); return; } } if (memberByNameIndex.Protected) { if (current_class == null) { this.scripter.CreateErrorObject("CS0001. Internal compiler error."); return; } if ((classObjectEx.Id != current_class.Id) && !current_class.InheritsFrom(classObjectEx)) { this.scripter.CreateErrorObjectEx("CS0122. '{0}' is inaccessible due to its protection level.", new object[] { memberByNameIndex.Name }); return; } } if (memberByNameIndex.Kind == MemberKind.Constructor) { this.ReplaceId(this.r.res, memberByNameIndex.Id); this.r.op = this.OP_NOP; goto Label_17DB; } if (memberByNameIndex.Kind != MemberKind.Method) { if (memberByNameIndex.Kind != MemberKind.Event) { if (memberByNameIndex.Kind != MemberKind.Property) { goto Label_17DB; } PropertyObject obj10 = (PropertyObject) memberByNameIndex; int num18 = 0; bool flag4 = false; bool flag5 = false; for (int j = this.n; j <= this.Card; j++) { if (this[j].arg1 == this.r.res) { if (this[j].op == this.OP_ASSIGN) { num18 = j; break; } if ((this[j].op == this.OP_CALL) && this.PascalOrBasic(this.n)) { if ((this[j + 1].op != this.OP_ASSIGN) || (this[j + 1].arg1 != this[j].res)) { continue; } num18 = j + 1; flag4 = true; break; } flag5 = true; } } if (num18 > 0) { if (obj10.WriteId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj10.Name }); return; } FunctionObject obj11 = this.GetFunctionObject(obj10.WriteId); if (flag4) { int num20 = this[num18].arg2; this.ReplaceId(this.r.res, obj10.WriteId); this.r.op = this.OP_NOP; this[num18 - 2].arg1 = this.r.arg1; this[num18].op = this.OP_NOP; ProgRec rec1 = this[num18 - 1]; rec1.arg2++; if (obj11.ParamCount != this[num18 - 1].arg2) { } this.InsertOperators(num18 - 2, 1); this[num18 - 2].op = this.OP_PUSH; this[num18 - 2].arg1 = num20; this[num18 - 2].arg2 = 0; this[num18 - 2].res = obj10.WriteId; return; } this[num18].op = this.OP_PUSH; this[num18].arg1 = this[num18].arg2; this[num18].arg2 = 0; this[num18].res = obj10.WriteId; this[num18 + 1].op = this.OP_PUSH; this[num18 + 1].arg1 = this.r.arg1; this[num18 + 1].arg2 = 0; this[num18 + 1].res = 0; this[num18 + 2].op = this.OP_CALL_SIMPLE; this[num18 + 2].arg1 = obj10.WriteId; this[num18 + 2].arg2 = 1; this[num18 + 2].res = 0; if (flag5) { if (obj10.ReadId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj10.Name }); return; } this[this.n - 1].op = this.OP_PUSH; this[this.n - 1].arg1 = this.r.arg1; this[this.n - 1].arg2 = 0; this[this.n - 1].res = 0; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = obj10.ReadId; this[this.n].arg2 = 0; this.symbol_table[this[this.n].res].Kind = MemberKind.Var; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[obj10.ReadId].TypeId; } else { this.r.op = this.OP_NOP; } if (obj11.ParamCount != 1) { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { obj11.FullName, 1 }); } goto Label_17DB; } if (obj10.ReadId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj10.Name }); return; } FunctionObject functionObject = this.GetFunctionObject(obj10.ReadId); int n = this.n; bool flag6 = false; Label_0E61: n++; if (n != this.card) { if ((this[n].op != this.OP_BEGIN_CALL) || (this[n].arg1 != this.r.res)) { goto Label_0E61; } flag6 = true; } if (!flag6 || !this.PascalOrBasic(this.n)) { this[this.n - 1].op = this.OP_PUSH; this[this.n - 1].arg1 = this.r.arg1; this.r.op = this.OP_CALL_SIMPLE; this.r.arg1 = obj10.ReadId; this.r.arg2 = 0; this.symbol_table[this.r.res].Kind = MemberKind.Var; this.symbol_table[this.r.res].TypeId = this.symbol_table[obj10.ReadId].TypeId; if (functionObject.ParamCount != 0) { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { functionObject.FullName, 0 }); } goto Label_17DB; } this.ReplaceId(this.r.res, obj10.ReadId); this.r.op = this.OP_NOP; IntegerList list3 = new IntegerList(true); IntegerList list4 = new IntegerList(true); int pos = 0; int avalue = n; do { avalue++; if ((this[avalue].op == this.OP_PUSH) && (this[avalue].res == obj10.ReadId)) { list3.Add(avalue); list4.Add(this[avalue].arg1); } } while ((this[avalue].op != this.OP_CALL) || (this[avalue].arg1 != obj10.ReadId)); this[avalue].tag = avalue; this.get_item_list.Add(this[avalue]); pos = avalue; this[avalue - 1].arg1 = this.r.arg1; if (functionObject.ParamCount != this[avalue].arg2) { if (functionObject.Owner.HasMethod(functionObject.NameIndex, this[avalue].arg2)) { return; } if (functionObject.ParamCount == 0) { this[avalue].arg2 = 0; for (int k = 0; k < list3.Count; k++) { this[list3[k]].op = this.OP_NOP; } int resultId = functionObject.ResultId; int id = this.symbol_table[resultId].TypeId; ClassObject classObject = this.GetClassObject(id); int num27 = this.scripter.names.Add("get_Item"); MemberObject obj14 = classObject.GetMemberByNameIndex(num27, true); if (obj14 == null) { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { functionObject.FullName, this[avalue].arg2 }); } else { int res = this[avalue].res; int num29 = this.AppVar(this.symbol_table[res].Level); this.symbol_table[num29].TypeId = id; this[avalue].res = num29; int num30 = obj14.Id; this.InsertOperators(avalue + 1, list4.Count + 3); avalue++; this[avalue].op = this.OP_BEGIN_CALL; this[avalue].arg1 = num30; this[avalue].arg2 = 0; this[avalue].res = 0; for (int m = 0; m < list3.Count; m++) { avalue++; this[avalue].op = this.OP_PUSH; this[avalue].arg1 = list4[m]; this[avalue].arg2 = 0; this[avalue].res = num30; } avalue++; this[avalue].op = this.OP_PUSH; this[avalue].arg1 = num29; this[avalue].arg2 = 0; this[avalue].res = 0; avalue++; this[avalue].op = this.OP_CALL; this[avalue].arg1 = num30; this[avalue].arg2 = list4.Count; this[avalue].res = res; resultId = this.GetFunctionObject(num30).ResultId; id = this.symbol_table[resultId].TypeId; this.symbol_table[res].TypeId = id; this.n = avalue - 1; } return; } this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { functionObject.FullName, this[avalue].arg2 }); } if (this.get_item_list.Count < 2) { return; } ProgRec rec = this.get_item_list[this.get_item_list.Count - 2] as ProgRec; ProgRec rec2 = this.get_item_list[this.get_item_list.Count - 1] as ProgRec; if (rec.arg1 != rec2.arg1) { return; } while ((this[pos + 1].op != this.OP_ASSIGN) || (this[pos + 1].arg1 != rec.res)) { pos++; if (pos == this.card) { return; } } if ((this[pos + 1].op != this.OP_ASSIGN) || (this[pos + 1].arg1 != rec.res)) { return; } if (obj10.WriteId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj10.Name }); return; } int num32 = this[pos + 1].arg2; this[pos + 1].op = this.OP_NOP; int tag = rec.tag; ArrayList list5 = new ArrayList(); list5.Insert(0, this[tag].Clone()); this[tag].op = this.OP_NOP; tag--; list5.Insert(0, this[tag].Clone()); this[tag].op = this.OP_NOP; int num34 = 0; while (true) { tag--; if ((this[tag].op == this.OP_PUSH) && (this[tag].res == rec.arg1)) { list5.Insert(0, this[tag].Clone()); this[tag].op = this.OP_NOP; num34++; if (num34 == rec.arg2) { pos++; this.InsertOperators(pos, list5.Count); this[pos].op = this.OP_BEGIN_CALL; this[pos].arg1 = obj10.WriteId; this[pos].arg2 = 0; this[pos].res = 0; for (num34 = 0; num34 <= (list5.Count - 3); num34++) { pos++; this[pos].op = this.OP_PUSH; this[pos].arg1 = (list5[num34] as ProgRec).arg1; this[pos].arg2 = (list5[num34] as ProgRec).arg2; this[pos].res = obj10.WriteId; } pos++; this[pos].op = this.OP_PUSH; this[pos].arg1 = num32; this[pos].arg2 = 0; this[pos].res = obj10.WriteId; pos++; this[pos].op = this.OP_PUSH; this[pos].arg1 = (list5[list5.Count - 2] as ProgRec).arg1; this[pos].arg2 = 0; this[pos].res = 0; pos++; this[pos].op = this.OP_CALL; this[pos].arg1 = obj10.WriteId; this[pos].arg2 = rec.arg2 + 1; this[pos].res = 0; return; } } } } obj9 = (EventObject) memberByNameIndex; num10 = 0; for (int i = this.n; i <= this.Card; i++) { if ((this[i].arg1 == this.r.res) && (this[i].op == this.OP_ASSIGN)) { num10 = i; break; } } } else { int num3 = this.n - 1; while ((this[num3].op == this.OP_NOP) || (this[num3].op == this.OP_SEPARATOR)) { num3--; } bool isDelegate = false; ClassObject obj5 = null; if (this[num3].op == this.OP_BEGIN_CALL) { int num4 = this[num3].arg1; if (this.symbol_table[num4].Kind == MemberKind.Type) { obj5 = this.GetClassObject(num4); isDelegate = obj5.IsDelegate; } } if (isDelegate) { FunctionObject obj6; FunctionObject patternMethod = obj5.PatternMethod; if (patternMethod.Init == null) { FunctionObject g = this.GetFunctionObject(memberByNameIndex.Id); this.CreatePatternMethod(patternMethod, g); } int num5 = classObjectEx.FindMethodId(nameIndex, patternMethod.Param_Ids, patternMethod.Param_Mod, patternMethod.ResultId, out obj6, upcase); if (num5 == 0) { if (classObjectEx.GetMemberByNameIndex(nameIndex, upcase) != null) { this.scripter.CreateErrorObject("CS0149. Method name expected."); } else { string str2 = obj5.Name; this.scripter.CreateErrorObjectEx("CS0123. Method '{0}' does not match delegate '{1}'.", new object[] { name, str2 }); } return; } this.ReplaceId(this.r.res, num5); this.r.res = obj5.Id; this.r.op = this.OP_PUSH; } else if (!this.PascalOrBasic(this.n)) { this.r.op = this.OP_NOP; } else { int num6 = this.r.arg1; int num7 = memberByNameIndex.Id; if (this[this.n + 1].op == this.OP_ADDRESS_OF) { this.r.op = this.OP_NOP; this[this.n + 1].arg1 = num7; } else { bool flag3 = false; for (int num8 = this.n; num8 < this.card; num8++) { int op = this[num8].op; if ((this[num8].arg1 == this.r.res) && (((op == this.OP_CALL) || (op == this.OP_CALL_BASE)) || ((op == this.OP_CALL_VIRT) || (op == this.OP_CALL_SIMPLE)))) { flag3 = true; break; } } if (flag3) { this.r.op = this.OP_NOP; } else { this.InsertOperators(this.n, 2); this[this.n].op = this.OP_BEGIN_CALL; this[this.n].arg1 = num7; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num6; this[this.n].arg2 = 0; this[this.n].res = 0; this.r.op = this.OP_CALL; this.r.arg1 = num7; this.r.arg2 = 0; this.symbol_table[this.r.res].Kind = MemberKind.Var; } } } goto Label_17DB; } if (num10 == 0) { if (obj9.EventFieldId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj9.Name }); return; } string str3 = this.symbol_table[obj9.EventFieldId].Name; this.symbol_table[this.r.res].Name = str3; goto Label_17DB; } num10--; if (this[num10].op == this.OP_PLUS) { if (obj9.AddId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj9.Name }); return; } int addId = obj9.AddId; int num13 = this[num10].arg2; int num14 = this.r.arg1; this.r.op = this.OP_NOP; this[num10].op = this.OP_PUSH; this[num10].arg1 = num13; this[num10].arg2 = 0; this[num10].res = addId; num10++; this[num10].op = this.OP_PUSH; this[num10].arg1 = num14; this[num10].arg2 = 0; this[num10].res = 0; num10++; this[num10].op = this.OP_CALL_SIMPLE; this[num10].arg1 = addId; this[num10].arg2 = 1; this[num10].res = 0; goto Label_17DB; } if (this[num10].op == this.OP_MINUS) { if (obj9.RemoveId == 0) { this.scripter.CreateErrorObjectEx("CS0154. The property or indexer '{0}' cannot be used in this context because it lacks the get accessor.", new object[] { obj9.Name }); return; } int removeId = obj9.RemoveId; int num16 = this[num10].arg2; int num17 = this.r.arg1; this.r.op = this.OP_NOP; this[num10].op = this.OP_PUSH; this[num10].arg1 = num16; this[num10].arg2 = 0; this[num10].res = removeId; num10++; this[num10].op = this.OP_PUSH; this[num10].arg1 = num17; this[num10].arg2 = 0; this[num10].res = 0; num10++; this[num10].op = this.OP_CALL_SIMPLE; this[num10].arg1 = removeId; this[num10].arg2 = 1; this[num10].res = 0; goto Label_17DB; } this.scripter.CreateErrorObjectEx("CS0079. The event '{0}' can only appear on the left hand side of += or -=.", new object[] { obj9.Name }); } return; Label_17DB: num35 = this.symbol_table[memberByNameIndex.Id].TypeId; this.symbol_table[this.r.res].TypeId = num35; }
private void CheckOP_CALL(ClassObject current_class, int curr_level, IntegerList a, IntegerList param_mod, IntegerList pos) { FunctionObject obj10; int num35; bool flag8; int id = this.r.arg1; int n = this.n; a.Clear(); param_mod.Clear(); pos.Clear(); int num3 = 0; int avalue = this.n; while (true) { if (avalue <= 1) { this.scripter.CreateErrorObject("CS0001. Internal compiler error."); return; } if ((this[avalue].op == this.OP_BEGIN_CALL) && (this[avalue].arg1 == id)) { break; } avalue--; } this[avalue].op = this.OP_NOP; while (true) { if ((this[avalue].op == this.OP_PUSH) && (this[avalue].res == id)) { pos.Add(avalue); a.Add(this[avalue].arg1); param_mod.Add(this[avalue].arg2); if (this[avalue].arg2 > 0) { num3++; } } if (avalue == this.n) { break; } avalue++; } this.scripter.Dump(); MemberKind kind = this.symbol_table[id].Kind; if (kind == MemberKind.Type) { ClassObject val = (ClassObject) this.GetVal(id); if (val.IsDelegate) { if (a.Count == 1) { FunctionObject obj3 = this.GetFunctionObject(curr_level); this.InsertOperators(pos[0], 1); this.n++; this[pos[0]].op = this.OP_PUSH; this[pos[0]].arg1 = obj3.ThisId; this[pos[0]].arg2 = 0; this[pos[0]].res = val.Id; a.Insert(0, obj3.ThisId); } if (val.PatternMethod.Init == null) { FunctionObject patternMethod = val.PatternMethod; int last = a.Last; if (this.symbol_table[last].Kind == MemberKind.Ref) { int num6 = this.symbol_table[last].Level; int num7 = this.symbol_table[num6].TypeId; ClassObject classObjectEx = this.GetClassObjectEx(num7); int num8 = this.symbol_table[last].NameIndex; bool flag = this.GetUpcase(this.n); MemberObject memberByNameIndex = classObjectEx.GetMemberByNameIndex(num8, flag); this.ReplaceId(a.Last, memberByNameIndex.Id); a.Last = memberByNameIndex.Id; } FunctionObject g = this.GetFunctionObject(a.Last); this.CreatePatternMethod(patternMethod, g); } this[this.n].op = this.OP_SETUP_DELEGATE; this[this.n].arg1 = 0; this[this.n].arg2 = 0; this[this.n].res = 0; } else if (this.r.res > 0) { if ((a.Count == 1) && (this.GetLanguage(this.n) == CSLite_Language.Pascal)) { this.r.op = this.OP_CAST; this.r.arg2 = a[0]; this[this.n - 1].op = this.OP_NOP; this[pos[0]].op = this.OP_NOP; this.n--; } else { string str = this.symbol_table[this.r.arg1].Name; this.scripter.CreateErrorObjectEx("CS0119. '{0}' denotes a '{1}' which is not valid in the given context.", new object[] { str, "type" }); } } else { FunctionObject obj8; id = val.FindConstructorId(a, param_mod, out obj8); if (id != 0) { goto Label_17D6; } string str2 = val.Name; if (obj8 != null) { if (obj8.ParamCount == a.Count) { if ((obj8.ParamsId == 0) || (a.Count == 0)) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { str2 }); return; } int num9 = a[a.Count - 1]; int num10 = this.symbol_table[num9].TypeId; if (CSLite_System.GetRank(this.symbol_table[num10].Name) != 0) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { str2 }); return; } this.InsertActualArray(obj8, curr_level, pos, a); id = obj8.Id; n = this.n; goto Label_17D6; } if (a.Count < obj8.ParamCount) { if (obj8.ParamsId == 0) { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { str2, a.Count }); } else { if ((a.Count + 1) == obj8.ParamCount) { this.InsertActualArray(obj8, curr_level, pos, a); id = obj8.Id; n = this.n; goto Label_17D6; } this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { str2, a.Count }); } } else { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { str2, a.Count }); } } else { this.scripter.CreateErrorObjectEx("CS0143. The type '{0}' has no constructors defined.", new object[] { val.Name }); } } return; } if (kind != MemberKind.Method) { switch (kind) { case MemberKind.Constructor: { FunctionObject obj13; int num32 = this.symbol_table[id].Level; ClassObject obj12 = this.GetClassObject(num32); id = obj12.FindConstructorId(a, param_mod, out obj13); this.r.res = 0; if (id == 0) { this.scripter.CreateErrorObjectEx("CS0143. The type '{0}' has no constructors defined.", new object[] { obj12.Name }); } goto Label_17D6; } case MemberKind.Destructor: { int num33 = this.symbol_table[id].Level; ClassObject obj14 = this.GetClassObject(num33); id = obj14.FindDestructorId(a); this.r.res = 0; if (id != 0) { goto Label_17D6; } this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { obj14.Name, "~" + obj14.Name }); return; } } if (kind != MemberKind.Ref) { switch (kind) { case MemberKind.Var: case MemberKind.Index: { int num55 = this.symbol_table[this.r.arg1].TypeId; ClassObject obj20 = this.GetClassObject(num55); if (((kind == MemberKind.Var) && (obj20.IsArray || obj20.IsPascalArray)) && this.PascalOrBasic(this.n)) { this.ConvertCallToIndexAccess(a, pos); return; } if (((kind == MemberKind.Var) && (obj20.DefaultProperty != null)) && this.PascalOrBasic(this.n)) { this.ConvertToDefaultPropertyCall(obj20.DefaultProperty, a, pos); return; } if ((kind == MemberKind.Property) && this.PascalOrBasic(this.n)) { this.ConvertToPropertyCall(a, pos); return; } if (!obj20.IsDelegate) { if (this.PascalOrBasic(this.n)) { this.ConvertCallToIndexAccess(a, pos); } else { string str9 = this.symbol_table[this.r.arg1].Name; this.scripter.CreateErrorObjectEx("CS0118. '{0}' denotes a '{1}' where a '{2}' was expected.", new object[] { str9, "variable", "method" }); } return; } if (this.PascalOrBasic(this.n)) { this[this.n - 1].arg1 = this.r.arg1; } id = obj20.PatternMethod.Id; goto Label_17D6; } } int num56 = this.symbol_table[this.r.arg1].TypeId; ClassObject obj21 = this.GetClassObject(num56); if (((kind == MemberKind.Field) && (obj21.IsArray || obj21.IsPascalArray)) && this.PascalOrBasic(this.n)) { this.ConvertCallToIndexAccess(a, pos); return; } if (((kind == MemberKind.Field) && (obj21.DefaultProperty != null)) && this.PascalOrBasic(this.n)) { this.ConvertToDefaultPropertyCall(obj21.DefaultProperty, a, pos); return; } if ((kind == MemberKind.Property) && this.PascalOrBasic(this.n)) { this.ConvertToPropertyCall(a, pos); return; } if (!obj21.IsDelegate) { string str10 = this.symbol_table[this.r.arg1].Name; this.scripter.CreateErrorObjectEx("CS0118. '{0}' denotes a '{1}' where a '{2}' was expected.", new object[] { str10, "variable", "method" }); return; } if ((kind == MemberKind.Field) && (obj21.ImportedType != null)) { int num57 = this.symbol_table[this.r.arg1].Level; if ((this.symbol_table[num57].Kind == MemberKind.Type) && (this.GetClassObject(num57).ImportedType != null)) { this.r.op = this.OP_DYNAMIC_INVOKE; return; } } this[this.n - 1].arg1 = this.r.arg1; id = obj21.PatternMethod.Id; } else { FunctionObject obj16; int num34 = this.symbol_table[id].Level; num35 = this[this.n - 1].arg1; this[this.n - 1].arg1 = num34; int num36 = this.symbol_table[id].NameIndex; string str6 = this.symbol_table[id].Name; int num37 = this.symbol_table[num34].TypeId; if (this.symbol_table[num37].Kind != MemberKind.Type) { string str7 = this.symbol_table[num37].Name; this.scripter.CreateErrorObjectEx("CS0246. The type or namespace name '{0}' could not be found (are you missing a using directive or an assembly reference?).", new object[] { str7 }); return; } ClassObject obj15 = this.GetClassObjectEx(num37); bool flag5 = this.GetUpcase(this.n); id = obj15.FindMethodId(num36, a, param_mod, 0, out obj16, flag5); if (id == 0) { if (obj16 == null) { int num51 = this.symbol_table[this.r.arg1].TypeId; if (this.symbol_table[num51].Kind != MemberKind.Type) { this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { obj15.Name, str6 }); return; } ClassObject obj18 = this.GetClassObject(num51); if ((obj18.IsArray || obj18.IsPascalArray) && this.PascalOrBasic(this.n)) { this.ConvertCallToIndexAccess(a, pos); return; } if ((obj18.DefaultProperty != null) && this.PascalOrBasic(this.n)) { this.ConvertToDefaultPropertyCall(obj18.DefaultProperty, a, pos); return; } if (!obj18.IsDelegate) { if (this.PascalOrBasic(this.n)) { this.ConvertCallToIndexAccess(a, pos); } else { this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { obj15.Name, str6 }); } return; } if (obj18.ImportedType != null) { int num52 = this.symbol_table[this.r.arg1].Level; int num53 = this.symbol_table[num52].TypeId; if (this.GetClassObject(num53).ImportedType != null) { this.r.op = this.OP_DYNAMIC_INVOKE; return; } } id = obj18.PatternMethod.Id; if (!this.PascalOrBasic(this.n)) { this[this.n - 1].arg1 = num35; goto Label_17D6; } int num54 = this.n; flag8 = false; while (true) { num54--; if ((this[num54].op == this.OP_RAISE_EVENT) && (this[num54].arg1 == this.r.arg1)) { flag8 = true; goto Label_143F; } if (num54 == 1) { goto Label_143F; } } } if (obj16.ParamCount != a.Count) { if ((a.Count < obj16.ParamCount) || (obj16.ParamsId == 0)) { if (obj16.Name == "Dispose") { for (int i = 0; i < pos.Count; i++) { this[pos[i]].op = this.OP_NOP; } this[this.n - 1].op = this.OP_NOP; this[this.n].op = this.OP_NOP; } else { this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { str6, a.Count }); } return; } this.InsertActualArray(obj16, curr_level, pos, a); id = obj16.Id; n = this.n; } else { bool flag6 = true; for (int j = 0; j < a.Count; j++) { int num39 = a[j]; int paramId = obj16.GetParamId(j); if (!this.scripter.MatchAssignment(paramId, num39)) { int num41 = this.symbol_table[num39].TypeId; ClassObject obj17 = this.GetClassObject(num41); int num42 = obj17.FindOverloadableImplicitOperatorId(num39, paramId); if (num42 == 0) { flag6 = false; break; } int num43 = this.n; this.n = pos[j]; int currMethodId = this.GetCurrMethodId(); int num45 = this.AppVar(currMethodId, this.symbol_table[paramId].TypeId); int res = this[this.n].res; this[this.n].arg1 = num45; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num39; this[this.n].arg2 = 0; this[this.n].res = num42; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = obj17.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num42; this[this.n].arg2 = 1; this[this.n].res = num45; this.n = num43 + 3; for (int k = j + 1; k < a.Count; k++) { pos[k] += 3; } } } if (!flag6) { if ((obj16.ParamsId == 0) || (a.Count == 0)) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { str6 }); return; } int num48 = a[a.Count - 1]; int num49 = this.symbol_table[num48].TypeId; if (CSLite_System.GetRank(this.symbol_table[num49].Name) != 0) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { str6 }); return; } this.InsertActualArray(obj16, curr_level, pos, a); } id = obj16.Id; n = this.n; } } } goto Label_17D6; } int nameIndex = this.symbol_table[id].NameIndex; string name = this.symbol_table[id].Name; int level = this.symbol_table[id].Level; ClassObject classObject = this.GetClassObject(level); bool upcase = this.GetUpcase(this.n); Label_0646: id = classObject.FindMethodId(nameIndex, a, param_mod, 0, out obj10, upcase); if (id != 0) { goto Label_17D6; } if (obj10 == null) { this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { classObject.Name, name }); } else if (obj10.ParamCount != a.Count) { if (a.Count < obj10.ParamCount) { int num27; int defaultParamCount = obj10.DefaultParamCount; if ((a.Count + defaultParamCount) < obj10.ParamCount) { if (obj10.ParamsId == 0) { if (((a.Count + 1) == obj10.ParamCount) && (this.GetTypeId(obj10.Param_Ids[obj10.ParamCount - 1]) == 0x10)) { int num31; if (pos.Count > 0) { num31 = pos[a.Count - 1] + 1; } else { num31 = this.n - 2; } this.InsertOperators(num31, 1); this[num31].op = this.OP_PUSH; this[num31].arg1 = this.symbol_table.NULL_id; this[num31].arg2 = 0; this[num31].res = 0; this.n++; id = obj10.Id; goto Label_0C98; } this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { name, a.Count }); } else { if ((a.Count + 1) == obj10.ParamCount) { this.InsertActualArray(obj10, curr_level, pos, a); id = obj10.Id; n = this.n; goto Label_0C98; } this.scripter.CreateErrorObjectEx("CS1501. No overload for method '{0}' takes '{1}' arguments.", new object[] { name, a.Count }); } return; } int number = obj10.ParamCount - a.Count; if (pos.Count > 0) { num27 = pos[a.Count - 1] + 1; } else { num27 = this.n - 2; } ProgRec rec1 = this[this.n]; rec1.arg2 += number; this.InsertOperators(num27, number); int num28 = obj10.ParamCount - number; for (int m = 0; m < number; m++) { int num30 = obj10.Default_Ids[num28]; a.Add(num30); pos.Add(num27); param_mod.Add(obj10.Param_Mod[num28]); this[num27].op = this.OP_PUSH; this[num27].arg1 = num30; this[num27].arg2 = 0; this[num27].res = obj10.Id; num27++; this.n++; num28++; } this.r = this[this.n]; n = this.n; goto Label_0646; } this.InsertActualArray(obj10, curr_level, pos, a); id = obj10.Id; n = this.n; } else { bool flag3 = true; for (int num13 = 0; num13 < a.Count; num13++) { int num14 = a[num13]; int num15 = obj10.GetParamId(num13); if (!this.scripter.MatchAssignment(num15, num14)) { int num16 = this.symbol_table[num14].TypeId; ClassObject obj11 = this.GetClassObject(num16); int num17 = obj11.FindOverloadableImplicitOperatorId(num14, num15); if (num17 == 0) { flag3 = false; break; } int num18 = this.n; this.n = pos[num13]; int num19 = this.GetCurrMethodId(); int num20 = this.AppVar(num19, this.symbol_table[num15].TypeId); int num21 = this[this.n].res; this[this.n].arg1 = num20; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num14; this[this.n].arg2 = 0; this[this.n].res = num17; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = obj11.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num17; this[this.n].arg2 = 1; this[this.n].res = num20; this.n = num18 + 3; for (int num22 = num13 + 1; num22 < a.Count; num22++) { pos[num22] += 3; } } } if (flag3) { id = obj10.Id; n = this.n; goto Label_17D6; } if ((obj10.ParamsId == 0) || (a.Count == 0)) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { name }); return; } int num23 = a[a.Count - 1]; int num24 = this.symbol_table[num23].TypeId; if (CSLite_System.GetRank(this.symbol_table[num24].Name) != 0) { this.scripter.CreateErrorObjectEx("CS1502. The best overloaded method match for '{0}' has some invalid arguments.", new object[] { name }); return; } this.InsertActualArray(obj10, curr_level, pos, a); id = obj10.Id; n = this.n; } Label_0C98: if (id != 0) { goto Label_17D6; } return; Label_143F: if (flag8) { this[this.n - 1].arg1 = num35; } else { this[this.n - 1].arg1 = this.r.arg1; } Label_17D6: this.r.arg1 = id; for (avalue = 0; avalue < pos.Count; avalue++) { this[pos[avalue]].res = id; } int typeId = this.symbol_table[this.r.arg1].TypeId; if (typeId == 1) { this.r.res = 0; } else if (this.symbol_table[this.r.arg1].Name != "get_Current") { this.symbol_table[this.r.res].TypeId = typeId; } bool flag9 = false; string str11 = ""; string str12 = ""; FunctionObject functionObject = this.GetFunctionObject(id); if (functionObject.Static) { int num59 = this.symbol_table[id].Level; this[n - 1].arg1 = num59; } if (!functionObject.Imported && (a.Count > 0)) { avalue = 0; while (avalue < functionObject.ParamCount) { ParamMod paramMod = functionObject.GetParamMod(avalue); ParamMod mod2 = (ParamMod) param_mod[avalue]; if (paramMod != mod2) { int num60 = functionObject.GetParamId(avalue); int num61 = this[this.n].arg1; int num62 = this.symbol_table[num60].TypeId; int num63 = this.symbol_table[num61].TypeId; str11 = this.symbol_table[num62].Name; str12 = this.symbol_table[num63].Name; switch (paramMod) { case ParamMod.RetVal: str11 = "ref " + str11; break; case ParamMod.Out: str11 = "out " + str11; break; } if (mod2 == ParamMod.RetVal) { str12 = "ref " + str12; } else if (mod2 == ParamMod.Out) { str12 = "out " + str12; } flag9 = true; if (flag9 && this.PascalOrBasic(this.n)) { flag9 = false; if (paramMod == ParamMod.RetVal) { param_mod[avalue] = (int) paramMod; num3++; } } else { this.n = pos[avalue]; break; } } avalue++; } } if (flag9) { this.scripter.CreateErrorObjectEx("CS1503. Argument '{0}': cannot convert from '{1}' to '{2}'.", new object[] { avalue + 1, str12, str11 }); } else if ((num3 > 0) && (a.Count > 0)) { this.InsertOperators(this.n + 1, num3 * 2); for (avalue = 0; avalue < functionObject.ParamCount; avalue++) { int num64 = functionObject.GetParamId(avalue); if (param_mod[avalue] != 0) { int num65 = this.AppVar(this.symbol_table[id].Level, this.symbol_table[num64].TypeId); this.n++; this[this.n].op = this.OP_GET_PARAM_VALUE; this[this.n].arg1 = id; this[this.n].arg2 = avalue; this[this.n].res = num65; this.n++; this[this.n].op = this.OP_ASSIGN; this[this.n].arg1 = a[avalue]; this[this.n].arg2 = num65; this[this.n].res = a[avalue]; } } } }
private string Parse_ArrayNameModifier(IntegerList bounds) { string str = ""; this.Match('('); str = str + "["; if (!base.IsCurrText(')')) { while (true) { if (!base.IsCurrText(',')) { int avalue = this.Parse_Expression(); bounds.Add(avalue); } if (!base.CondMatch(',')) { break; } str = str + ","; } } this.Match(')'); return (str + "]"); }
internal int GetEntryId() { IntegerList list = new IntegerList(false); for (int i = 0; i < this.symbol_table.Card; i++) { if ((this.symbol_table[i].Kind == MemberKind.Method) && (this.symbol_table[i].Name == "Main")) { for (int j = 1; j < this.code.Card; j++) { if ((this.code[j].op == this.code.OP_CREATE_METHOD) && (this.code[j].arg1 == i)) { for (int k = j + 1; this.code[k].op == this.code.OP_ADD_MODIFIER; k++) { if (this.code[k].arg2 == 7) { list.Add(i); break; } } } } } } if (list.Count == 0) { return 0; } if (list.Count == 1) { return list[0]; } return -1; }
private void Parse_NamespaceDeclaration() { this.Match("Namespace"); IntegerList list = new IntegerList(false); do { int avalue = this.Parse_Ident(); list.Add(avalue); base.BeginNamespace(avalue); } while (base.CondMatch('.')); Label_003A: this.Parse_NamespaceMemberDeclaration(); if (!base.IsCurrText("End")) { if (base.IsEOF()) { this.Match("End"); } goto Label_003A; } for (int i = list.Count - 1; i >= 0; i--) { base.EndNamespace(list[i]); } this.Match("End"); this.Match("Namespace"); this.MatchLineTerminator(); }
internal void AddApplicableMethod(FunctionObject f, IntegerList a, IntegerList param_mod, int res_id, ref FunctionObject best, ref IntegerList applicable_list) { if (best == null) { best = f; } if (((f.ParamCount <= a.Count) && ((f.ParamCount >= a.Count) || (f.ParamsId != 0))) && ((res_id == 0) || base.Scripter.MatchAssignment(f.ResultId, res_id))) { best = f; if (f.ParamCount == 0) { applicable_list.Add(f.Id); } else { bool flag = true; for (int i = 0; i < a.Count; i++) { int num2 = a[i]; int paramId = f.GetParamId(i); flag = ((int)f.GetParamMod(i) == param_mod[i]); if (!flag && !f.Imported) { if (base.Scripter.code.GetLanguage(base.Scripter.code.n) != CSLite_Language.VB) { break; } flag = true; } flag = base.Scripter.MatchAssignment(paramId, num2); if (!flag) { if (base.Scripter.code.GetLanguage(base.Scripter.code.n) == CSLite_Language.VB) { int typeId = base.Scripter.symbol_table[paramId].TypeId; int id = base.Scripter.symbol_table[num2].TypeId; ClassObject classObject = base.Scripter.GetClassObject(typeId); ClassObject obj3 = base.Scripter.GetClassObject(id); flag = base.Scripter.MatchTypes(classObject, obj3); } if (!flag) { break; } } } if (flag) { applicable_list.Add(f.Id); } } } }
private int Parse_FreeArrayInitializer(int array_type_id, ref IntegerList bounds) { int num3; string name = base.GetName(array_type_id); int rank = CSLite_System.GetRank(name); string elementTypeName = CSLite_System.GetElementTypeName(name); IntegerList list = new IntegerList(true); int id = base.NewVar(); base.SetName(id, elementTypeName); this.Gen(base.code.OP_EVAL_TYPE, 0, 0, id); int res = base.NewVar(); this.Gen(base.code.OP_CREATE_OBJECT, array_type_id, 0, res); this.Gen(base.code.OP_BEGIN_CALL, array_type_id, 0, 0); IntegerList list2 = new IntegerList(true); for (int i = 0; i < rank; i++) { num3 = base.NewVar(0); list2.Add(num3); this.Gen(base.code.OP_PUSH, num3, 0, array_type_id); } this.Gen(base.code.OP_PUSH, res, 0, 0); this.Gen(base.code.OP_CALL, array_type_id, rank, 0); int num6 = 0; this.Match('{'); if (!base.IsCurrText('}')) { num6 = 0; do { num6++; int num7 = base.NewVar(); int num8 = base.NewConst(num6 - 1); this.Gen(base.code.OP_CREATE_INDEX_OBJECT, res, 0, num7); this.Gen(base.code.OP_ADD_INDEX, num7, num8, res); this.Gen(base.code.OP_SETUP_INDEX_OBJECT, num7, 0, 0); num3 = base.NewVar(); if (base.IsCurrText('{')) { num3 = this.Parse_FreeArrayInitializer(id, ref list); } else { num3 = this.Parse_Expression(); } this.Gen(base.code.OP_ASSIGN, num7, num3, num7); } while (base.CondMatch(',')); } this.Match('}'); num3 = list2[0]; base.PutVal(num3, num6); bounds.Add(num6); for (int j = 1; j < list2.Count; j++) { num3 = list2[j]; num6 = list[j - 1]; base.PutVal(num3, num6); bounds.Add(num6); } return res; }
internal int FindOverloadableImplicitOperatorId(int actual_id, int res_id) { bool upcase = false; int num = base.Scripter.names.Add("op_Implicit"); IntegerList a = new IntegerList(false); a.Add(actual_id); IntegerList list2 = new IntegerList(false); list2.Add(0); IntegerList list3 = new IntegerList(false); FunctionObject best = null; this.FindApplicableMethodList(num, a, list2, res_id, ref best, ref list3, upcase); this.CompressApplicableMethodList(a, list3); if (list3.Count >= 1) { int id = list3[0]; best = base.Scripter.GetFunctionObject(id); return id; } return 0; }
private void Parse_NamespaceDeclaration() { this.Match("namespace"); IntegerList list = new IntegerList(false); do { int avalue = this.Parse_Ident(); list.Add(avalue); base.BeginNamespace(avalue); } while (base.CondMatch('.')); this.Match('{'); if (base.IsCurrText("using")) { this.Parse_UsingDirectives(); } if (!base.IsCurrText('}')) { this.Parse_NamespaceMemberDeclarations(); } for (int i = list.Count - 1; i >= 0; i--) { base.EndNamespace(list[i]); } this.Match('}'); if (base.IsCurrText(';')) { this.Match(';'); } }
private bool TryOverloadableBinaryOperator(int op, string operator_name, ClassObject c1, ClassObject c2) { int num; foreach (string str in this.scripter.OperatorHelpers.Keys) { ClassObject classObject = null; FunctionObject best = null; int num2 = 0; IntegerList list = new IntegerList(false); IntegerList a = new IntegerList(true); a.Add(this.r.arg1); a.Add(this.r.arg2); a.Add(this.symbol_table.FALSE_id); IntegerList list3 = new IntegerList(true); list3.Add(0); list3.Add(0); list3.Add(0); if (operator_name == str) { MethodInfo info = (MethodInfo) this.scripter.OperatorHelpers[str]; Type reflectedType = info.ReflectedType; int num3 = this.symbol_table.RegisterType(reflectedType, false); int id = this.symbol_table.RegisterMethod(info, num3); classObject = this.scripter.GetClassObject(num3); FunctionObject functionObject = this.scripter.GetFunctionObject(id); classObject.AddApplicableMethod(functionObject, a, list3, num2, ref best, ref list); } num = 0; if (classObject != null) { classObject.CompressApplicableMethodList(a, list); if (list.Count >= 1) { num = list[0]; } } if (num != 0) { this.r.op = this.OP_NOP; int res = this.r.res; this.n++; this.InsertOperators(this.n, 5); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = a[0]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = a[1]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = a[2]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = classObject.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num; this[this.n].arg2 = 2; this[this.n].res = res; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[num].TypeId; return true; } } foreach (string str2 in this.scripter.OperatorHelpers.Keys) { ClassObject obj5 = null; FunctionObject obj6 = null; int num6 = 0; IntegerList list4 = new IntegerList(false); IntegerList list5 = new IntegerList(true); list5.Add(this.r.arg2); list5.Add(this.r.arg1); list5.Add(this.symbol_table.TRUE_id); IntegerList list6 = new IntegerList(true); list6.Add(0); list6.Add(0); list6.Add(0); if (operator_name == str2) { MethodInfo info2 = (MethodInfo) this.scripter.OperatorHelpers[str2]; Type t = info2.ReflectedType; int num7 = this.symbol_table.RegisterType(t, false); int num8 = this.symbol_table.RegisterMethod(info2, num7); obj5 = this.scripter.GetClassObject(num7); FunctionObject f = this.scripter.GetFunctionObject(num8); obj5.AddApplicableMethod(f, list5, list6, num6, ref obj6, ref list4); } num = 0; if (obj5 != null) { obj5.CompressApplicableMethodList(list5, list4); if (list4.Count >= 1) { num = list4[0]; } } if (num != 0) { this.r.op = this.OP_NOP; int num9 = this.r.res; this.n++; this.InsertOperators(this.n, 5); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = list5[0]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = list5[1]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = list5[2]; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = obj5.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num; this[this.n].arg2 = 2; this[this.n].res = num9; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[num].TypeId; return true; } } num = c1.FindOverloadableBinaryOperatorId(operator_name, this.r.arg1, this.r.arg2); if (num != 0) { this.r.op = this.OP_NOP; int num10 = this.r.res; this.n++; this.InsertOperators(this.n, 4); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg1; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg2; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = c1.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num; this[this.n].arg2 = 2; this[this.n].res = num10; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[num].TypeId; return true; } num = c2.FindOverloadableBinaryOperatorId(operator_name, this.r.arg2, this.r.arg1); if (num != 0) { this.r.op = this.OP_SWAPPED_ARGUMENTS; int num11 = this.r.res; this.n++; this.InsertOperators(this.n, 5); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg2; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg1; this[this.n].arg2 = 0; this[this.n].res = num; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = c1.Id; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL_SIMPLE; this[this.n].arg1 = num; this[this.n].arg2 = 2; this[this.n].res = num11; this.symbol_table[this[this.n].res].TypeId = this.symbol_table[num].TypeId; this.r.arg1 = this.symbol_table.TRUE_id; this.n++; this[this.n].op = this.OP_SWAPPED_ARGUMENTS; this[this.n].arg1 = this.symbol_table.FALSE_id; this[this.n].arg2 = 0; this[this.n].res = 0; return true; } return false; }