| 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 #include "vm/ast.h" | 5 #include "vm/ast.h" |
| 6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
| 7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 | 10 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return prefix_ ? "instance_field_pre_++" : "instance_field_post_++"; | 312 return prefix_ ? "instance_field_pre_++" : "instance_field_post_++"; |
| 313 case Token::kDECR: | 313 case Token::kDECR: |
| 314 return prefix_ ? "instance_field_pre_--" : "instance_field_post_--"; | 314 return prefix_ ? "instance_field_pre_--" : "instance_field_post_--"; |
| 315 default: | 315 default: |
| 316 UNREACHABLE(); | 316 UNREACHABLE(); |
| 317 return NULL; | 317 return NULL; |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 | 321 |
| 322 const char* IncrOpStaticFieldNode::Name() const { | |
| 323 switch (kind_) { | |
| 324 case Token::kINCR: | |
| 325 return prefix_ ? "static_field_pre_++" : "static_field_post_++"; | |
| 326 case Token::kDECR: | |
| 327 return prefix_ ? "static_field_pre_--" : "static_field_post_--"; | |
| 328 default: | |
| 329 UNREACHABLE(); | |
| 330 return NULL; | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 | |
| 335 const char* JumpNode::Name() const { | 322 const char* JumpNode::Name() const { |
| 336 return Token::Str(kind_); | 323 return Token::Str(kind_); |
| 337 } | 324 } |
| 338 | 325 |
| 339 | 326 |
| 340 const char* IncrOpIndexedNode::Name() const { | 327 const char* IncrOpIndexedNode::Name() const { |
| 341 switch (kind_) { | 328 switch (kind_) { |
| 342 case Token::kINCR: | 329 case Token::kINCR: |
| 343 return prefix_ ? "indexed_pre_++" : "indexed_post_++"; | 330 return prefix_ ? "indexed_pre_++" : "indexed_post_++"; |
| 344 case Token::kDECR: | 331 case Token::kDECR: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 369 | 356 |
| 370 | 357 |
| 371 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { | 358 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { |
| 372 return new StoreStaticFieldNode(token_index(), field(), rhs); | 359 return new StoreStaticFieldNode(token_index(), field(), rhs); |
| 373 } | 360 } |
| 374 | 361 |
| 375 | 362 |
| 376 AstNode* LoadStaticFieldNode::MakeIncrOpNode(intptr_t token_index, | 363 AstNode* LoadStaticFieldNode::MakeIncrOpNode(intptr_t token_index, |
| 377 Token::Kind kind, | 364 Token::Kind kind, |
| 378 bool is_prefix) { | 365 bool is_prefix) { |
| 379 return new IncrOpStaticFieldNode(token_index, kind, is_prefix, field()); | 366 UNIMPLEMENTED(); |
| 367 return NULL; |
| 380 } | 368 } |
| 381 | 369 |
| 382 | 370 |
| 383 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) { | 371 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) { |
| 384 return new InstanceSetterNode(token_index(), receiver(), field_name(), rhs); | 372 return new InstanceSetterNode(token_index(), receiver(), field_name(), rhs); |
| 385 } | 373 } |
| 386 | 374 |
| 387 | 375 |
| 388 AstNode* InstanceGetterNode::MakeIncrOpNode(intptr_t token_index, | 376 AstNode* InstanceGetterNode::MakeIncrOpNode(intptr_t token_index, |
| 389 Token::Kind kind, | 377 Token::Kind kind, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 413 | 401 |
| 414 | 402 |
| 415 AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) { | 403 AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) { |
| 416 return new StaticSetterNode(token_index(), cls(), field_name(), rhs); | 404 return new StaticSetterNode(token_index(), cls(), field_name(), rhs); |
| 417 } | 405 } |
| 418 | 406 |
| 419 | 407 |
| 420 AstNode* StaticGetterNode::MakeIncrOpNode(intptr_t token_index, | 408 AstNode* StaticGetterNode::MakeIncrOpNode(intptr_t token_index, |
| 421 Token::Kind kind, | 409 Token::Kind kind, |
| 422 bool is_prefix) { | 410 bool is_prefix) { |
| 423 return new IncrOpStaticFieldNode(token_index, | 411 UNIMPLEMENTED(); |
| 424 kind, | 412 return NULL; |
| 425 is_prefix, | |
| 426 cls(), | |
| 427 field_name()); | |
| 428 } | 413 } |
| 429 | 414 |
| 430 | 415 |
| 431 const Instance* StaticGetterNode::EvalConstExpr() const { | 416 const Instance* StaticGetterNode::EvalConstExpr() const { |
| 432 const String& getter_name = | 417 const String& getter_name = |
| 433 String::Handle(Field::GetterName(this->field_name())); | 418 String::Handle(Field::GetterName(this->field_name())); |
| 434 const Function& getter_func = | 419 const Function& getter_func = |
| 435 Function::Handle(this->cls().LookupStaticFunction(getter_name)); | 420 Function::Handle(this->cls().LookupStaticFunction(getter_name)); |
| 436 if (getter_func.IsNull() || !getter_func.is_const()) { | 421 if (getter_func.IsNull() || !getter_func.is_const()) { |
| 437 return NULL; | 422 return NULL; |
| 438 } | 423 } |
| 439 GrowableArray<const Object*> arguments; | 424 GrowableArray<const Object*> arguments; |
| 440 const Array& kNoArgumentNames = Array::Handle(); | 425 const Array& kNoArgumentNames = Array::Handle(); |
| 441 const Object& result = | 426 const Object& result = |
| 442 Object::Handle(DartEntry::InvokeStatic(getter_func, | 427 Object::Handle(DartEntry::InvokeStatic(getter_func, |
| 443 arguments, | 428 arguments, |
| 444 kNoArgumentNames)); | 429 kNoArgumentNames)); |
| 445 if (result.IsError() || result.IsNull()) { | 430 if (result.IsError() || result.IsNull()) { |
| 446 // TODO(turnidge): We could get better error messages by returning | 431 // TODO(turnidge): We could get better error messages by returning |
| 447 // the Error object directly to the parser. This will involve | 432 // the Error object directly to the parser. This will involve |
| 448 // replumbing all of the EvalConstExpr methods. | 433 // replumbing all of the EvalConstExpr methods. |
| 449 return NULL; | 434 return NULL; |
| 450 } | 435 } |
| 451 Instance& field_value = Instance::ZoneHandle(); | 436 Instance& field_value = Instance::ZoneHandle(); |
| 452 field_value ^= result.raw(); | 437 field_value ^= result.raw(); |
| 453 return &field_value; | 438 return &field_value; |
| 454 } | 439 } |
| 455 | 440 |
| 456 } // namespace dart | 441 } // namespace dart |
| OLD | NEW |