public UndeclaredVariableException(RelinqScriptExpression root, VariableExpression ve, Closure closure) 
     : base(JSToCSharpExceptionType.UndeclaredVariable, root, ve)
 {
     Closure = closure;
     Name = ve.Name;
 }
Beispiel #2
0
 private void InferVariable(VariableExpression ve, TypeInferenceCache cache)
 {
     if (ve.GetClosure().ContainsKey(ve.Name))
     {
         var lambda = ve.GetClosure()[ve.Name];
         var funcType = ((Lambda)cache[lambda]).Type;
         var argIndex = Array.IndexOf(lambda.Args.ToArray(), ve.Name);
         cache.Add(ve, funcType.GetFunctionDesc().Args.ElementAt(argIndex));
     }
     else
     {
         throw new UndeclaredVariableException(Root, ve, ve.GetClosure());
     }
 }
        private LinqExpression CompileVariable(VariableExpression ve, CompilationContext ctx)
        {
            if (!ctx.Closure.ContainsKey(ve.Name))
            {
                throw new CSharpBuilderException(
                    JSToCSharpExceptionType.UnexpectedInferredAst, Ast, ve, ctx);
            }

            return ctx.Closure[ve.Name];
        }