コード例 #1
0
        public object visitStmtFunctionStmt(StmtFunction stmt)
        {
            LoxFunction func = new LoxFunction(stmt, enviroment);

            enviroment.define(stmt.name.lexeme, func);
            return(null);
        }
コード例 #2
0
        public object visitStmtFunctionStmt(StmtFunction stmt)
        {
            declare(stmt.name);
            define(stmt.name);

            resolveFunction(stmt, FunctionType.FUNCTION);
            return(null);
        }
コード例 #3
0
        void resolveFunction(StmtFunction stmt, FunctionType fType)
        {
            FunctionType encFunction = currentFunction;

            currentFunction = fType;

            beginScope();
            foreach (Token param in stmt.arguments)
            {
                declare(param);
                define(param);
            }
            resolve(stmt.body);
            endScope();

            currentFunction = encFunction;
        }
コード例 #4
0
ファイル: LoxCallable.cs プロジェクト: Terrabalt/CsLox
 public LoxFunction(StmtFunction _declaration, Enviroment _closure)
 {
     closure     = _closure;
     declaration = _declaration;
 }