IBoundExpr IUnboundExprVisitor<IBoundExpr>.Visit(LocalFuncExpr expr)
        {
            // create a unique name for the local function
            string name = mContext.NameGenerator.Generate();

            // create a reference to it
            var reference = new FuncRefExpr(expr.Position,
                new NameExpr(expr.Position, name),
                expr.Type.Parameter.Unbound);

            // lift the local function into a new top-level function
            var function = new Function(expr.Position, name,
                expr.Type, expr.ParamNames, expr.Body);

            function.BindSearchSpace(mContext.SearchSpace);

            // bind it
            mContext.Compiler.Functions.AddAndBind(mContext.Compiler, function);

            // return the reference to it
            return reference.Accept(this);

            //### bob: eventually, will need to handle closures
        }
 public virtual IUnboundExpr Transform(LocalFuncExpr expr)
 {
     return(expr);
 }
Beispiel #3
0
 IUnboundExpr IUnboundExprVisitor <IUnboundExpr> .Visit(LocalFuncExpr expr)
 {
     throw new NotImplementedException();
 }