| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(FullCodeGenSyntaxChecker); | 57 DISALLOW_COPY_AND_ASSIGN(FullCodeGenSyntaxChecker); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 | 60 |
| 61 // ----------------------------------------------------------------------------- | 61 // ----------------------------------------------------------------------------- |
| 62 // Full code generator. | 62 // Full code generator. |
| 63 | 63 |
| 64 class FullCodeGenerator: public AstVisitor { | 64 class FullCodeGenerator: public AstVisitor { |
| 65 public: | 65 public: |
| 66 enum Mode { |
| 67 PRIMARY, |
| 68 SECONDARY |
| 69 }; |
| 70 |
| 66 FullCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) | 71 FullCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) |
| 67 : masm_(masm), | 72 : masm_(masm), |
| 68 function_(NULL), | |
| 69 script_(script), | 73 script_(script), |
| 70 is_eval_(is_eval), | 74 is_eval_(is_eval), |
| 75 function_(NULL), |
| 71 nesting_stack_(NULL), | 76 nesting_stack_(NULL), |
| 72 loop_depth_(0), | 77 loop_depth_(0), |
| 73 location_(kStack), | 78 location_(kStack), |
| 74 true_label_(NULL), | 79 true_label_(NULL), |
| 75 false_label_(NULL) { | 80 false_label_(NULL) { |
| 76 } | 81 } |
| 77 | 82 |
| 78 static Handle<Code> MakeCode(FunctionLiteral* fun, | 83 static Handle<Code> MakeCode(FunctionLiteral* fun, |
| 79 Handle<Script> script, | 84 Handle<Script> script, |
| 80 bool is_eval); | 85 bool is_eval); |
| 81 | 86 |
| 82 void Generate(FunctionLiteral* fun); | 87 void Generate(FunctionLiteral* fun, Mode mode); |
| 83 | 88 |
| 84 private: | 89 private: |
| 85 class Breakable; | 90 class Breakable; |
| 86 class Iteration; | 91 class Iteration; |
| 87 class TryCatch; | 92 class TryCatch; |
| 88 class TryFinally; | 93 class TryFinally; |
| 89 class Finally; | 94 class Finally; |
| 90 class ForIn; | 95 class ForIn; |
| 91 | 96 |
| 92 class NestedStatement BASE_EMBEDDED { | 97 class NestedStatement BASE_EMBEDDED { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void LoadContextField(Register dst, int context_index); | 420 void LoadContextField(Register dst, int context_index); |
| 416 | 421 |
| 417 // AST node visit functions. | 422 // AST node visit functions. |
| 418 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 423 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 419 AST_NODE_LIST(DECLARE_VISIT) | 424 AST_NODE_LIST(DECLARE_VISIT) |
| 420 #undef DECLARE_VISIT | 425 #undef DECLARE_VISIT |
| 421 // Handles the shortcutted logical binary operations in VisitBinaryOperation. | 426 // Handles the shortcutted logical binary operations in VisitBinaryOperation. |
| 422 void EmitLogicalOperation(BinaryOperation* expr); | 427 void EmitLogicalOperation(BinaryOperation* expr); |
| 423 | 428 |
| 424 MacroAssembler* masm_; | 429 MacroAssembler* masm_; |
| 425 FunctionLiteral* function_; | |
| 426 Handle<Script> script_; | 430 Handle<Script> script_; |
| 427 bool is_eval_; | 431 bool is_eval_; |
| 432 |
| 433 FunctionLiteral* function_; |
| 434 |
| 428 Label return_label_; | 435 Label return_label_; |
| 429 NestedStatement* nesting_stack_; | 436 NestedStatement* nesting_stack_; |
| 430 int loop_depth_; | 437 int loop_depth_; |
| 431 | 438 |
| 432 Expression::Context context_; | 439 Expression::Context context_; |
| 433 Location location_; | 440 Location location_; |
| 434 Label* true_label_; | 441 Label* true_label_; |
| 435 Label* false_label_; | 442 Label* false_label_; |
| 436 | 443 |
| 437 friend class NestedStatement; | 444 friend class NestedStatement; |
| 438 | 445 |
| 439 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 446 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 440 }; | 447 }; |
| 441 | 448 |
| 442 | 449 |
| 443 } } // namespace v8::internal | 450 } } // namespace v8::internal |
| 444 | 451 |
| 445 #endif // V8_FULL_CODEGEN_H_ | 452 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |