public int IntValue()
        {
            switch (Type)
            {
            case BurikoValueType.Int:
            case BurikoValueType.Bool:
                return(valueInt);

            case BurikoValueType.String:
                if (int.TryParse(valueString, out int result))
                {
                    return(result);
                }
                throw new Exception("BurikoValue: Cannot parse type string into type int.");

            case BurikoValueType.Variable:
            {
                IBurikoObject memory = BurikoMemory.Instance.GetMemory(valueReference.Property);
                return(memory.IntValue(valueReference));
            }

            case BurikoValueType.Operation:
                return(valueVariable.IntValue());

            case BurikoValueType.Null:
                return(0);

            default:
                throw new NotImplementedException($"BurikoValue: Cannot cast type {Type} into type Int.");
            }
        }
        public string StringValue()
        {
            switch (Type)
            {
            case BurikoValueType.Null:
                return(string.Empty);

            case BurikoValueType.Int:
            case BurikoValueType.Bool:
                return(valueInt.ToString(CultureInfo.InvariantCulture));

            case BurikoValueType.String:
                return(valueString);

            case BurikoValueType.Variable:
                if (BurikoMemory.Instance.IsMemory(valueReference.Property))
                {
                    IBurikoObject memory = BurikoMemory.Instance.GetMemory(valueReference.Property);
                    return(memory.GetObject(valueReference).StringValue());
                }
                if (BurikoMemory.Instance.IsFlag(valueReference.Property))
                {
                    return(BurikoMemory.Instance.GetFlag(valueReference.Property).StringValue());
                }
                throw new Exception("Unable to convert variable type to string!");

            case BurikoValueType.Operation:
                return(valueVariable.StringValue());

            default:
                throw new NotImplementedException($"BurikoValue: Cannot cast type {Type} into type String.");
            }
        }
 public void AddMemory(string name, IBurikoObject obj)
 {
     memorylist.Add(name, new BurikoMemoryEntry(scopeLevel, obj));
 }
Esempio n. 4
0
 public BurikoMemoryEntry(int scope, IBurikoObject obj)
 {
     Scope = scope;
     Obj   = obj;
 }