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