public bool ExistsImplicitReferenceConversion(ClassObject c1, ClassObject c2) { BaseScripter scripter = c1.Scripter; if (c1.IsReferenceType && (c2.Id == scripter.symbol_table.OBJECT_CLASS_id)) { return true; } if (c1.InheritsFrom(c2)) { return true; } if (c1.IsArray && (c2.Id == scripter.symbol_table.ARRAY_CLASS_id)) { return true; } if (c1.IsDelegate && (c2.Id == scripter.symbol_table.DELEGATE_CLASS_id)) { return true; } if ((c1.IsArray || c1.IsDelegate) && (c2.Id == scripter.symbol_table.ICLONEABLE_CLASS_id)) { return true; } if (c1.IsArray && c2.IsArray) { int rank = CSLite_System.GetRank(c1.Name); int num2 = CSLite_System.GetRank(c2.Name); if (rank == num2) { string elementTypeName = CSLite_System.GetElementTypeName(c1.Name); string str2 = CSLite_System.GetElementTypeName(c2.Name); int typeId = scripter.GetTypeId(elementTypeName); int id = scripter.GetTypeId(str2); ClassObject classObject = scripter.GetClassObject(typeId); ClassObject obj3 = scripter.GetClassObject(id); if (classObject.IsReferenceType && obj3.IsReferenceType) { return this.ExistsImplicitReferenceConversion(classObject, obj3); } } return false; } return false; }
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; }