| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" |
| 9 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| 10 #include "vm/handles_impl.h" | 11 #include "vm/handles_impl.h" |
| 11 #include "vm/object.h" | 12 #include "vm/object.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 class FlowGraphVisitor; | 16 class FlowGraphVisitor; |
| 16 class LocalVariable; | 17 class LocalVariable; |
| 17 | 18 |
| 18 // Computations and values. | 19 // Computations and values. |
| 19 // | 20 // |
| 20 // <Computation> ::= <Value> | 21 // <Computation> ::= <Value> |
| 21 // | AssertAssignable <Value> <AbstractType> | 22 // | AssertAssignable <Value> <AbstractType> |
| 22 // | InstanceCall <cstring> <Value> ... | 23 // | InstanceCall <cstring> <Value> ... |
| 23 // | StaticCall <Function> <Value> ... | 24 // | StaticCall <Function> <Value> ... |
| 24 // | LoadLocal <LocalVariable> | 25 // | LoadLocal <LocalVariable> |
| 25 // | StoreLocal <LocalVariable> <Value> | 26 // | StoreLocal <LocalVariable> <Value> |
| 26 // | StrictCompare <Token::kind> <Value> <Value> | 27 // | StrictCompare <Token::kind> <Value> <Value> |
| 28 // | NativeCall <String> <NativeFunction> <int> <bool> |
| 27 // | 29 // |
| 28 // <Value> ::= Temp <int> | 30 // <Value> ::= Temp <int> |
| 29 // | Constant <Instance> | 31 // | Constant <Instance> |
| 30 | 32 |
| 31 // M is a two argument macro. It is applied to each concrete value's | 33 // M is a two argument macro. It is applied to each concrete value's |
| 32 // typename and classname. | 34 // typename and classname. |
| 33 #define FOR_EACH_VALUE(M) \ | 35 #define FOR_EACH_VALUE(M) \ |
| 34 M(Temp, TempVal) \ | 36 M(Temp, TempVal) \ |
| 35 M(Constant, ConstantVal) | 37 M(Constant, ConstantVal) |
| 36 | 38 |
| 37 // M is a two argument macro. It is applied to each concrete instruction's | 39 // M is a two argument macro. It is applied to each concrete instruction's |
| 38 // (including the values) typename and classname. | 40 // (including the values) typename and classname. |
| 39 #define FOR_EACH_COMPUTATION(M) \ | 41 #define FOR_EACH_COMPUTATION(M) \ |
| 40 FOR_EACH_VALUE(M) \ | 42 FOR_EACH_VALUE(M) \ |
| 41 M(AssertAssignable, AssertAssignableComp) \ | 43 M(AssertAssignable, AssertAssignableComp) \ |
| 42 M(InstanceCall, InstanceCallComp) \ | 44 M(InstanceCall, InstanceCallComp) \ |
| 43 M(StrictCompare, StrictCompareComp) \ | |
| 44 M(StaticCall, StaticCallComp) \ | 45 M(StaticCall, StaticCallComp) \ |
| 45 M(LoadLocal, LoadLocalComp) \ | 46 M(LoadLocal, LoadLocalComp) \ |
| 46 M(StoreLocal, StoreLocalComp) | 47 M(StoreLocal, StoreLocalComp) \ |
| 48 M(StrictCompare, StrictCompareComp) \ |
| 49 M(NativeCall, NativeCallComp) \ |
| 47 | 50 |
| 48 | 51 |
| 49 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 52 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 50 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 53 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 51 #undef FORWARD_DECLARATION | 54 #undef FORWARD_DECLARATION |
| 52 | 55 |
| 53 class Computation : public ZoneAllocated { | 56 class Computation : public ZoneAllocated { |
| 54 public: | 57 public: |
| 55 Computation() { } | 58 Computation() { } |
| 56 | 59 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const LocalVariable& local() const { return local_; } | 232 const LocalVariable& local() const { return local_; } |
| 230 Value* value() const { return value_; } | 233 Value* value() const { return value_; } |
| 231 | 234 |
| 232 private: | 235 private: |
| 233 const LocalVariable& local_; | 236 const LocalVariable& local_; |
| 234 Value* value_; | 237 Value* value_; |
| 235 | 238 |
| 236 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 239 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 237 }; | 240 }; |
| 238 | 241 |
| 242 |
| 243 class NativeCallComp : public Computation { |
| 244 public: |
| 245 explicit NativeCallComp(NativeBodyNode* node) : ast_node_(*node) {} |
| 246 |
| 247 DECLARE_COMPUTATION(NativeCall) |
| 248 |
| 249 const String& native_name() const { |
| 250 return ast_node_.native_c_function_name(); |
| 251 } |
| 252 |
| 253 private: |
| 254 const NativeBodyNode& ast_node_; |
| 255 |
| 256 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); |
| 257 }; |
| 258 |
| 239 #undef DECLARE_COMPUTATION | 259 #undef DECLARE_COMPUTATION |
| 240 | 260 |
| 241 | 261 |
| 242 // Instructions. | 262 // Instructions. |
| 243 // | 263 // |
| 244 // <Instruction> ::= Do <Computation> <Instruction> | 264 // <Instruction> ::= Do <Computation> <Instruction> |
| 245 // | Bind <int> <Computation> <Instruction> | 265 // | Bind <int> <Computation> <Instruction> |
| 246 // | Return <Value> | 266 // | Return <Value> |
| 247 // | Branch <Value> <Instruction> <Instruction> | 267 // | Branch <Value> <Instruction> <Instruction> |
| 248 // | Empty <Instruction> | 268 // | Empty <Instruction> |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 #undef DECLARE_VISIT_INSTRUCTION | 527 #undef DECLARE_VISIT_INSTRUCTION |
| 508 | 528 |
| 509 private: | 529 private: |
| 510 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 530 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 511 }; | 531 }; |
| 512 | 532 |
| 513 | 533 |
| 514 } // namespace dart | 534 } // namespace dart |
| 515 | 535 |
| 516 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 536 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |