public object VisitVariable(VariableExpr expr) { return null; }
/// <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; }
/// <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; }
/// <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"); }
/// <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; }