Пример #1
0
 public new void AddAttribute(string name, HassiumObject obj)
 {
     obj.Parent = this;
     if (!BoundAttributes.ContainsKey(name))
     {
         BoundAttributes.Add(name, obj);
     }
 }
 public override Dictionary <string, HassiumObject> GetAttributes()
 {
     foreach (var pair in TypeDefinition.BoundAttributes)
     {
         if (!BoundAttributes.ContainsKey(pair.Key))
         {
             BoundAttributes.Add(pair.Key, (pair.Value.Clone() as HassiumObject).SetSelfReference(this));
         }
     }
     return(BoundAttributes);
 }
Пример #3
0
 public override HassiumObject Invoke(VirtualMachine vm, SourceLocation location, params HassiumObject[] args)
 {
     if (BoundAttributes.ContainsKey("new"))
     {
         return(BoundAttributes["new"].Invoke(vm, location, args).AddType(TypeDefinition));
     }
     else if (BoundAttributes.ContainsKey(INVOKE))
     {
         return(BoundAttributes[INVOKE].Invoke(vm, location, args).AddType(TypeDefinition));
     }
     else
     {
         foreach (var inherit in Inherits)
         {
             var inheritClazz = vm.ExecuteMethod(inherit);
             if (inheritClazz is HassiumTypeDefinition)
             {
                 foreach (var attrib in inheritClazz.BoundAttributes)
                 {
                     BoundAttributes.Add(attrib.Key, (attrib.Value.Clone() as HassiumObject).SetSelfReference(this));
                 }
             }
             else
             {
                 foreach (var attrib in HassiumMethod.CloneDictionary(vm.ExecuteMethod(inherit).GetAttributes()))
                 {
                     if (!BoundAttributes.ContainsKey(attrib.Key))
                     {
                         attrib.Value.Parent = this;
                         BoundAttributes.Add(attrib.Key, attrib.Value);
                     }
                 }
             }
         }
         if (BoundAttributes.ContainsKey("new"))
         {
             return(Invoke(vm, location, args).AddType(TypeDefinition));
         }
         vm.RaiseException(HassiumAttribNotFoundException.AttribNotFoundExceptionTypeDef._new(vm, null, location, this, new HassiumString(INVOKE)));
         return(Null);
     }
 }
Пример #4
0
 public new void AddAttribute(string name, HassiumObject obj)
 {
     BoundAttributes.Add(name, obj);
     obj.AddType(TypeDefinition);
 }