private void CheckOP_PLUS() { int op = this.r.op; int typeId = this.symbol_table[this.r.arg1].TypeId; int id = this.symbol_table[this.r.arg2].TypeId; ClassObject classObject = this.GetClassObject(typeId); ClassObject obj3 = this.GetClassObject(id); if (classObject.IsDelegate) { if (typeId == id) { this.r.op = this.OP_ADD_DELEGATES; this.symbol_table[this.r.res].TypeId = typeId; } else { this.scripter.CreateErrorObjectEx("CS0019. Operator '{0}' cannot be applied to operands of type '{1}' and '{2}'.", new object[] { "+", classObject.Name, obj3.Name }); } } else if (this.SetupDetailedBinaryOperator(op, "+", this.detailed_addition_operators)) { if (this.r.op == this.OP_ADDITION_STRING) { if (classObject.Id != 12) { FunctionObject obj4; int num4 = this.AppVar(this.symbol_table[this.r.arg1].Level, 12); bool upcase = this.GetUpcase(); int num5 = classObject.FindMethodId("ToString", null, null, 0, out obj4, upcase); if (num5 == 0) { this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { classObject.Name, "ToString" }); return; } this.InsertOperators(this.n, 2); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg1; this[this.n].arg2 = 0; this[this.n].arg2 = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num5; this[this.n].arg2 = 0; this[this.n].res = num4; this.r.arg1 = num4; } if (obj3.Id != 12) { FunctionObject obj5; int num6 = this.AppVar(this.symbol_table[this.r.arg2].Level, 12); bool flag2 = this.GetUpcase(); int num7 = obj3.FindMethodId("ToString", null, null, 0, out obj5, flag2); if (num7 == 0) { if (obj3.IsEnum) { num7 = obj3.UnderlyingType.FindMethodId("ToString", null, null, 0, out obj5, flag2); } if (num7 == 0) { this.scripter.CreateErrorObjectEx("CS0117. '{0}' does not contain a definition for '{1}'.", new object[] { obj3.Name, "ToString" }); return; } } this.InsertOperators(this.n, 2); this[this.n].op = this.OP_PUSH; this[this.n].arg1 = this.r.arg2; this[this.n].arg2 = 0; this[this.n].arg2 = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num7; this[this.n].arg2 = 0; this[this.n].res = num6; this.r.arg2 = num6; } } else if (this[this.n].op != this.OP_CALL_SIMPLE) { this.r = this[this.n]; typeId = this.GetTypeId(this.r.arg1); id = this.GetTypeId(this.r.arg2); int num8 = this.GetTypeId(this.r.res); if ((typeId != num8) && IsNumericTypeId(num8)) { this.InsertNumericConversion(num8, 1); } if ((id != num8) && IsNumericTypeId(num8)) { this.InsertNumericConversion(num8, 2); } } } }
private void CheckOP_RIGHT_SHIFT() { int op = this.r.op; if (this.SetupDetailedBinaryOperator(op, ">>", this.detailed_right_shift_operators) && (this[this.n].op != this.OP_CALL_SIMPLE)) { this.r = this[this.n]; int typeId = this.GetTypeId(this.r.arg1); int num3 = this.GetTypeId(this.r.arg2); int id = this.GetTypeId(this.r.res); if ((typeId != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 1); } if ((num3 != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 2); } } }
private void CheckOP_DIV() { int op = this.r.op; if (this.SetupDetailedBinaryOperator(op, "/", this.detailed_division_operators)) { if (this.symbol_table[this.r.res].TypeId == 0) { this.symbol_table[this.r.res].TypeId = this.symbol_table[this.r.arg1].TypeId; } if (this[this.n].op != this.OP_CALL_SIMPLE) { this.r = this[this.n]; int typeId = this.GetTypeId(this.r.arg1); int num3 = this.GetTypeId(this.r.arg2); int id = this.GetTypeId(this.r.res); if ((typeId != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 1); } if ((num3 != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 2); } } } }
private void CheckOP_MINUS() { int op = this.r.op; int typeId = this.symbol_table[this.r.arg1].TypeId; int id = this.symbol_table[this.r.arg2].TypeId; ClassObject classObject = this.GetClassObject(typeId); ClassObject obj3 = this.GetClassObject(id); if (classObject.IsDelegate) { if (typeId == id) { this.r.op = this.OP_SUB_DELEGATES; this.symbol_table[this.r.res].TypeId = typeId; } else { this.scripter.CreateErrorObjectEx("CS0019. Operator '{0}' cannot be applied to operands of type '{1}' and '{2}'.", new object[] { "-", classObject.Name, obj3.Name }); } } else if (this.SetupDetailedBinaryOperator(op, "-", this.detailed_subtraction_operators) && (this[this.n].op != this.OP_CALL_SIMPLE)) { this.r = this[this.n]; typeId = this.GetTypeId(this.r.arg1); id = this.GetTypeId(this.r.arg2); int num4 = this.GetTypeId(this.r.res); if ((typeId != num4) && IsNumericTypeId(num4)) { this.InsertNumericConversion(num4, 1); } if ((id != num4) && IsNumericTypeId(num4)) { this.InsertNumericConversion(num4, 2); } } }
public void AdjustCallsEx(int init_n) { if (this.scripter.IsError()) { return; } for (int i = init_n + 1; i <= this.symbol_table.Card; i++) { switch (this.symbol_table[i].Kind) { case MemberKind.Method: case MemberKind.Constructor: case MemberKind.Destructor: this.GetFunctionObject(i).CreateSignature(); break; } } this.n = init_n; Label_0062: this.n++; if (this.n < this.Card) { if (this[this.n].op == this.OP_CALL_SIMPLE) { this[this.n].op = this.OP_CALL; } if (this[this.n].op != this.OP_CALL) { goto Label_0062; } int id = this[this.n].arg1; if (this.symbol_table[id].Kind != MemberKind.Method) { goto Label_0062; } FunctionObject functionObject = this.GetFunctionObject(id); if ((functionObject.HasModifier(Modifier.Virtual) || functionObject.HasModifier(Modifier.Override)) || functionObject.HasModifier(Modifier.Abstract)) { this[this.n].op = this.OP_CALL_VIRT; } if (functionObject.ParamCount != 1) { goto Label_0062; } if ((functionObject.Imported && (functionObject.Name.Length > 4)) && (functionObject.Name.Substring(0, 4) == "add_")) { int typeId = this.symbol_table[functionObject.Param_Ids[0]].TypeId; ClassObject classObject = this.GetClassObject(typeId); if (classObject.IsDelegate) { string name = functionObject.Name.Substring(4); EventInfo e = functionObject.Owner.ImportedType.GetEvent(name); FunctionObject patternMethod = classObject.PatternMethod; if ((e != null) && (patternMethod != null)) { this.scripter.DefineEventHandler(e, patternMethod); this[this.n].op = this.OP_CALL_ADD_EVENT; } } goto Label_0062; } if (functionObject.GetParamTypeId(0) != 0x10) { goto Label_0062; } string fullName = functionObject.FullName; if (!(fullName == "System.Console.Write") && !(fullName == "System.Console.WriteLine")) { goto Label_0062; } int n = this.n; do { n--; if ((this[n].op == this.OP_PUSH) && (this[n].res == functionObject.Id)) { FunctionObject obj7; this.r = this[n]; int num5 = this.GetTypeId(this.r.arg1); ClassObject obj6 = this.GetClassObject(num5); bool upcase = this.GetUpcase(this.n); id = obj6.FindMethodId("ToString", null, null, 0, out obj7, upcase); if (id > 0) { int num6 = this.AppVar(this.symbol_table[this.r.arg1].Level, 12); this.InsertOperators(n, 2); this[n].op = this.OP_PUSH; this[n].arg1 = this.r.arg1; this[n].arg2 = 0; this[n].arg2 = 0; n++; this[n].op = this.OP_CALL; this[n].arg1 = id; this[n].arg2 = 0; this[n].res = num6; this.r.arg1 = num6; this.n++; this.n++; } goto Label_0062; } } while (n != 0); this.scripter.CreateErrorObject("CS0001. Internal compiler error."); } }
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]; } } } }
public void Run(RunMode run_mode) { this.Terminated = false; this.Paused = false; this.n++; if (!this.debugging || ((run_mode == RunMode.Run) && (this.breakpoint_list.Count == 0))) { Label_0363: if (!this.scripter.TerminatedFlag) { if (this.scripter.Owner.rh != null) { this.scripter.Owner.rh(this.scripter.Owner); } try { this.r = (ProgRec) this.prog[this.n]; Oper oper2 = (Oper) this.arrProc[-this.r.op]; if (this.Checked) { oper2(); } else { oper2(); } } catch (Exception innerException) { this.scripter.Error_List.Add(new ScriptError(this.scripter, innerException.Message)); this.scripter.LastError.E = innerException; if (innerException.InnerException != null) { innerException = innerException.InnerException; if (innerException != null) { this.scripter.Error_List.Add(new ScriptError(this.scripter, innerException.Message)); this.scripter.LastError.E = innerException; } } this.RaiseError(); } if (!this.Terminated) { goto Label_0363; } } return; } int num = this.NextLine(); int count = this.stack.Count; int currSubId = this.callstack.CurrSubId; this.breakpoint_list.Activate(); Label_006C: if (this.scripter.TerminatedFlag) { return; } Label_0083: this.r = (ProgRec) this.prog[this.n]; if (this.r.op != this.OP_SEPARATOR) { if (this.scripter.Owner.rh != null) { this.scripter.Owner.rh(this.scripter.Owner); } try { this.r = (ProgRec) this.prog[this.n]; Oper oper = (Oper) this.arrProc[-this.r.op]; if (this.Checked) { oper(); } else { oper(); } } catch (Exception exception) { this.scripter.Error_List.Add(new ScriptError(this.scripter, exception.Message)); this.scripter.LastError.E = exception; if (exception.InnerException != null) { exception = exception.InnerException; if (exception != null) { this.scripter.Error_List.Add(new ScriptError(this.scripter, exception.Message)); this.scripter.LastError.E = exception; } } this.RaiseError(); } if (this.Terminated) { return; } goto Label_006C; } if (this.HasBreakpoint(this.n)) { this.Paused = true; } else { switch (run_mode) { case RunMode.Run: this.n++; goto Label_0083; case RunMode.TraceInto: while (this[this.n + 1].op == this.OP_SEPARATOR) { this.n++; } this.Paused = true; break; case RunMode.StepOver: if (this.stack.Count > count) { this.n++; goto Label_0083; } while (this[this.n + 1].op == this.OP_SEPARATOR) { this.n++; } this.Paused = true; break; case RunMode.NextLine: if (this.n != num) { this.n++; goto Label_0083; } while (this[this.n + 1].op == this.OP_SEPARATOR) { this.n++; } this.Paused = true; break; case RunMode.UntilReturn: if (this.callstack.HasSubId(currSubId)) { this.n++; goto Label_0083; } while (this[this.n + 1].op == this.OP_SEPARATOR) { this.n++; } this.Paused = true; break; default: goto Label_0083; } } }
private void OperGotoContinue() { if (this.goto_line == 0) { this.n++; return; } Label_0020: this.r = (ProgRec) this.prog[this.n]; int op = this.r.op; if (this.n == this.goto_line) { this.goto_line = 0; } else { if (op == this.OP_FINALLY) { if (this.try_stack.Legal(this.n)) { return; } } else { if ((op == this.OP_RET) || (op == this.OP_HALT)) { if (this.goto_line > 0) { this.n = this.goto_line; this.goto_line = 0; } return; } this.n++; } goto Label_0020; } }
public void ProcessEvalType(IntegerStack l) { bool upcase = this.GetUpcase(); int nameIndex = this.symbol_table[this.r.res].NameIndex; string name = this.symbol_table[this.r.res].Name; if (this.scripter.IsStandardType(this.r.res)) { if (this.NextInstruction(this.n).op == this.OP_CREATE_TYPE_REFERENCE) { name = name + "." + this.symbol_table[this.NextInstruction(this.n).res].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[] { name }); } else { this.r.op = this.OP_NOP; } return; } MemberObject memberByNameIndex = null; for (int i = l.Count - 1; i >= 0; i--) { MemberObject memberObject = this.GetMemberObject(l[i]); if (memberObject.Kind == MemberKind.Type) { if (memberObject.NameIndex == nameIndex) { memberByNameIndex = memberObject; break; } memberByNameIndex = memberObject.GetMemberByNameIndex(nameIndex, upcase); if (memberByNameIndex != null) { if (memberByNameIndex.Kind == MemberKind.Alias) { int id = memberByNameIndex.Id; while (this.symbol_table[id].Kind == MemberKind.Alias) { memberByNameIndex = this.GetMemberObject(id); id = this[memberByNameIndex.PCodeLine].res; } memberByNameIndex = this.GetMemberObject(id); nameIndex = memberByNameIndex.NameIndex; } if ((memberByNameIndex.Kind == MemberKind.Type) && ((memberByNameIndex.NameIndex == nameIndex) || (upcase && (memberByNameIndex != null)))) { break; } } } } if (memberByNameIndex == null) { int startIndex = CSLite_System.PosCh('[', name); if (startIndex > 0) { if (this.GetClassObject(this.r.arg1).Imported) { memberByNameIndex = this.FindType(l, name, upcase); } if (memberByNameIndex == null) { string str2 = "Object" + name.Substring(startIndex); memberByNameIndex = this.FindType(l, str2, upcase); if (memberByNameIndex != null) { int num5 = this.symbol_table.AppVar(); this.symbol_table[num5].Name = name; this.symbol_table[num5].Kind = MemberKind.Type; int num6 = 0; ClassObject obj5 = new ClassObject(this.scripter, num5, num6, ClassKind.Array); obj5.Imported = true; obj5.ImportedType = (memberByNameIndex as ClassObject).ImportedType; obj5.RType = (memberByNameIndex as ClassObject).ImportedType; this.PutVal(num5, obj5); this.GetClassObject(num6).AddMember(obj5); memberByNameIndex = obj5; } } } } if (memberByNameIndex == null) { memberByNameIndex = this.FindType(l, name, upcase); } if (memberByNameIndex == 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[] { name }); return; } this.r.op = this.OP_NOP; Label_02F4: this.n++; ProgRec rec = (ProgRec) this.prog[this.n]; if (rec.op == this.OP_SEPARATOR) { goto Label_02F4; } if (rec.op == this.OP_CREATE_TYPE_REFERENCE) { this.r.op = this.OP_NOP; this.r = (ProgRec) this.prog[this.n]; MemberObject obj7 = this.GetMemberObject(memberByNameIndex.Id); if (obj7.Kind != MemberKind.Type) { 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[] { name }); } else { nameIndex = this.symbol_table[this.r.res].NameIndex; memberByNameIndex = obj7.GetMemberByNameIndex(nameIndex, upcase); if (memberByNameIndex != null) { goto Label_02F4; } name = this.symbol_table[this.r.res].FullName; if (memberByNameIndex == null) { memberByNameIndex = this.FindType(l, name, upcase); } if (memberByNameIndex != null) { goto Label_02F4; } 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[] { name }); } } if (memberByNameIndex != null) { this.scripter.CheckForbiddenType(memberByNameIndex.Id); } this.r.op = this.OP_NOP; if (!this.scripter.IsError()) { this.ReplaceIdEx(this.r.res, memberByNameIndex.Id, this.n, true); } }
public void RemoveEvalOpEx(int init_n, IntegerStack init_l) { if (!this.scripter.IsError()) { IntegerStack stack; if (init_l == null) { stack = new IntegerStack(); } else { stack = init_l.Clone(); } for (int i = init_n + 1; i <= this.Card; i++) { bool flag; this.r = (ProgRec) this.prog[i]; int op = this.r.op; this.n = i; if (op == this.OP_CREATE_METHOD) { stack.Push(this.r.arg1); int id = this.r.arg1; int num4 = this.r.arg2; MemberObject memberObject = this.GetMemberObject(id); flag = memberObject.HasModifier(Modifier.New); bool upcase = this.GetUpcase(this.n); ClassObject classObject = this.GetClassObject(num4); for (int j = 0; j < classObject.AncestorIds.Count; j++) { ClassObject obj4 = this.GetClassObject(classObject.AncestorIds[j]); MemberObject memberByNameIndex = obj4.GetMemberByNameIndex(memberObject.NameIndex, upcase); if (memberByNameIndex != null) { if ((!flag && !obj4.IsInterface) && (((!memberObject.HasModifier(Modifier.Override) || !memberByNameIndex.HasModifier(Modifier.Virtual)) && !memberObject.HasModifier(Modifier.Override)) && !memberObject.HasModifier(Modifier.Shadows))) { this.scripter.CreateWarningObjectEx("CS0108. The keyword new is required on '{0}' because it hides inherited member '{1}'", new object[] { memberObject.FullName, obj4.FullName + "." + memberObject.Name }); } } else if (flag) { this.scripter.CreateWarningObjectEx("CS0109. The member '{0}' does not hide an inherited member. The new keyword is not required.", new object[] { memberObject.FullName }); } } } else if (op == this.OP_RET) { stack.Pop(); } else if (op == this.OP_BEGIN_USING) { int res = this.r.arg1; while (this.symbol_table[res].Kind == MemberKind.Alias) { MemberObject obj6 = this.GetMemberObject(res); res = this[obj6.PCodeLine].res; } string fullName = this.symbol_table[res].FullName; if (this.scripter.CheckForbiddenNamespace(fullName)) { this.scripter.CreateErrorObjectEx("CSLite0006. Use of forbidden namespace '{0}'.", new object[] { fullName }); } stack.Push(res); } else if (op == this.OP_END_USING) { stack.Pop(); } else if (op == this.OP_ADD_ANCESTOR) { this.ProcessAddAncestor(); if (this.scripter.IsError()) { break; } } else if (((op == this.OP_CREATE_FIELD) || (op == this.OP_CREATE_EVENT)) || (op == this.OP_CREATE_PROPERTY)) { int num7 = this.r.arg1; int num8 = this.r.arg2; MemberObject obj7 = this.GetMemberObject(num7); flag = obj7.HasModifier(Modifier.New); ClassObject obj8 = this.GetClassObject(num8); bool flag4 = this.GetUpcase(this.n); for (int k = 0; k < obj8.AncestorIds.Count; k++) { ClassObject obj9 = this.GetClassObject(obj8.AncestorIds[k]); if (obj9.GetMemberByNameIndex(obj7.NameIndex, flag4) != null) { if (!(((flag || obj9.IsInterface) || obj7.HasModifier(Modifier.Override)) || obj7.HasModifier(Modifier.Shadows))) { this.scripter.CreateWarningObjectEx("CS0108. The keyword new is required on '{0}' because it hides inherited member '{1}'", new object[] { obj7.FullName, obj9.FullName + "." + obj7.Name }); } } else if (flag) { this.scripter.CreateWarningObjectEx("CS0109. The member '{0}' does not hide an inherited member. The new keyword is not required.", new object[] { obj7.FullName }); } } } else if (op == this.OP_EVAL_TYPE) { this.ProcessEvalType(stack); if (this.scripter.IsError()) { break; } } else if (op == this.OP_ADD_UNDERLYING_TYPE) { int num10 = this.r.arg1; int num11 = this.r.arg2; ClassObject obj10 = this.GetClassObject(num10); ClassObject obj11 = this.GetClassObject(num11); obj10.UnderlyingType = obj11; } else if (op == this.OP_EVAL) { if ((this[this.n + 1].op == this.OP_EVAL_TYPE) && (this[this.n + 1].res == this.r.res)) { this.r.op = this.OP_NOP; } else { this.ProcessEvalOp(stack); if (this.scripter.IsError()) { break; } } } } if (!this.scripter.IsError()) { for (int m = init_n + 1; m <= this.Card; m++) { this.r = (ProgRec) this.prog[m]; int num13 = this.r.op; this.n = m; if (num13 == this.OP_EVAL_BASE_TYPE) { ClassObject obj12 = this.GetClassObject(this.r.arg1); ClassObject ancestorClass = obj12.AncestorClass; if (ancestorClass == null) { int num14 = 0x10; ancestorClass = this.GetClassObject(num14); obj12.AncestorIds.Add(num14); } this.ReplaceId(this.r.res, ancestorClass.Id); if (this.r.arg2 != 0) { FunctionObject obj14; int num15 = ancestorClass.FindConstructorId(null, null, out obj14); if (num15 != 0) { this.ReplaceId(this.r.arg2, num15); } } this.r.op = this.OP_NOP; } else if (num13 == this.OP_CAST) { this.symbol_table[this.r.res].TypeId = this.r.arg1; } else if (num13 == this.OP_ASSIGN_NAME) { this.symbol_table[this.r.res].NameIndex = this.symbol_table[this.r.arg2].NameIndex; } } } } }
public void LoadFromStream(BinaryReader br, Module m, int ds, int dp) { bool flag = (ds != 0) || (dp != 0); for (int i = m.P1; i <= m.P2; i++) { this.Card++; this.r = this[this.Card]; this.r.LoadFromStream(br); if ((this.r.op != this.OP_SEPARATOR) && flag) { if (m.IsInternalId(this.r.arg1)) { this.r.arg1 += ds; } if (m.IsInternalId(this.r.arg2)) { this.r.arg2 += ds; } if (m.IsInternalId(this.r.res)) { this.r.res += ds; } } } }
public void CreateClassObjects() { for (int i = 1; i <= this.Card; i++) { this.r = (ProgRec) this.prog[i]; int op = this.r.op; this.n = i; if (op == this.OP_CREATE_NAMESPACE) { this.OperCreateNamespace(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_CREATE_USING_ALIAS) { this.OperCreateUsingAlias(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_CREATE_CLASS) { this.OperCreateClass(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_CREATE_FIELD) { this.OperCreateField(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_CREATE_PROPERTY) { this.OperCreateProperty(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_CREATE_EVENT) { this.OperCreateEvent(); if (!this.scripter.IsError()) { continue; } break; } if (op == this.OP_ADD_EVENT_FIELD) { this.OperAddEventField(); } else if (op == this.OP_ADD_READ_ACCESSOR) { this.OperAddReadAccessor(); } else if (op == this.OP_ADD_WRITE_ACCESSOR) { this.OperAddWriteAccessor(); } else if (op == this.OP_SET_DEFAULT) { this.OperSetDefault(); } else if (op == this.OP_ADD_ADD_ACCESSOR) { this.OperAddAddAccessor(); } else if (op == this.OP_ADD_REMOVE_ACCESSOR) { this.OperAddRemoveAccessor(); } else if (op == this.OP_ADD_MIN_VALUE) { this.OperAddMinValue(); } else if (op == this.OP_ADD_MAX_VALUE) { this.OperAddMaxValue(); } else if (op == this.OP_CREATE_METHOD) { this.OperCreateMethod(); } else if (op == this.OP_ADD_PATTERN) { this.OperAddPattern(); } else if (op == this.OP_ADD_PARAM) { this.OperAddParam(); } else if (op == this.OP_ADD_PARAMS) { this.OperAddParams(); } else if (op == this.OP_ADD_DEFAULT_VALUE) { this.OperAddDefaultValue(); } else if (op == this.OP_INIT_METHOD) { this.OperInitMethod(); } else if (op == this.OP_END_METHOD) { this.OperEndMethod(); } else if (op == this.OP_ADD_MODIFIER) { this.OperAddModifier(); } } }
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 InsertOperators(int pos, int number) { for (int i = 0; i < number; i++) { ProgRec rec = new ProgRec(); rec.op = this.OP_NOP; this.prog.Insert(pos, rec); } this.Card += number; }
public void SetTypesEx(int init_n) { if (!this.scripter.IsError()) { FunctionObject functionObject = null; for (int i = init_n + 1; i <= this.Card; i++) { this.r = (ProgRec) this.prog[i]; int op = this.r.op; this.n = i; if (op == this.OP_ASSIGN_TYPE) { this.scripter.Dump(); this.symbol_table[this.r.arg1].TypeId = this.r.arg2; ClassObject obj3 = this.GetClassObject(this.r.arg2); if (obj3.Class_Kind == ClassKind.Namespace) { this.scripter.CreateErrorObjectEx("CS0118. '{0}' denotes a '{1}' where a '{2}' was expected.", new object[] { obj3.Name, "namespace", "class" }); break; } MemberKind kind = this.symbol_table[this.r.arg1].Kind; switch (kind) { case MemberKind.Method: functionObject = this.GetFunctionObject(this.r.arg1); if ((MemberObject.CompareAccessibility(obj3, functionObject) < 0) && (obj3.Id != functionObject.OwnerId)) { if (functionObject.Name == "op_Implicit") { this.scripter.CreateErrorObjectEx("CS0056. Inconsistent accessibility: return type '{0}' is less accessible than operator '{1}'.", new object[] { obj3.Name, "Implicit" }); } else if (functionObject.Name == "op_Explicit") { this.scripter.CreateErrorObjectEx("CS0056. Inconsistent accessibility: return type '{0}' is less accessible than operator '{1}'.", new object[] { obj3.Name, "Explicit" }); } else if (CSLite_System.PosCh('$', functionObject.Name) >= 0) { if (functionObject.Owner.IsDelegate) { this.scripter.CreateErrorObjectEx("CS0058. Inconsistent accessibility: parameter type '{0}' is less accessible than delegate '{1}'.", new object[] { obj3.Name, functionObject.Owner.Name }); } } else { this.scripter.CreateErrorObjectEx("CS0050. Inconsistent accessibility: return type '{0}' is less accessible than method '{1}'.", new object[] { obj3.Name, functionObject.Name }); } } break; case MemberKind.Field: { FieldObject fieldObject = this.GetFieldObject(this.r.arg1); if ((MemberObject.CompareAccessibility(obj3, fieldObject) < 0) && (obj3.Id != fieldObject.OwnerId)) { this.scripter.CreateErrorObjectEx("CS0052. Inconsistent accessibility: field type '{0}' is less accessible than field '{1}'.", new object[] { obj3.Name, fieldObject.Name }); } break; } case MemberKind.Event: { EventObject eventObject = this.GetEventObject(this.r.arg1); if ((MemberObject.CompareAccessibility(obj3, eventObject) < 0) && (obj3.Id != eventObject.OwnerId)) { this.scripter.CreateErrorObjectEx("CS0053. Inconsistent accessibility: property type '{0}' is less accessible than property '{1}'.", new object[] { obj3.Name, eventObject.Name }); } if (!obj3.IsDelegate) { this.scripter.CreateErrorObjectEx("CS0066. '{0}': event must be of a delegate type.", new object[] { eventObject.Name }); } break; } case MemberKind.Property: { PropertyObject propertyObject = this.GetPropertyObject(this.r.arg1); if ((MemberObject.CompareAccessibility(obj3, propertyObject) < 0) && (obj3.Id != propertyObject.OwnerId)) { if (propertyObject.ParamCount == 0) { this.scripter.CreateErrorObjectEx("CS0053. Inconsistent accessibility: property type '{0}' is less accessible than property '{1}'.", new object[] { obj3.Name, propertyObject.Name }); } else { this.scripter.CreateErrorObjectEx("CS0054. Inconsistent accessibility: indexer return type '{0}' is less accessible than indexer '{1}'.", new object[] { obj3.Name, propertyObject.Name }); } } break; } default: if ((((kind == MemberKind.Var) && (functionObject != null)) && (functionObject.HasParameter(this.r.arg1) && (MemberObject.CompareAccessibility(obj3, functionObject) < 0))) && (obj3.Id != functionObject.OwnerId)) { if ((functionObject.Name == "get_Item") || (functionObject.Name == "set_Item")) { this.scripter.CreateErrorObjectEx("CS0055. Inconsistent accessibility: parameter type '{0}' is less accessible than indexer '{1}'.", new object[] { obj3.Name, functionObject.Name }); } else if (functionObject.Name == "op_Implicit") { this.scripter.CreateErrorObjectEx("CS0057. Inconsistent accessibility: parameter type '{0}' is less accessible than operator '{1}'.", new object[] { obj3.Name, "Implicit" }); } else if (functionObject.Name == "op_Explicit") { this.scripter.CreateErrorObjectEx("CS0057. Inconsistent accessibility: parameter type '{0}' is less accessible than operator '{1}'.", new object[] { obj3.Name, "Explicit" }); } else if ((CSLite_System.PosCh('$', functionObject.Name) >= 0) && functionObject.Owner.IsDelegate) { this.scripter.CreateErrorObjectEx("CS0059. Inconsistent accessibility: parameter type '{0}' is less accessible than delegate '{1}'.", new object[] { obj3.Name, functionObject.Owner.Name }); } } break; } this.r.op = this.OP_NOP; continue; } if (op == this.OP_TYPEOF) { this.symbol_table[this.r.res].TypeId = this.symbol_table.TYPE_CLASS_id; continue; } if (op == this.OP_CREATE_REF_TYPE) { int id = this.r.arg1; int level = this.symbol_table[id].Level; string str = this.symbol_table[id].Name + "&"; int num5 = 0; for (int j = 1; j <= this.symbol_table.Card; j++) { if ((this.symbol_table[j].Level == level) && (this.symbol_table[j].Name == str)) { num5 = j; break; } } if (num5 > 0) { this.ReplaceId(this.r.res, num5); } else { this.PutVal(this.r.res, this.GetVal(id)); this.symbol_table[this.r.arg1].Kind = MemberKind.Type; } continue; } if (op == this.OP_SET_REF_TYPE) { int typeId = this.symbol_table[this.r.arg1].TypeId; int num8 = this.symbol_table[typeId].Level; string str2 = this.symbol_table[typeId].Name + "&"; int num9 = 0; for (int k = 1; k <= this.symbol_table.Card; k++) { if ((this.symbol_table[k].Level == num8) && (this.symbol_table[k].Name == str2)) { num9 = k; break; } } if (num9 == 0) { num9 = this.symbol_table.AppVar(); this.PutVal(num9, this.GetVal(typeId)); this.symbol_table[num9].Kind = MemberKind.Type; this.symbol_table[num9].Level = num8; this.symbol_table[num9].Name = str2; } this.symbol_table[this.r.arg1].TypeId = num9; for (int m = this.n; m <= this.Card; m++) { if ((this[m].op == this.OP_SET_REF_TYPE) && (this[m].arg1 == this.r.arg1)) { this[m].op = this.OP_NOP; } } continue; } if (op == this.OP_CREATE_OBJECT) { this.symbol_table[this.r.res].TypeId = this.r.arg1; continue; } if (op == this.OP_AS) { this.symbol_table[this.r.res].TypeId = this.r.arg2; continue; } if ((op == this.OP_ASSIGN) && (this[this.n - 1].op == this.OP_DECLARE_LOCAL_VARIABLE)) { if ((this[this.n - 1].arg1 == this.r.res) && !this.GetExplicit(this.n)) { this.symbol_table[this.r.res].TypeId = this.symbol_table[this.r.arg2].TypeId; } continue; } if ((op == this.OP_ASSIGN) && (this.symbol_table[this.r.arg1].TypeId == 0x10)) { if (!this.GetStrict(this.n)) { this.symbol_table[this.r.res].TypeId = this.symbol_table[this.r.arg2].TypeId; } continue; } if (op == this.OP_ADD_IMPLEMENTS) { int num12 = this.r.arg1; this.GetMemberObject(num12).ImplementsId = this.r.res; continue; } if (op == this.OP_BEGIN_CALL) { if (this.symbol_table[this.r.arg1].Name.IndexOf('[') >= 0) { this.r.op = this.OP_NOP; } continue; } if (op == this.OP_ADD_ARRAY_RANGE) { this.GetClassObject(this.r.arg1).RangeTypeId = this.r.arg2; continue; } if (op == this.OP_ADD_ARRAY_INDEX) { ClassObject obj9 = this.GetClassObject(this.r.arg1); obj9.IndexTypeId = this.r.arg2; string str4 = this.symbol_table[this.r.arg2].Name; int typeByName = this.symbol_table.LookupTypeByName(str4, true); if (typeByName == 0) { typeByName = this.symbol_table.OBJECT_CLASS_id; } ClassObject obj10 = this.GetClassObject(typeByName); if (obj10.ImportedType == null) { obj9.ImportedType = typeof(object); } else { obj9.ImportedType = obj10.ImportedType; } continue; } if (op == this.OP_CALL) { string elementTypeName = this.symbol_table[this.r.arg1].Name; if (elementTypeName.IndexOf('[') < 0) { continue; } this.r.op = this.OP_CREATE_ARRAY_INSTANCE; elementTypeName = CSLite_System.GetElementTypeName(elementTypeName); bool flag = this.GetUpcase(this.n); int num15 = this.symbol_table.LookupTypeByName(elementTypeName, flag); if (num15 > 0) { this.r.arg1 = num15; continue; } this.scripter.CreateErrorObjectEx("Undeclared identifier '{0}'", new object[] { elementTypeName }); break; } if ((op != this.OP_CREATE_REFERENCE) || (this.symbol_table[this.r.arg1].Kind != MemberKind.Type)) { continue; } ClassObject classObject = this.GetClassObject(this.r.arg1); if (this.scripter.ForbiddenTypes.IndexOf(classObject.FullName) >= 0) { this.scripter.CreateErrorObjectEx("CSLite0007. Use of forbidden type '{0}'.", new object[] { classObject.FullName }); } int nameIndex = this.symbol_table[this.r.res].NameIndex; string name = this.symbol_table[this.r.res].Name; bool upcase = this.GetUpcase(this.n); MemberObject memberByNameIndex = classObject.GetMemberByNameIndex(nameIndex, upcase); if (((memberByNameIndex == null) && classObject.IsNamespace) && classObject.Imported) { memberByNameIndex = this.scripter.FindImportedNamespaceMember(classObject, name, upcase); } if (memberByNameIndex == null) { if ((this.GetLanguage(this.n) == CSLite_Language.Pascal) && CSLite_System.StrEql(name, "Create")) { int num17 = this[this.n].arg1; int res = this[this.n].res; int num19 = this.AppVar(this.GetCurrMethodId(), num17); if ((this[this.n + 1].op == this.OP_BEGIN_CALL) && (this[this.n + 1].arg1 == this[this.n].res)) { this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].res = num19; this[this.n + 1].arg1 = num17; int num20 = this.n + 1; while (true) { if ((this[num20].op == this.OP_PUSH) && (this[num20].res == res)) { this[num20].res = num17; } if ((this[num20].op == this.OP_CALL) && (this[num20].arg1 == res)) { this[num20].arg1 = num17; break; } num20++; } this[num20 - 1].arg1 = num19; this.ReplaceId(this[num20].res, num19); this[num20].res = 0; continue; } this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].res = num19; this.n++; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_BEGIN_CALL; this[this.n].arg1 = num17; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num19; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num17; this[this.n].arg2 = 0; this[this.n].res = 0; this.ReplaceId(res, num19); this.n -= 3; continue; } this.scripter.CreateErrorObjectEx("CS0103. The name '{0}' does not exist in the class or namespace '{1}'.", new object[] { name, classObject.Name }); break; } if (!memberByNameIndex.Static) { if (this[this.n + 1].op == this.OP_ADDRESS_OF) { goto Label_136C; } memberByNameIndex = classObject.GetStaticMemberByNameIndex(nameIndex, upcase); if (memberByNameIndex != null) { goto Label_136C; } if ((this.GetLanguage(this.n) == CSLite_Language.Pascal) && CSLite_System.StrEql(name, "Create")) { int num21 = this[this.n].arg1; int num22 = this[this.n].res; int num23 = this.AppVar(this.GetCurrMethodId(), num21); if ((this[this.n + 1].op == this.OP_BEGIN_CALL) && (this[this.n + 1].arg1 == this[this.n].res)) { this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].res = num23; this[this.n + 1].arg1 = num21; int num24 = this.n + 1; while (true) { if ((this[num24].op == this.OP_PUSH) && (this[num24].res == num22)) { this[num24].res = num21; } if ((this[num24].op == this.OP_CALL) && (this[num24].arg1 == num22)) { this[num24].arg1 = num21; break; } num24++; } this[num24 - 1].arg1 = num23; this.ReplaceId(this[num24].res, num23); this[num24].res = 0; continue; } this[this.n].op = this.OP_CREATE_OBJECT; this[this.n].res = num23; this.n++; this.InsertOperators(this.n, 3); this[this.n].op = this.OP_BEGIN_CALL; this[this.n].arg1 = num21; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_PUSH; this[this.n].arg1 = num23; this[this.n].arg2 = 0; this[this.n].res = 0; this.n++; this[this.n].op = this.OP_CALL; this[this.n].arg1 = num21; this[this.n].arg2 = 0; this[this.n].res = 0; this.ReplaceId(num22, num23); this.n -= 3; continue; } this.scripter.CreateErrorObjectEx("CS0120. An object reference is required for the nonstatic field, method, or property '{0}'.", new object[] { name }); break; } int ownerId = memberByNameIndex.OwnerId; string fullName = this.symbol_table[ownerId].FullName; if (this.scripter.CheckForbiddenNamespace(fullName)) { this.scripter.CreateErrorObjectEx("CSLite0006. Use of forbidden namespace '{0}'.", new object[] { fullName }); } Label_136C: this.r.op = this.OP_NOP; this.ReplaceIdEx(this.r.res, memberByNameIndex.Id, this.n, true); } } }
private void OperExitSub() { do { this.n++; this.r = (ProgRec) this.prog[this.n]; } while (this.r.op != this.OP_RET); }
private void CheckOP_BITWISE_XOR() { int op = this.r.op; if (this.SetupDetailedBinaryOperator(op, "^", this.detailed_bitwise_xor_operators) && (this[this.n].op != this.OP_CALL_SIMPLE)) { this.r = this[this.n]; int typeId = this.GetTypeId(this.r.arg1); int num3 = this.GetTypeId(this.r.arg2); int id = this.GetTypeId(this.r.res); if ((typeId != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 1); } if ((num3 != id) && IsNumericTypeId(id)) { this.InsertNumericConversion(id, 2); } } }
private void OperRet() { if (this.debugging) { this.callstack.Pop(); } FunctionObject functionObject = this.GetFunctionObject(this.r.arg1); this.n = (int) this.stack.Pop(); this.r = (ProgRec) this.prog[this.n]; object obj3 = this.GetValue(functionObject.ResultId); functionObject.DeallocateSub(); if (this.r.res != 0) { this.PutValue(this.r.res, obj3); } this.n++; }
private void RaiseError() { while (this.stack.Count > this.curr_stack_count) { this.stack.Pop(); } if (this.try_stack.Count == 0) { if (this.PascalOrBasic(this.n)) { int n = this.n; this.resume_stack.Push(this.n); while (this[n].op != this.OP_INIT_METHOD) { n--; } do { n++; if (this[n].op == this.OP_ONERROR) { this.n = n + 1; return; } } while (this[n].op != this.OP_END_METHOD); } this.Terminated = true; this.Paused = false; return; } Label_00C4: this.r = (ProgRec) this.prog[this.n]; int op = this.r.op; while (true) { if (((op == this.OP_RET) || (op == this.OP_FINALLY)) || ((op == this.OP_CATCH) || (op == this.OP_HALT))) { break; } if (op == this.OP_TRY_ON) { this.OperTryOn(); } else if (op == this.OP_TRY_OFF) { this.OperTryOff(); } else if (op == this.OP_HALT) { this.OperHalt(); } else { this.n++; } this.r = (ProgRec) this.prog[this.n]; op = this.r.op; } if (op == this.OP_RET) { this.OperRet(); goto Label_00C4; } if (op == this.OP_CATCH) { if (this.try_stack.Legal(this.n)) { if (this.r.arg1 <= 0) { this.n++; return; } Type t = this.scripter.LastError.E.GetType(); int id = this.symbol_table.RegisterType(t, false); int typeId = this.symbol_table[this.r.arg1].TypeId; if (typeId == id) { this.PutValue(this.r.arg1, this.scripter.LastError.E); return; } ClassObject classObject = this.GetClassObject(id); ClassObject a = this.GetClassObject(typeId); if (classObject.InheritsFrom(a) || (a == classObject)) { this.PutValue(this.r.arg1, this.scripter.LastError.E); return; } int index = this.custom_ex_list.IndexOf(this.scripter.LastError.E); if (index >= 0) { ObjectObject obj4 = this.custom_ex_list.Objects[index] as ObjectObject; classObject = obj4.Class_Object; if (classObject.InheritsFrom(a) || (a == classObject)) { this.PutValue(this.r.arg1, obj4); return; } } this.n++; } else { this.n++; } goto Label_00C4; } if ((op != this.OP_FINALLY) || this.try_stack.Legal(this.n)) { return; } goto Label_00C4; }