예제 #1
0
 public object VisitVariable(VariableExpr expr)
 {
     return null;
 }
예제 #2
0
        /// <summary>
        /// Check that variable exists and that it is not used befor it is declared.
        /// </summary>
        /// <param name="semActs">The semantic analyser</param>
        /// <param name="exp">The variable expression</param>
        private SemanticCheckResult CheckVariable(SemActs semActs, VariableExpr exp)
        {
            if(!_currentSymScope.Contains(exp.Name))
                return NodeError("Variable " + exp.Name + " does not exist", exp);

            return SemanticCheckResult.Valid;
        }
예제 #3
0
 /// <summary>
 /// Creates a variable expression with symbol scope, context, script refernce set.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static Expr Ident(string name, TokenData token)
 {
     var exp = new VariableExpr();
     exp.Name = name;
     SetupContext(exp, token);
     return exp;
 }
예제 #4
0
        /// <summary>
        /// Evaluate
        /// </summary>
        /// <returns></returns>
        public static object EvalVariable(VariableExpr expr)
        {
            // Case 1: memory variable has highest precendence
            var name = expr.Name;
            if (Ctx.Memory.Contains(name))
            {
                var val = Ctx.Memory.Get<object>(name);
                return val;
            }
            // Case 2: check function now.
            if (expr.SymScope.IsFunction(name))
            {

            }
            throw ExceptionHelper.BuildRunTimeException(expr, "variable : " + name + " does not exist");
        }
예제 #5
0
 /// <summary>
 /// Creates a variable expression with symbol scope, context, script refernce set.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public Expr ToIdentExpr(string name, TokenData token)
 {
     var exp = new VariableExpr(name);
     this.SetupContext(exp, token);
     return exp;
 }