Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 9646008: Implementing ConstructorCall. (part I) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 17 matching lines...) Expand all
28 // | StrictCompare <Token::kind> <Value> <Value> 28 // | StrictCompare <Token::kind> <Value> <Value>
29 // | NativeCall <NativeBodyNode> 29 // | NativeCall <NativeBodyNode>
30 // | StoreIndexed <Value> <Value> <Value> 30 // | StoreIndexed <Value> <Value> <Value>
31 // | InstanceSetter <String> <Value> <Value> 31 // | InstanceSetter <String> <Value> <Value>
32 // | LoadInstanceField <LoadInstanceFieldNode> <Value> 32 // | LoadInstanceField <LoadInstanceFieldNode> <Value>
33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> 33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value>
34 // | LoadStaticField <Field> 34 // | LoadStaticField <Field>
35 // | StoreStaticField <Field> <Value> 35 // | StoreStaticField <Field> <Value>
36 // | BooleanNegate <Value> 36 // | BooleanNegate <Value>
37 // | InstanceOf <Value> <Type> 37 // | InstanceOf <Value> <Type>
38 // | AllocateObject <ConstructorCallNode>
38 // 39 //
39 // <Value> ::= 40 // <Value> ::=
40 // Temp <int> 41 // Temp <int>
41 // | Constant <Instance> 42 // | Constant <Instance>
42 43
43 // M is a two argument macro. It is applied to each concrete value's 44 // M is a two argument macro. It is applied to each concrete value's
44 // typename and classname. 45 // typename and classname.
45 #define FOR_EACH_VALUE(M) \ 46 #define FOR_EACH_VALUE(M) \
46 M(Temp, TempVal) \ 47 M(Temp, TempVal) \
47 M(Constant, ConstantVal) \ 48 M(Constant, ConstantVal) \
(...skipping 12 matching lines...) Expand all
60 M(NativeCall, NativeCallComp) \ 61 M(NativeCall, NativeCallComp) \
61 M(StoreIndexed, StoreIndexedComp) \ 62 M(StoreIndexed, StoreIndexedComp) \
62 M(InstanceSetter, InstanceSetterComp) \ 63 M(InstanceSetter, InstanceSetterComp) \
63 M(LoadInstanceField, LoadInstanceFieldComp) \ 64 M(LoadInstanceField, LoadInstanceFieldComp) \
64 M(StoreInstanceField, StoreInstanceFieldComp) \ 65 M(StoreInstanceField, StoreInstanceFieldComp) \
65 M(LoadStaticField, LoadStaticFieldComp) \ 66 M(LoadStaticField, LoadStaticFieldComp) \
66 M(StoreStaticField, StoreStaticFieldComp) \ 67 M(StoreStaticField, StoreStaticFieldComp) \
67 M(BooleanNegate, BooleanNegateComp) \ 68 M(BooleanNegate, BooleanNegateComp) \
68 M(InstanceOf, InstanceOfComp) \ 69 M(InstanceOf, InstanceOfComp) \
69 M(CreateArray, CreateArrayComp) \ 70 M(CreateArray, CreateArrayComp) \
71 M(AllocateObject, AllocateObjectComp) \
70 72
71 73
72 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 74 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
73 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 75 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
74 #undef FORWARD_DECLARATION 76 #undef FORWARD_DECLARATION
75 77
76 class Computation : public ZoneAllocated { 78 class Computation : public ZoneAllocated {
77 public: 79 public:
78 Computation() { } 80 Computation() { }
79 81
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 123
122 private: 124 private:
123 const intptr_t index_; 125 const intptr_t index_;
124 126
125 DISALLOW_COPY_AND_ASSIGN(TempVal); 127 DISALLOW_COPY_AND_ASSIGN(TempVal);
126 }; 128 };
127 129
128 130
129 class ConstantVal: public Value { 131 class ConstantVal: public Value {
130 public: 132 public:
131 explicit ConstantVal(const Instance& instance) : instance_(instance) { 133 explicit ConstantVal(const Object& value) : value_(value) {
132 ASSERT(instance.IsZoneHandle()); 134 ASSERT(value.IsZoneHandle());
133 } 135 }
134 136
135 DECLARE_VALUE(Constant) 137 DECLARE_VALUE(Constant)
136 138
137 const Instance& instance() const { return instance_; } 139 const Object& value() const { return value_; }
138 140
139 private: 141 private:
140 const Instance& instance_; 142 const Object& value_;
141 143
142 DISALLOW_COPY_AND_ASSIGN(ConstantVal); 144 DISALLOW_COPY_AND_ASSIGN(ConstantVal);
143 }; 145 };
144 146
145 #undef DECLARE_VALUE 147 #undef DECLARE_VALUE
146 148
147 149
148 class AssertAssignableComp : public Computation { 150 class AssertAssignableComp : public Computation {
149 public: 151 public:
150 AssertAssignableComp(Value* value, const AbstractType& type) 152 AssertAssignableComp(Value* value, const AbstractType& type)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const Token::Kind kind_; 223 const Token::Kind kind_;
222 Value* left_; 224 Value* left_;
223 Value* right_; 225 Value* right_;
224 226
225 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 227 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
226 }; 228 };
227 229
228 230
229 class StaticCallComp : public Computation { 231 class StaticCallComp : public Computation {
230 public: 232 public:
231 StaticCallComp(StaticCallNode* node, ZoneGrowableArray<Value*>* arguments) 233 StaticCallComp(intptr_t token_index,
232 : ast_node_(*node), arguments_(arguments) { } 234 const Function& function,
235 const Array& argument_names,
236 ZoneGrowableArray<Value*>* arguments)
237 : token_index_(token_index),
238 function_(function),
239 argument_names_(argument_names),
240 arguments_(arguments) {
241 ASSERT(function.IsZoneHandle());
242 ASSERT(argument_names.IsZoneHandle());
243 }
233 244
234 DECLARE_COMPUTATION(StaticCall) 245 DECLARE_COMPUTATION(StaticCall)
235 246
236 // Accessors forwarded to the AST node. 247 // Accessors forwarded to the AST node.
237 const Function& function() const { return ast_node_.function(); } 248 const Function& function() const { return function_; }
238 const Array& argument_names() const { return ast_node_.arguments()->names(); } 249 const Array& argument_names() const { return argument_names_; }
239 intptr_t token_index() const { return ast_node_.token_index(); } 250 intptr_t token_index() const { return token_index_; }
240 251
241 int ArgumentCount() const { return arguments_->length(); } 252 int ArgumentCount() const { return arguments_->length(); }
242 Value* ArgumentAt(int index) const { return (*arguments_)[index]; } 253 Value* ArgumentAt(int index) const { return (*arguments_)[index]; }
243 254
244 private: 255 private:
245 const StaticCallNode& ast_node_; 256 const intptr_t token_index_;
257 const Function& function_;
258 const Array& argument_names_;
246 ZoneGrowableArray<Value*>* arguments_; 259 ZoneGrowableArray<Value*>* arguments_;
247 260
248 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); 261 DISALLOW_COPY_AND_ASSIGN(StaticCallComp);
249 }; 262 };
250 263
251 264
252 class LoadLocalComp : public Computation { 265 class LoadLocalComp : public Computation {
253 public: 266 public:
254 explicit LoadLocalComp(const LocalVariable& local) : local_(local) { } 267 explicit LoadLocalComp(const LocalVariable& local) : local_(local) { }
255 268
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 const intptr_t node_id_; 517 const intptr_t node_id_;
505 const intptr_t token_index_; 518 const intptr_t token_index_;
506 Value* value_; 519 Value* value_;
507 const AbstractType& type_; 520 const AbstractType& type_;
508 const bool negate_result_; 521 const bool negate_result_;
509 522
510 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); 523 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp);
511 }; 524 };
512 525
513 526
527 class AllocateObjectComp : public Computation {
528 public:
529 AllocateObjectComp(ConstructorCallNode* node,
530 ZoneGrowableArray<Value*>* arguments)
531 : ast_node_(*node), arguments_(arguments) {
532 // Either no arguments or one type-argument and one instantiator.
533 ASSERT(arguments->is_empty() || (arguments->length() == 2));
534 }
535
536 DECLARE_COMPUTATION(AllocateObject)
537
538 const Function& constructor() const { return ast_node_.constructor(); }
539 intptr_t token_index() const { return ast_node_.token_index(); }
540 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; }
541
542 private:
543 const ConstructorCallNode& ast_node_;
544 ZoneGrowableArray<Value*>* const arguments_;
545 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp);
546 };
547
548
514 class CreateArrayComp : public Computation { 549 class CreateArrayComp : public Computation {
515 public: 550 public:
516 CreateArrayComp(ArrayNode* node, ZoneGrowableArray<Value*>* elements) 551 CreateArrayComp(ArrayNode* node, ZoneGrowableArray<Value*>* elements)
517 : ast_node_(*node), elements_(elements) { } 552 : ast_node_(*node), elements_(elements) { }
518 553
519 DECLARE_COMPUTATION(CreateArray) 554 DECLARE_COMPUTATION(CreateArray)
520 555
521 intptr_t token_index() const { return ast_node_.token_index(); } 556 intptr_t token_index() const { return ast_node_.token_index(); }
522 const AbstractTypeArguments& type_arguments() const { 557 const AbstractTypeArguments& type_arguments() const {
523 return ast_node_.type_arguments(); 558 return ast_node_.type_arguments();
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 #undef DECLARE_VISIT_INSTRUCTION 910 #undef DECLARE_VISIT_INSTRUCTION
876 911
877 private: 912 private:
878 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 913 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
879 }; 914 };
880 915
881 916
882 } // namespace dart 917 } // namespace dart
883 918
884 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 919 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698