Esempio n. 1
0
        public bool Equals(LiteValue Other)
        {
            if (Type != Other.Type)
            {
                return(false);
            }

            switch (Type)
            {
            case LiteValueType.Error:
                return(false);

            case LiteValueType.Nil:
                return(true);

            case LiteValueType.Boolean:
            case LiteValueType.String:
            case LiteValueType.Numeric:
            case LiteValueType.Function:
            case LiteValueType.Class:
            case LiteValueType.Object:
            case LiteValueType.Elements:
                return((int)Numeric == (int)Other.Numeric);
            }

            return(false);
        }
Esempio n. 2
0
 public LiteValue Get(LiteValue Name)
 {
     if (Name.Type == LiteValueType.String)
     {
         return(Get(StringTable.GetString((int)Name.Numeric)));
     }
     Logger.DError($"unknown var : {StringTable.GetString((int)Name.Numeric)}");
     return(LiteValue.Nil);
 }
Esempio n. 3
0
        public LiteValue Set(int Index, LiteValue Val)
        {
            if (Index < 0 || Index >= Values_.Length)
            {
                Logger.DError($"index [{Index}] out of range, max len = {Values_.Length}");
                return(LiteValue.Error);
            }

            Values_[Index] = Val;
            return(Val);
        }
Esempio n. 4
0
        public LiteValue Write(string Member, LiteValue Val)
        {
            var Env = GetEnv(Member);

            if (Env != null)
            {
                Env.SetSelf(Member, Val);
                return(Val);
            }
            return(LiteValue.Error);
        }
Esempio n. 5
0
 public void SetSelf(string Name, LiteValue Val)
 {
     if (!Variable_.ContainsKey(Name))
     {
         Variable_.Add(Name, Val);
     }
     else
     {
         Variable_[Name] = Val;
     }
 }
Esempio n. 6
0
 public void Set(LiteValue Name, LiteValue Val)
 {
     if (Name.Type == LiteValueType.String)
     {
         Set(StringTable.GetString((int)Name.Numeric), Val);
     }
     else
     {
         Logger.DError($"unknown var : {StringTable.GetString((int)Name.Numeric)}");
     }
 }
Esempio n. 7
0
        public void Set(string Name, LiteValue Val)
        {
            var Env = Where(Name);

            if (Env == null)
            {
                Env = this;
            }

            Env.SetSelf(Name, Val);
        }
Esempio n. 8
0
 public void Push(LiteValue Val)
 {
     Stack_.Push(Val);
 }