Exemplo n.º 1
0
 public void DeleteVariable(AsquellObj name)
 {
     if (name.Type == AsquellObjectType.RunTimeValue)
         DeleteVariable(name.Value.ToString());
     else
         throw new ArgumentException("Can not delete from memory value where name is type '" + name.Type.ToString() + "'!");
 }
Exemplo n.º 2
0
        public FormMemoryDetail(AsquellObj obj)
        {
            InitializeComponent();
            _obj = obj;

            doGenerics();
            doSpecifics();
        }
Exemplo n.º 3
0
 public ArrayObj(object[] array)
 {
     AsquellObj[] tmp = new AsquellObj[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         tmp[i] = new AsquellObj(array[i]);
     }
     baseObj = new AsquellObj(tmp);
 }
Exemplo n.º 4
0
 public static void MakeArray(MemoryBlock memory, AsquellObj to, params AsquellObj[] values)
 {
     if (to.Type == AsquellObjectType.RunTimeValue)
     {
         ArrayObj array = new ArrayObj(values);
         memory.ModifyVariable(to, array.BaseObj);
         return;
     }
     throw new ArgumentException("Invalid type for modifying memory! First argument must be a variable!");
 }
Exemplo n.º 5
0
 public static void SubtractNumbers(MemoryBlock memory, AsquellObj a, AsquellObj b, AsquellObj storeResult)
 {
     NumericObj NumA = getNumericObj(a, memory);
     NumericObj NumB = getNumericObj(b, memory);
     if (NumA != null && NumB != null)
     {
         memory.ModifyVariable(storeResult, (NumA - NumB).BaseObj);
         return;
     }
     throw new ArgumentException("Invalid type for subtracting!");
 }
Exemplo n.º 6
0
        public AsquellObj GetRealVariable(AsquellObj name)
        {
            AsquellObj tmp = name;
            AsquellObj last = tmp;
            while (true)
            {
                if (tmp != null)
                    last = tmp;
                if (tmp==null||tmp.Type!=AsquellObjectType.RunTimeValue)
                    break;

                tmp = GetVariable(name);
            }
            return last;
        }
Exemplo n.º 7
0
 public static void MoveMemory(MemoryBlock memory, AsquellObj to, AsquellObj from)
 {
     if (from.Type == AsquellObjectType.RunTimeValue)
     {
         if (memory.VariableInMemory(from))
         {
             AsquellObj rawValue = memory.GetRealVariable(from);
             memory.ModifyVariable(to, rawValue);
             memory.DeleteVariable(from);
             return;
         }
         else
         {
             throw new KeyNotFoundException("Can not find '"+from.Value.ToString()+"' in memory!");
         }
     }
     throw new ArgumentException("Invalid type for moving memory! First argument must be a variable!");
 }
Exemplo n.º 8
0
        public bool DoReflection(string name, AsquellObj[] args, MemoryBlock block)
        {
            if (_usableMethods.ContainsKey(name))
            {
                MethodInfo m = _usableMethods[name];
                int argCount = args.Length;

                if (getMethodAttr(m).NoMemoryBlock == false)
                    argCount++;

                //Don't want to call a method that will throw a C# error
                if (m.GetParameters().Length != argCount && !methodHasParams(m))
                    return false;

                object[] methodArgs = new object[m.GetParameters().Length];

                if (args.Length < argCount)
                { methodArgs[0] = block; }

                int argTrueCount = 0;
                for (int i = (args.Length < argCount ? 1 : 0); i < methodArgs.Length; i++)
                {
                    if (i + 1 == methodArgs.Length && methodHasParams(m))
                    {
                        methodArgs[i] = arrayOfArgs(args, argTrueCount);
                    }
                    else
                        methodArgs[i] = args[argTrueCount];
                    argTrueCount++;
                }

                m.Invoke(null, methodArgs);

                return true;
            }
            return false;
        }
Exemplo n.º 9
0
 public ArrayObj(AsquellObj obj)
 {
     baseObj = obj;
 }
Exemplo n.º 10
0
 public ArrayObj(AsquellObj[] array)
     : this(new AsquellObj(array))
 {
 }
Exemplo n.º 11
0
 public static void SetMemory(MemoryBlock memory, AsquellObj to, AsquellObj from)
 {
     memory.ModifyVariable(to, from);
 }
Exemplo n.º 12
0
 public void ModifyVariable(string name, AsquellObj value)
 {
     _globals[name] = value;
 }
Exemplo n.º 13
0
 private object arrayOfArgs(AsquellObj[] args, int argCount)
 {
     List<AsquellObj> tmp = new List<AsquellObj>();
     for (int i = argCount; i < args.Length; i++)
     {
         tmp.Add(args[i]);
     }
     return tmp.ToArray();
 }
Exemplo n.º 14
0
 public NumericObj(AsquellObj obj)
 {
     baseObj = obj;
 }
Exemplo n.º 15
0
 public AsquellObj GetVariable(AsquellObj name)
 {
     if (name.Type == AsquellObjectType.RunTimeValue)
         return GetVariable(name.Value.ToString());
     else
         throw new ArgumentException("Can not read from memory value where name is type '" + name.Type.ToString() + "'!");
 }
Exemplo n.º 16
0
 public void ModifyVariable(AsquellObj name, AsquellObj value)
 {
     if (name.Type == AsquellObjectType.RunTimeValue)
         ModifyVariable(name.Value.ToString(), value);
     else
         throw new ArgumentException("Can not write to memory value where name is type '"+name.Type.ToString()+"'!");
 }
Exemplo n.º 17
0
 private static NumericObj getNumericObj(AsquellObj obj, MemoryBlock memory)
 {
     obj = memory.GetRealVariable(obj);
     if (obj.Type == AsquellObjectType.Number)
         return new NumericObj(obj);
     else
         return null;
 }
Exemplo n.º 18
0
 public static void DeleteMemory(MemoryBlock memory, AsquellObj block)
 {
     memory.DeleteVariable(block);
 }