Ejemplo n.º 1
0
 internal ObjectObject(BaseScripter scripter, ClassObject class_object)
     : base(scripter)
 {
     this.class_object = class_object;
     this.Properties = new InstancePropertyList(scripter);
     this.Instance = null;
     this.invocation_listX = new ArrayList();
     this.invocation_listF = new ArrayList();
     this.invocation_index = -1;
 }
Ejemplo n.º 2
0
 internal ClassObject(BaseScripter scripter, int class_id, int owner_id, ClassKind ck)
     : base(scripter, class_id, owner_id)
 {
     this.PatternMethod = null;
     this.UnderlyingType = null;
     this.RType = null;
     this._namespaceNameIndex = -1;
     this.MinValueId = 0;
     this.MaxValueId = 0;
     this.RangeTypeId = 0;
     this.IndexTypeId = 0;
     this.ht = new Hashtable();
     this.AncestorIds = new IntegerList(false);
     this.ImportedType = null;
     this.Class_Kind = ck;
     this.PatternMethod = null;
 }
Ejemplo n.º 3
0
 public int RegisterNamespace(string namespace_name)
 {
     int num2;
     char ch;
     int index = this.scripter.RegisteredNamespaces.IndexOf(namespace_name);
     if (index >= 0)
     {
         return (int) this.scripter.RegisteredNamespaces.Objects[index];
     }
     string str = CSLite_System.ExtractOwner(namespace_name, out ch);
     if (namespace_name == "System")
     {
         num2 = 0;
     }
     else if (str == "")
     {
         num2 = 0;
     }
     else
     {
         num2 = this.RegisterNamespace(str);
     }
     namespace_name = CSLite_System.ExtractName(namespace_name);
     int num = this.AppType(namespace_name);
     ClassObject m = new ClassObject(this.scripter, num, num2, ClassKind.Namespace);
     m.Imported = true;
     this[num].Level = num2;
     m.Modifiers.Add(Modifier.Public);
     m.Modifiers.Add(Modifier.Static);
     this[num].Value = m;
     if (namespace_name != "")
     {
         ((ClassObject) this[num2].Val).AddMember(m);
     }
     this.scripter.RegisteredNamespaces.AddObject(m.FullName, num);
     if (m.FullName == "System.Collections")
     {
         this.SYSTEM_COLLECTIONS_ID = num;
     }
     return num;
 }
Ejemplo n.º 4
0
 public void RegisterMemberTypes(Type t, ClassObject c)
 {
     foreach (ConstructorInfo info in t.GetConstructors())
     {
         foreach (ParameterInfo info2 in info.GetParameters())
         {
             this.RegisterType(info2.ParameterType, true);
         }
     }
     foreach (MethodInfo info3 in t.GetMethods())
     {
         this.RegisterType(info3.ReturnType, false);
         foreach (ParameterInfo info4 in info3.GetParameters())
         {
             this.RegisterType(info4.ParameterType, false);
         }
     }
     foreach (FieldInfo info5 in t.GetFields())
     {
         this.RegisterType(info5.FieldType, false);
     }
     foreach (Type type in t.GetNestedTypes(BindingFlags.Public))
     {
         int id = this.RegisterType(type, true);
         this[id].Level = c.Id;
         c.AddMember(this.scripter.GetClassObject(id));
     }
     foreach (Type type2 in t.GetInterfaces())
     {
         int avalue = this.RegisterType(type2, false);
         c.AncestorIds.Add(avalue);
     }
     if (t.IsEnum)
     {
         Type underlyingType = Enum.GetUnderlyingType(t);
         int num3 = this.RegisterType(underlyingType, false);
         c.UnderlyingType = this.scripter.GetClassObject(num3);
     }
     Type baseType = t.BaseType;
     if ((baseType != null) && (baseType != typeof(object)))
     {
         int num4 = this.RegisterType(baseType, true);
         c.AncestorIds.Add(num4);
     }
 }
