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 RawInstance; | 18 class RawInstance; |
19 class Script; | 19 class Script; |
20 class SequenceNode; | 20 class SequenceNode; |
21 | 21 |
22 DECLARE_RUNTIME_ENTRY(CompileFunction); | 22 DECLARE_RUNTIME_ENTRY(CompileFunction); |
23 | 23 |
24 class Compiler : public AllStatic { | 24 class Compiler : public AllStatic { |
25 public: | 25 public: |
26 // Extracts class, interface, function symbols from the script and populates | 26 // Extracts class, interface, function symbols from the script and populates |
27 // the symbol tables and the class dictionary of the library. | 27 // the symbol tables and the class dictionary of the library. |
28 // | 28 static void Compile(const Library& library, const Script& script); |
29 // Returns Error::null() if there is no compilation error. | |
30 static RawError* Compile(const Library& library, const Script& script); | |
31 | 29 |
32 // Generates code for given function and sets its code field. | 30 // Generates code for given function and sets its code field. |
33 // | 31 static void CompileFunction(const Function& function); |
34 // Returns Error::null() if there is no compilation error. | |
35 static RawError* CompileFunction(const Function& function); | |
36 | 32 |
37 // Generates optimized code for function. | 33 // Generates optimized code for function. |
38 // | 34 static void CompileOptimizedFunction(const Function& function); |
39 // Returns Error::null() if there is no compilation error. | |
40 static RawError* CompileOptimizedFunction(const Function& function); | |
41 | 35 |
42 // Generates and executes code for a given code fragment, e.g. a | 36 // Generates and executes code for a given code fragment, e.g. a |
43 // compile time constant expression. Returns the result returned | 37 // compile time constant expression. Returns the result returned |
44 // by the fragment. | 38 // by the fragment. |
45 // | 39 static RawInstance* ExecuteOnce(SequenceNode* fragment); |
46 // The return value is either a RawInstance on success or a RawError | |
47 // on compilation failure. | |
48 static RawObject* ExecuteOnce(SequenceNode* fragment); | |
49 | 40 |
50 // Eagerly compiles all functions in a class. | 41 // Eagerly compiles all functions in a class. |
51 // | 42 static void CompileAllFunctions(const Class& cls); |
52 // Returns Error::null() if there is no compilation error. | |
53 static RawError* CompileAllFunctions(const Class& cls); | |
54 }; | 43 }; |
55 | 44 |
56 } // namespace dart | 45 } // namespace dart |
57 | 46 |
58 #endif // VM_COMPILER_H_ | 47 #endif // VM_COMPILER_H_ |
OLD | NEW |