예제 #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() + "'!");
 }
예제 #2
0
        public FormMemoryDetail(AsquellObj obj)
        {
            InitializeComponent();
            _obj = obj;

            doGenerics();
            doSpecifics();
        }
예제 #3
0
파일: ArrayObj.cs 프로젝트: Turnerj/Asquell
 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);
 }
예제 #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!");
 }
예제 #5
0
파일: MathCore.cs 프로젝트: Turnerj/Asquell
 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!");
 }
예제 #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;
        }
예제 #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!");
 }
예제 #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;
        }
예제 #9
0
파일: ArrayObj.cs 프로젝트: Turnerj/Asquell
 public ArrayObj(AsquellObj obj)
 {
     baseObj = obj;
 }
예제 #10
0
파일: ArrayObj.cs 프로젝트: Turnerj/Asquell
 public ArrayObj(AsquellObj[] array)
     : this(new AsquellObj(array))
 {
 }
예제 #11
0
 public static void SetMemory(MemoryBlock memory, AsquellObj to, AsquellObj from)
 {
     memory.ModifyVariable(to, from);
 }
예제 #12
0
 public void ModifyVariable(string name, AsquellObj value)
 {
     _globals[name] = value;
 }
예제 #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();
 }
예제 #14
0
 public NumericObj(AsquellObj obj)
 {
     baseObj = obj;
 }
예제 #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() + "'!");
 }
예제 #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()+"'!");
 }
예제 #17
0
파일: MathCore.cs 프로젝트: Turnerj/Asquell
 private static NumericObj getNumericObj(AsquellObj obj, MemoryBlock memory)
 {
     obj = memory.GetRealVariable(obj);
     if (obj.Type == AsquellObjectType.Number)
         return new NumericObj(obj);
     else
         return null;
 }
예제 #18
0
 public static void DeleteMemory(MemoryBlock memory, AsquellObj block)
 {
     memory.DeleteVariable(block);
 }