Ejemplo n.º 5
0
 private bool TryDetailedUnaryOperator(Contact_Integers details, ClassObject c1)
 {
     for (int i = 0; i < details.Count; i++)
     {
         if (details.Items1[i] == c1.Id)
         {
             this.r.op = details.Items2[i];
             this.symbol_table[this.r.res].TypeId = c1.Id;
             return true;
         }
     }
     for (int j = 0; j < details.Count; j++)
     {
         if (this.TryUnaryOperator(details.Items1[j], c1))
         {
             this.r.op = details.Items2[j];
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 internal bool Implements(ClassObject i)
 {
     return (this.InheritsFrom(i) && i.IsInterface);
 }
Ejemplo n.º 7
0
 public bool InheritsFrom(ClassObject a)
 {
     for (int i = 0; i < this.AncestorIds.Count; i++) {
         int id = this.AncestorIds[i];
         if (a.Id == id) {
             return true;
         }
         if (base.Scripter.GetClassObject(id).InheritsFrom(a)) {
             return true;
         }
     }
     return (((a.Imported && (this.ImportedType != null)) && !a.IsInterface) && this.ImportedType.IsSubclassOf(a.ImportedType));
 }
Ejemplo n.º 8
0
 internal ClassObject FindOriginalType(ClassObject c)
 {
     if (!c.IsRefType)
     {
         return c;
     }
     string name = c.Name.Substring(0, c.Name.Length - 1);
     int ownerId = c.OwnerId;
     int id = this.symbol_table.LookupID(name, ownerId, false);
     if (id > 0)
     {
         return (ClassObject) this.GetVal(id);
     }
     return null;
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
        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];
                    }
                }
            }
        }
Ejemplo n.º 11
0
 private void CheckOP_ASSIGN(ClassObject enum_class)
 {
     ClassObject obj3;
     if (this.symbol_table[this.r.arg1].Kind == MemberKind.Index)
     {
         int level = this.symbol_table[this.r.arg1].Level;
         if (this.symbol_table[level].TypeId == 12)
         {
             this.scripter.CreateErrorObjectEx("CS0200. Property or indexer '{0}' cannot be assigned to — it is read only.", new object[] { "this" });
             return;
         }
     }
     int typeId = this.symbol_table[this.r.arg1].TypeId;
     int id = this.symbol_table[this.r.arg2].TypeId;
     ClassObject classObject = this.GetClassObject(typeId);
     if (classObject.IsSubrange)
     {
         typeId = classObject.AncestorIds[0];
     }
     if (typeId != id)
     {
         if (id == 0)
         {
             id = 0;
         }
         else if (typeId != 0x10)
         {
             if (this.r.arg2 == this.symbol_table.NULL_id)
             {
                 classObject = this.GetClassObject(typeId);
                 if (classObject.IsValueType)
                 {
                     this.scripter.CreateErrorObjectEx("CS0037. Cannot convert null to '{0}' because it is a value type.", new object[] { classObject.Name });
                     return;
                 }
             }
             else if (enum_class != null)
             {
                 int num4 = enum_class.UnderlyingType.Id;
                 classObject = this.GetClassObject(num4);
                 obj3 = this.GetClassObject(id);
                 if (!this.scripter.MatchTypes(obj3, classObject))
                 {
                     this.scripter.CreateErrorObjectEx("CS0029. Cannot impllicitly convert type '{0}' to '{1}'.", new object[] { obj3.Name, classObject.Name });
                     return;
                 }
                 this.InsertNumericConversion(num4, 2);
             }
             else if (typeId == 0)
             {
                 this.symbol_table[this.r.arg1].TypeId = id;
                 if (id == 0)
                 {
                     this.scripter.CreateErrorObject("CS0001. Internal compiler error.");
                     return;
                 }
             }
             else
             {
                 classObject = this.GetClassObject(typeId);
                 obj3 = this.GetClassObject(id);
                 bool flag = obj3.InheritsFrom(classObject);
                 if (!flag)
                 {
                     flag = this.scripter.conversion.ExistsImplicitNumericConstConversion(this.scripter, this.r.arg2, this.r.arg1);
                 }
                 if (!flag)
                 {
                     flag = this.scripter.MatchTypes(obj3, classObject);
                 }
                 if (!flag)
                 {
                     ClassObject obj4;
                     int num5 = classObject.FindOverloadableImplicitOperatorId(this.r.arg2, this.r.res);
                     if (num5 == 0)
                     {
                         num5 = obj3.FindOverloadableImplicitOperatorId(this.r.arg2, this.r.res);
                         obj4 = obj3;
                     }
                     else
                     {
                         obj4 = classObject;
                     }
                     flag = num5 > 0;
                     if (flag)
                     {
                         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].res = num5;
                         this.n++;
                         this[this.n].op = this.OP_PUSH;
                         this[this.n].arg1 = obj4.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 = num5;
                         this[this.n].arg2 = 1;
                         this[this.n].res = this.r.res;
                         return;
                     }
                 }
                 if (!flag)
                 {
                     this.scripter.CreateErrorObjectEx("CS0029. Cannot impllicitly convert type '{0}' to '{1}'.", new object[] { obj3.Name, classObject.Name });
                     return;
                 }
             }
         }
     }
     classObject = this.GetClassObject(typeId);
     obj3 = this.GetClassObject(id);
     if ((typeId > this.symbol_table.OBJECT_CLASS_id) && (classObject.Class_Kind == ClassKind.Struct))
     {
         this.r.op = this.OP_ASSIGN_STRUCT;
     }
     else if ((IsNumericTypeId(classObject.Id) && IsNumericTypeId(obj3.Id)) && ((this.symbol_table[this.r.arg1].Kind != MemberKind.Var) || (classObject != obj3)))
     {
         this.InsertNumericConversion(classObject.Id, 2);
     }
 }
Ejemplo n.º 12
0
 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);
     }
 }
Ejemplo n.º 13
0
 private bool TryUnaryOperator(int type_id, ClassObject c1)
 {
     ClassObject classObject = this.GetClassObject(type_id);
     if (this.scripter.MatchTypes(c1, classObject))
     {
         if (c1.Class_Kind == ClassKind.Enum)
         {
             this.symbol_table[this.r.res].TypeId = c1.Id;
         }
         else
         {
             this.symbol_table[this.r.res].TypeId = classObject.Id;
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 14
0
 private bool TryOverloadableUnaryOperator(string operator_name, ClassObject c1)
 {
     int num = c1.FindOverloadableUnaryOperatorId(operator_name, this.r.arg1);
     if (num != 0)
     {
         this.r.op = this.OP_NOP;
         int res = this.r.res;
         this.n++;
         this.InsertOperators(this.n, 3);
         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 = 1;
         this[this.n].res = res;
         this.symbol_table[this[this.n].res].TypeId = this.symbol_table[num].TypeId;
     }
     return (num != 0);
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 public int RegisterType(Type t, bool recursive)
 {
     int num = this.scripter.RegisteredTypes.FindRegisteredTypeId(t);
     if (num <= 0)
     {
         char ch;
         int typeByName;
         string fullName = t.FullName;
         if (fullName == null)
         {
             return 0x10;
         }
         string str2 = CSLite_System.ExtractOwner(fullName, out ch);
         if (str2 == "System")
         {
             typeByName = this.system_namespace_id;
         }
         else if (str2 == "")
         {
             typeByName = this.root_namespace_id;
         }
         else if (ch == '.')
         {
             typeByName = this.RegisterNamespace(str2);
         }
         else
         {
             typeByName = this.LookupTypeByName(str2, false);
             if (typeByName == 0)
             {
                 Type type = Type.GetType(str2);
                 if (type != null)
                 {
                     typeByName = this.RegisterType(type, false);
                 }
             }
         }
         ClassKind ck = ClassKind.Class;
         if (t.IsArray)
         {
             ck = ClassKind.Array;
         }
         else if (t.IsEnum)
         {
             ck = ClassKind.Enum;
         }
         else if (t.IsInterface)
         {
             ck = ClassKind.Interface;
         }
         else if (t.IsValueType)
         {
             ck = ClassKind.Struct;
         }
         else if (t.BaseType == typeof(MulticastDelegate))
         {
             ck = ClassKind.Delegate;
         }
         num = this.AppType(t.Name);
         if (t == typeof(Type))
         {
             this.type_class_id = num;
         }
         else if (t == typeof(object))
         {
             this.object_class_id = num;
         }
         ClassObject m = new ClassObject(this.scripter, num, typeByName, ck);
         m.Modifiers.Add(Modifier.Public);
         m.Modifiers.Add(Modifier.Static);
         if (t.IsSealed)
         {
             m.Modifiers.Add(Modifier.Sealed);
         }
         if (t.IsAbstract)
         {
             m.Modifiers.Add(Modifier.Abstract);
         }
         m.Imported = true;
         m.ImportedType = t;
         this[num].Value = m;
         this[num].Level = typeByName;
         ((ClassObject) this[typeByName].Val).AddMember(m);
         if (t.BaseType == typeof(MulticastDelegate))
         {
             int num3 = this.AppVar();
             FunctionObject obj4 = new FunctionObject(this.scripter, num3, m.Id);
             this[num3].Kind = MemberKind.Method;
             this[num3].Level = m.Id;
             this[num3].Val = obj4;
             int num4 = this.AppLabel();
             this[num4].Level = num3;
             num4 = this.AppVar();
             this[num4].Level = num3;
             num4 = this.AppVar();
             this[num4].Level = num3;
             m.AddMember(obj4);
             m.PatternMethod = obj4;
         }
         this.scripter.RegisteredTypes.RegisterType(t, num);
         if (recursive)
         {
             this.RegisterMemberTypes(t, m);
         }
     }
     return num;
 }
Ejemplo n.º 17
0
 internal MemberObject FindImportedNamespaceMember(ClassObject n, string member_name, bool upcase)
 {
     string str = n.FullName + "." + member_name;
     Type t = this.FindAvailableType(str, upcase);
     if (t != null)
     {
         int id = this.symbol_table.RegisterType(t, false);
         return this.GetMemberObject(id);
     }
     string str2 = str + ".";
     for (int i = 0; i < this.UserNamespaces.Count; i++)
     {
         string str3 = this.UserNamespaces[i] + ".";
         if (str2.Length < str3.Length)
         {
             str3 = str3.Substring(0, str2.Length - 1);
         }
         if (str2 == str3)
         {
             int num3 = this.symbol_table.RegisterNamespace(str);
             return this.GetMemberObject(num3);
         }
     }
     return null;
 }
Ejemplo n.º 18
0
 private void OperCreateClass()
 {
     int num = this.r.arg1;
     int id = this.r.arg2;
     ClassObject classObject = this.GetClassObject(id);
     if (this.scripter.HasPredefinedNamespace(this.symbol_table[num].FullName))
     {
         this.scripter.CreateErrorObjectEx("CS0519. '{0}' conflicts with a predefined namespace.", new object[] { this.symbol_table[num].FullName });
     }
     else
     {
         bool upcase = this.GetUpcase();
         int nameIndex = this.symbol_table[num].NameIndex;
         if (classObject.GetMemberByNameIndex(nameIndex, upcase) != null)
         {
             string name = this.symbol_table[num].Name;
             if (classObject.Class_Kind == ClassKind.Namespace)
             {
                 this.scripter.CreateErrorObjectEx("CS0101. The namespace '{0}' already contains a definition for '{1}'.", new object[] { classObject.Name, name });
             }
             else
             {
                 this.scripter.CreateErrorObjectEx("CS0102. The class '{0}' already contains a definition for '{1}'.", new object[] { classObject.Name, name });
             }
         }
         else
         {
             ClassKind res = (ClassKind) this.r.res;
             ClassObject obj4 = new ClassObject(this.scripter, num, id, res);
             obj4.PCodeLine = this.n;
             this.PutVal(num, obj4);
             classObject.AddMember(obj4);
             this.n++;
         }
     }
 }
Ejemplo n.º 19
0
 internal bool MatchTypes(ClassObject c1, ClassObject c2)
 {
     if (c1.IsRefType)
     {
         c1 = this.FindOriginalType(c1);
         if (c1 == null)
         {
             return false;
         }
     }
     if (c2.IsRefType)
     {
         c2 = this.FindOriginalType(c2);
         if (c2 == null)
         {
             return false;
         }
     }
     if (c1 == c2)
     {
         return true;
     }
     if (this.conversion.ExistsImplicitNumericConversion(c1.Id, c2.Id))
     {
         return true;
     }
     if (c1.Class_Kind == ClassKind.Enum)
     {
         if (c2.Class_Kind == ClassKind.Enum)
         {
             return false;
         }
         return this.MatchTypes(c1.UnderlyingType, c2);
     }
     if (c2.Class_Kind == ClassKind.Enum)
     {
         if (c1.Class_Kind == ClassKind.Enum)
         {
             return false;
         }
         return this.MatchTypes(c1, c2.UnderlyingType);
     }
     return false;
 }
Ejemplo n.º 20
0
 private void OperCreateNamespace()
 {
     int num = this.r.arg1;
     int id = this.r.arg2;
     string fullName = this.symbol_table[num].FullName;
     bool upcase = this.GetUpcase();
     if (this.scripter.FindAvailableType(fullName, upcase) != null)
     {
         this.scripter.CreateErrorObjectEx("CS0010. Cannot declare a namespace and a type both named '{0}'.", new object[] { fullName });
     }
     else
     {
         ClassObject classObject = this.GetClassObject(id);
         if (classObject != null)
         {
             int nameIndex = this.symbol_table[num].NameIndex;
             MemberObject memberByNameIndex = classObject.GetMemberByNameIndex(nameIndex, upcase);
             if (memberByNameIndex != null)
             {
                 if (memberByNameIndex.Kind == MemberKind.Type)
                 {
                     ClassObject obj4 = memberByNameIndex as ClassObject;
                     if (obj4.Class_Kind == ClassKind.Namespace)
                     {
                         this.symbol_table[num].Kind = MemberKind.None;
                         this.ReplaceId(num, memberByNameIndex.Id);
                         return;
                     }
                 }
                 string name = this.symbol_table[num].Name;
                 this.scripter.CreateErrorObjectEx("CS0101. The namespace '{0}' already contains a definition for '{1}'.", new object[] { classObject.Name, name });
                 return;
             }
         }
         ClassKind res = (ClassKind) this.r.res;
         ClassObject obj5 = new ClassObject(this.scripter, num, id, res);
         obj5.PCodeLine = this.n;
         this.PutVal(num, obj5);
         if (classObject != null)
         {
             classObject.AddMember(obj5);
         }
         this.n++;
     }
 }
Ejemplo n.º 21
0
 public bool ExistsImplicitBoxingConversion(ClassObject c1, ClassObject c2)
 {
     BaseScripter scripter = c1.Scripter;
     if (c1.IsValueType)
     {
         if (c2.Id == scripter.symbol_table.OBJECT_CLASS_id)
         {
             return true;
         }
         if (c2.Id == scripter.symbol_table.VALUETYPE_CLASS_id)
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 internal bool IsBaseClassOf(ClassObject c)
 {
     return this.InheritsFrom(c);
 }
Ejemplo n.º 24
0
 private bool TryDetailedBinaryOperator(Contact_Integers details, ClassObject c1, ClassObject c2)
 {
     for (int i = 0; i < details.Count; i++)
     {
         if (this.TryBinaryOperator(details.Items1[i], c1, c2))
         {
             this.r.op = details.Items2[i];
             return true;
         }
     }
     return false;
 }