Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a variable expression with symbol scope, context, script refernce set.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static Expr IdentWith(TokenData token)
 {
     var exp = new VariableExpr();
     exp.Name = _withStack.Peek();
     SetupContext(exp, token);
     return exp;
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Evaluate
        /// </summary>
        /// <returns></returns>
        public object VisitVariable(VariableExpr expr)
        {
            // Case 1: memory variable has highest precendence
            var name = expr.Name;
            if (this.Ctx.Memory.Contains(name))
            {
                var val = this.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");
        }
Ejemplo n.º 5
0
 public object VisitVariable(VariableExpr expr)
 {
     return null;
 }