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

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