Handle-ize BytecodeEmitter.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of JITCraft.
7 * JITCraft is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #ifndef _include_bytecode_compiler_h_
20 #define _include_bytecode_compiler_h_
23 #include "BytecodeEmitter.h"
24 #include "Functions.h"
30 class BytecodeCompiler : public AstVisitor
34 BytecodeEmitter emitter_;
35 ScopedRoot<Module> module_;
36 ScopedRoot<FixedArray> locals_;
42 BytecodeEmitter::Label *bk_;
43 BytecodeEmitter::Label *ct_;
48 LoopScope(Scope *scope, BytecodeEmitter::Label *bk, BytecodeEmitter::Label *ct,
64 BytecodeEmitter::Label *break_() {
67 BytecodeEmitter::Label *continue_() {
80 BytecodeCompiler *bc_;
84 AutoEnterScope(BytecodeCompiler *bc, Scope *scope)
97 void recordLifoSlot(Scope *scope);
98 void unwindTo(Scope *scope);
99 void visitForTest(Expression *expression, BytecodeEmitter::Label *label, bool onTrue);
100 Function *compileFunction(Module *module, FunctionStatement *fun);
101 void visitForALU(Type *needed, Expression *node);
104 BytecodeCompiler(Zone *zone, ParseTree *tree, Module *module);
109 void visit(NameProxy *name);
110 void visit(Assignment *node);
111 void visit(BinaryExpression *node);
112 void visit(ReturnStatement *node);
113 void visit(ForStatement *node);
114 void visit(BlockStatement *node);
115 void visit(VariableDeclaration *node);
116 void visit(IntegerLiteral *node);
117 void visit(FloatLiteral *node);
118 void visit(StringLiteral *node);
119 void visit(ExpressionStatement *node);
120 void visit(FunctionStatement *node);
121 void visit(CallExpression *node);
122 void visit(IfStatement *node);
123 void visit(IndexExpression *node);
124 void visit(EnumStatement *node);
125 void visit(WhileStatement *node);
126 void visit(BreakStatement *node);
127 void visit(ContinueStatement *node);
128 void visit(IncDecExpression *node);
133 #endif // _include_bytecode_generator_h_