Beispiel #1
0
 public void InitVariable(string variable)
 {
     VariableIdent ident = new VariableIdent()
     {
         FrameId = frameStack.Peek().Id,
         VariableName = variable
     };
     if (!variables.ContainsKey(ident))
     {
         variables[ident] = new ObjectVariable(new Undefined());
     }
 }
Beispiel #2
0
 protected void PushFunc(object arg)
 {
     try
     {
         ObjectVariable var = new ObjectVariable(new Function() { EntryPoint = Module.Code.Pointer + 1, ArgsNumber = Int32.Parse(arg.ToString()) });
         StackVM.Push(var);
         GoUntilReturn();
     }
     catch (FormatException ex)
     {
         throw new CodeException(Module.Code.Pointer.ToString() + ": invalid arg in PushFunc; found: " + arg.ToString() + ", expected integer");
     }
 }
Beispiel #3
0
 public static bool operator >=(Variable v1, Variable v2)
 {
     if ((v1.Value is Undefined) || (v2.Value is Undefined) || (v1.Value is NaN) || (v2.Value is NaN))
     {
         return false;
     }
     if (v1.Value is bool)
     {
         v1 = new ObjectVariable((bool)v1.Value ? 1 : 0);
     }
     if (v2.Value is bool)
     {
         v2 = new ObjectVariable((bool)v2.Value ? 1 : 0);
     }
     if ((v1.Value.ToString() != NaN.Value) || (v2.Value.ToString() != NaN.Value))
     {
         double res1;
         double res2;
         if (double.TryParse(v1.Value.ToString(), out res1))
         {
             if (double.TryParse(v2.Value.ToString(), out res2))
             {
                 return res1 >= res2;
             }
         }
     }
     return v1.Value.ToString().Equals(v2.Value.ToString());
 }
Beispiel #4
0
 public static bool operator >(Variable v1, Variable v2)
 {
     if (v1.Value is bool)
     {
         v1 = new ObjectVariable((bool)v1.Value ? 1 : 0);
     }
     if (v2.Value is bool)
     {
         v2 = new ObjectVariable((bool)v2.Value ? 1 : 0);
     }
     double res1;
     double res2;
     bool isRes1 = false;
     bool isRes2 = false;
     isRes1 = double.TryParse(v1.Value.ToString(), out res1);
     isRes2 = double.TryParse(v2.Value.ToString(), out res2);
     if ((isRes1) && (isRes2))
     {
         return res1 > res2;
     }
     return false;
 }