OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "v8.h" | 31 #include "v8.h" |
32 | 32 |
33 #include "ast.h" | 33 #include "ast.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 | 38 |
39 class FastCodeGenerator: public AstVisitor { | 39 class FastCodeGenerator: public AstVisitor { |
40 public: | 40 public: |
41 explicit FastCodeGenerator(MacroAssembler* masm) | 41 FastCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) |
42 : masm_(masm), function_(NULL) { | 42 : masm_(masm), function_(NULL), script_(script), is_eval_(is_eval) { |
43 } | 43 } |
44 | 44 |
45 static Handle<Code> MakeCode(FunctionLiteral* fun, Handle<Script> script); | 45 static Handle<Code> MakeCode(FunctionLiteral* fun, |
| 46 Handle<Script> script, |
| 47 bool is_eval); |
46 | 48 |
47 void Generate(FunctionLiteral* fun); | 49 void Generate(FunctionLiteral* fun); |
48 | 50 |
49 private: | 51 private: |
50 int SlotOffset(Slot* slot); | 52 int SlotOffset(Slot* slot); |
51 | 53 |
| 54 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 55 Handle<JSFunction> BuildBoilerplate(FunctionLiteral* fun); |
| 56 void DeclareGlobals(Handle<FixedArray> pairs); |
| 57 |
52 void SetFunctionPosition(FunctionLiteral* fun); | 58 void SetFunctionPosition(FunctionLiteral* fun); |
53 void SetReturnPosition(FunctionLiteral* fun); | 59 void SetReturnPosition(FunctionLiteral* fun); |
54 void SetStatementPosition(Statement* stmt); | 60 void SetStatementPosition(Statement* stmt); |
55 void SetSourcePosition(int pos); | 61 void SetSourcePosition(int pos); |
56 | 62 |
57 // AST node visit functions. | 63 // AST node visit functions. |
58 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 64 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
59 AST_NODE_LIST(DECLARE_VISIT) | 65 AST_NODE_LIST(DECLARE_VISIT) |
60 #undef DECLARE_VISIT | 66 #undef DECLARE_VISIT |
61 | 67 |
62 MacroAssembler* masm_; | 68 MacroAssembler* masm_; |
63 FunctionLiteral* function_; | 69 FunctionLiteral* function_; |
| 70 Handle<Script> script_; |
| 71 bool is_eval_; |
64 | 72 |
65 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); | 73 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); |
66 }; | 74 }; |
67 | 75 |
68 | 76 |
69 } } // namespace v8::internal | 77 } } // namespace v8::internal |
70 | 78 |
71 #endif // V8_FAST_CODEGEN_H_ | 79 #endif // V8_FAST_CODEGEN_H_ |
OLD | NEW |