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() + "'!"); }
public FormMemoryDetail(AsquellObj obj) { InitializeComponent(); _obj = obj; doGenerics(); doSpecifics(); }
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); }
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!"); }
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!"); }
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; }
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!"); }
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; }
public ArrayObj(AsquellObj obj) { baseObj = obj; }
public ArrayObj(AsquellObj[] array) : this(new AsquellObj(array)) { }
public static void SetMemory(MemoryBlock memory, AsquellObj to, AsquellObj from) { memory.ModifyVariable(to, from); }
public void ModifyVariable(string name, AsquellObj value) { _globals[name] = value; }
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(); }
public NumericObj(AsquellObj obj) { baseObj = obj; }
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() + "'!"); }
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()+"'!"); }
private static NumericObj getNumericObj(AsquellObj obj, MemoryBlock memory) { obj = memory.GetRealVariable(obj); if (obj.Type == AsquellObjectType.Number) return new NumericObj(obj); else return null; }
public static void DeleteMemory(MemoryBlock memory, AsquellObj block) { memory.DeleteVariable(block); }