Ejemplo n.º 1
0
 public UndeclaredVariableException(RelinqScriptExpression root, VariableExpression ve, Closure closure) 
     : base(JSToCSharpExceptionType.UndeclaredVariable, root, ve)
 {
     Closure = closure;
     Name = ve.Name;
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 3
0
        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];
        }