示例#1
0
 public Nothing VisitFunctionStmt(Stmt.Function stmt)
 {
     Declare(stmt.Name);
     Define(stmt.Name);
     ResolveFunction(stmt, FunctionType.Function);
     return(Nothing.AtAll);
 }
示例#2
0
        public Nothing VisitFunctionStmt(Stmt.Function stmt)
        {
            LoxFunction function = new LoxFunction(stmt, environment, false);

            environment.Define(stmt.Name.Lexeme, function);

            return(Nothing.AtAll);
        }
示例#3
0
        private void ResolveFunction(Stmt.Function function, FunctionType type)
        {
            FunctionType enclosingFunction = currentFunction;

            currentFunction = type;
            BeginScope();
            foreach (var param in function.Parameters)
            {
                Declare(param);
                Define(param);
            }
            Resolve(function.Body);
            EndScope();
            currentFunction = enclosingFunction;
        }
示例#4
0
 public LoxFunction(Stmt.Function declaration, Environment closure, bool isInitializer)
 {
     this.declaration   = declaration;
     this.closure       = closure;
     this.isInitializer = isInitializer;
 }