예제 #1
0
    public override void Eval(Program program)
    {
        object retVal = expression.Eval(program);

        program.SetRetVal(retVal);
        program.Return();
    }
예제 #2
0
 public override void Eval(Program program)
 {
     while ((bool)check.Eval(program))
     {
         statements.Eval(program);
     }
 }
예제 #3
0
    public override void Eval(Program program)
    {
        bool b = (bool)check.Eval(program);

        if (b)
        {
            statements.Eval(program);
        }
        else
        {
            foreach (var stmnt in elseifs)
            {
                if ((bool)stmnt.check.Eval(program))
                {
                    stmnt.statements.Eval(program);
                    return;
                }
            }

            if (elseStatements != null)
            {
                elseStatements.Eval(program);
            }
        }
    }
예제 #4
0
    public override void Eval(Program program)
    {
        object value = expression.Eval(program);

        if (indexers.Count == 0)
        {
            program.SetVar(varName, value);
        }
        else
        {
            object cur = program.GetVar(varName);

            for (int i = 0; i < indexers.Count; i++)
            {
                int index = (int)indexers[i].Eval(program);

                if (cur is object[])
                {
                    object[] array = (object[])cur;

                    if (i == indexers.Count - 1)
                    {
                        array[index] = value;
                    }
                    else
                    {
                        cur = array[index];
                    }
                }
                else if (cur is List <object> )
                {
                    List <object> array = (List <object>)cur;

                    if (i == indexers.Count - 1)
                    {
                        array[index] = value;
                    }
                    else
                    {
                        cur = array[index];
                    }
                }
            }
        }

        //Debug.Log("Setting var '" + varName + "' to " + value);
    }
예제 #5
0
    public override object Eval(Program program)
    {
        object baseObj = baseExpr.Eval(program);
        object index   = indexExpr.Eval(program);

        if (baseObj is object[])
        {
            object[] array = (object[])baseObj;
            return(array[(int)index]);
        }
        else if (baseObj is List <object> )
        {
            List <object> array = (List <object>)baseObj;
            return(array[(int)index]);
        }
        return(null);
    }
예제 #6
0
    public override object Eval(Program program)
    {
        object lhs = left.Eval(program);
        object rhs = right.Eval(program);

        if (lhs.GetType() == typeof(string) || rhs.GetType() == typeof(string))
        {
            return(EvalString(lhs.ToString(), rhs.ToString()));
        }

        if (lhs.GetType() == typeof(int))
        {
            return(EvalInt((int)lhs, (int)rhs));
        }

        if (lhs.GetType() == typeof(bool))
        {
            return(EvalBool((bool)lhs, (bool)rhs));
        }

        return(null);
    }