| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_COMPILER_H_ | 5 #ifndef VM_COMPILER_H_ |
| 6 #define VM_COMPILER_H_ | 6 #define VM_COMPILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 // Forward declarations. | 14 // Forward declarations. |
| 15 class Class; | 15 class Class; |
| 16 class Function; | 16 class Function; |
| 17 class Library; | 17 class Library; |
| 18 class ParsedFunction; |
| 18 class RawInstance; | 19 class RawInstance; |
| 19 class Script; | 20 class Script; |
| 20 class SequenceNode; | 21 class SequenceNode; |
| 21 | 22 |
| 22 DECLARE_RUNTIME_ENTRY(CompileFunction); | 23 DECLARE_RUNTIME_ENTRY(CompileFunction); |
| 23 | 24 |
| 24 class Compiler : public AllStatic { | 25 class Compiler : public AllStatic { |
| 25 public: | 26 public: |
| 26 // Extracts class, interface, function symbols from the script and populates | 27 // Extracts class, interface, function symbols from the script and populates |
| 27 // the symbol tables and the class dictionary of the library. | 28 // the symbol tables and the class dictionary of the library. |
| 28 // | 29 // |
| 29 // Returns Error::null() if there is no compilation error. | 30 // Returns Error::null() if there is no compilation error. |
| 30 static RawError* Compile(const Library& library, const Script& script); | 31 static RawError* Compile(const Library& library, const Script& script); |
| 31 | 32 |
| 32 // Generates code for given function and sets its code field. | 33 // Generates code for given function and sets its code field. |
| 33 // | 34 // |
| 34 // Returns Error::null() if there is no compilation error. | 35 // Returns Error::null() if there is no compilation error. |
| 35 static RawError* CompileFunction(const Function& function); | 36 static RawError* CompileFunction(const Function& function); |
| 36 | 37 |
| 37 // Generates optimized code for function. | 38 // Generates optimized code for function. |
| 38 // | 39 // |
| 39 // Returns Error::null() if there is no compilation error. | 40 // Returns Error::null() if there is no compilation error. |
| 40 static RawError* CompileOptimizedFunction(const Function& function); | 41 static RawError* CompileOptimizedFunction(const Function& function); |
| 41 | 42 |
| 43 // Generates code for given parsed function (without parsing it again) and |
| 44 // sets its code field. |
| 45 // |
| 46 // Returns Error::null() if there is no compilation error. |
| 47 static RawError* CompileParsedFunction(const ParsedFunction& parsed_function); |
| 48 |
| 42 // Generates and executes code for a given code fragment, e.g. a | 49 // Generates and executes code for a given code fragment, e.g. a |
| 43 // compile time constant expression. Returns the result returned | 50 // compile time constant expression. Returns the result returned |
| 44 // by the fragment. | 51 // by the fragment. |
| 45 // | 52 // |
| 46 // The return value is either a RawInstance on success or a RawError | 53 // The return value is either a RawInstance on success or a RawError |
| 47 // on compilation failure. | 54 // on compilation failure. |
| 48 static RawObject* ExecuteOnce(SequenceNode* fragment); | 55 static RawObject* ExecuteOnce(SequenceNode* fragment); |
| 49 | 56 |
| 50 // Eagerly compiles all functions in a class. | 57 // Eagerly compiles all functions in a class. |
| 51 // | 58 // |
| 52 // Returns Error::null() if there is no compilation error. | 59 // Returns Error::null() if there is no compilation error. |
| 53 static RawError* CompileAllFunctions(const Class& cls); | 60 static RawError* CompileAllFunctions(const Class& cls); |
| 54 }; | 61 }; |
| 55 | 62 |
| 56 } // namespace dart | 63 } // namespace dart |
| 57 | 64 |
| 58 #endif // VM_COMPILER_H_ | 65 #endif // VM_COMPILER_H_ |
| OLD | NEW |