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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 for (intptr_t i = 0; i < this->length(); i++) { | 76 for (intptr_t i = 0; i < this->length(); i++) { |
77 ElementAt(i)->Visit(visitor); | 77 ElementAt(i)->Visit(visitor); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 // TODO(srdjan): Add code for logical negation. | 82 // TODO(srdjan): Add code for logical negation. |
83 AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) { | 83 AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) { |
84 if (unary_op_kind == Token::kSUB) { | 84 if (unary_op_kind == Token::kSUB) { |
85 if (literal().IsSmi()) { | 85 if (literal().IsSmi()) { |
86 Smi& smi = Smi::Handle(); | 86 const Smi& smi = Smi::Cast(literal()); |
87 smi ^= literal().raw(); | |
88 const Instance& literal = | 87 const Instance& literal = |
89 Instance::ZoneHandle(Integer::New(-smi.Value())); | 88 Instance::ZoneHandle(Integer::New(-smi.Value())); |
90 return new LiteralNode(this->token_pos(), literal); | 89 return new LiteralNode(this->token_pos(), literal); |
91 } | 90 } |
92 if (literal().IsDouble()) { | 91 if (literal().IsDouble()) { |
93 Double& dbl = Double::Handle(); | 92 const Double& dbl = Double::Cast(literal()); |
94 dbl ^= literal().raw(); | |
95 // Preserve negative zero. | 93 // Preserve negative zero. |
96 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value()); | 94 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value()); |
97 Double& double_instance = | 95 Double& double_instance = |
98 Double::ZoneHandle(Double::New(new_value, Heap::kOld)); | 96 Double::ZoneHandle(Double::New(new_value, Heap::kOld)); |
99 double_instance ^= double_instance.Canonicalize(); | 97 double_instance ^= double_instance.Canonicalize(); |
100 return new LiteralNode(this->token_pos(), double_instance); | 98 return new LiteralNode(this->token_pos(), double_instance); |
101 } | 99 } |
102 } | 100 } |
103 return NULL; | 101 return NULL; |
104 } | 102 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 const Object& result = | 367 const Object& result = |
370 Object::Handle(DartEntry::InvokeStatic(getter_func, | 368 Object::Handle(DartEntry::InvokeStatic(getter_func, |
371 arguments, | 369 arguments, |
372 kNoArgumentNames)); | 370 kNoArgumentNames)); |
373 if (result.IsError() || result.IsNull()) { | 371 if (result.IsError() || result.IsNull()) { |
374 // TODO(turnidge): We could get better error messages by returning | 372 // TODO(turnidge): We could get better error messages by returning |
375 // the Error object directly to the parser. This will involve | 373 // the Error object directly to the parser. This will involve |
376 // replumbing all of the EvalConstExpr methods. | 374 // replumbing all of the EvalConstExpr methods. |
377 return NULL; | 375 return NULL; |
378 } | 376 } |
379 Instance& field_value = Instance::ZoneHandle(); | 377 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
380 field_value ^= result.raw(); | |
381 return &field_value; | |
382 } | 378 } |
383 | 379 |
384 } // namespace dart | 380 } // namespace dart |
OLD | NEW |