Esempio n. 1
0
        public object VisitFunctionStmt(Stmt.Function stmt)
        {
            BasilFunction function = new BasilFunction(stmt, environment, false);

            environment.Define(stmt.name.lexeme, function);
            return(null);
        }
Esempio n. 2
0
 public object VisitFunctionStmt(Stmt.Function stmt)
 {
     Declare(stmt.name);
     Define(stmt.name);
     ResolveFunction(stmt, FunctionType.Function);
     return(null);
 }
Esempio n. 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;
        }
Esempio n. 4
0
 public BasilFunction(Stmt.Function declaration, Environment closure, bool isInitializer)
 {
     this.declaration   = declaration;
     this.closure       = closure;
     this.isInitializer = isInitializer;
 }