| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 4448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4459 RawObject* raw = Object::Allocate(Field::kInstanceKind, | 4459 RawObject* raw = Object::Allocate(Field::kInstanceKind, |
| 4460 Field::InstanceSize(), | 4460 Field::InstanceSize(), |
| 4461 Heap::kOld); | 4461 Heap::kOld); |
| 4462 return reinterpret_cast<RawField*>(raw); | 4462 return reinterpret_cast<RawField*>(raw); |
| 4463 } | 4463 } |
| 4464 | 4464 |
| 4465 | 4465 |
| 4466 RawField* Field::New(const String& name, | 4466 RawField* Field::New(const String& name, |
| 4467 bool is_static, | 4467 bool is_static, |
| 4468 bool is_final, | 4468 bool is_final, |
| 4469 bool is_const, |
| 4469 intptr_t token_pos) { | 4470 intptr_t token_pos) { |
| 4470 ASSERT(name.IsOneByteString()); | 4471 ASSERT(name.IsOneByteString()); |
| 4471 const Field& result = Field::Handle(Field::New()); | 4472 const Field& result = Field::Handle(Field::New()); |
| 4472 result.set_name(name); | 4473 result.set_name(name); |
| 4473 result.set_is_static(is_static); | 4474 result.set_is_static(is_static); |
| 4474 if (is_static) { | 4475 if (is_static) { |
| 4475 result.set_value(Instance::Handle()); | 4476 result.set_value(Instance::Handle()); |
| 4476 } else { | 4477 } else { |
| 4477 result.SetOffset(0); | 4478 result.SetOffset(0); |
| 4478 } | 4479 } |
| 4479 result.set_is_final(is_final); | 4480 result.set_is_final(is_final); |
| 4481 result.set_is_const(is_const); |
| 4480 result.set_token_pos(token_pos); | 4482 result.set_token_pos(token_pos); |
| 4481 result.set_has_initializer(false); | 4483 result.set_has_initializer(false); |
| 4482 return result.raw(); | 4484 return result.raw(); |
| 4483 } | 4485 } |
| 4484 | 4486 |
| 4485 | 4487 |
| 4486 const char* Field::ToCString() const { | 4488 const char* Field::ToCString() const { |
| 4487 const char* kF0 = is_static() ? " static" : ""; | 4489 const char* kF0 = is_static() ? " static" : ""; |
| 4488 const char* kF1 = is_final() ? " final" : ""; | 4490 const char* kF1 = is_final() ? " final" : ""; |
| 4489 const char* kFormat = "Field <%s.%s>:%s%s"; | 4491 const char* kF2 = is_const() ? " const" : ""; |
| 4492 const char* kFormat = "Field <%s.%s>:%s%s%s"; |
| 4490 const char* field_name = String::Handle(name()).ToCString(); | 4493 const char* field_name = String::Handle(name()).ToCString(); |
| 4491 const Class& cls = Class::Handle(owner()); | 4494 const Class& cls = Class::Handle(owner()); |
| 4492 const char* cls_name = String::Handle(cls.Name()).ToCString(); | 4495 const char* cls_name = String::Handle(cls.Name()).ToCString(); |
| 4493 intptr_t len = | 4496 intptr_t len = |
| 4494 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1) + 1; | 4497 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; |
| 4495 char* chars = reinterpret_cast<char*>( | 4498 char* chars = reinterpret_cast<char*>( |
| 4496 Isolate::Current()->current_zone()->Allocate(len)); | 4499 Isolate::Current()->current_zone()->Allocate(len)); |
| 4497 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1); | 4500 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); |
| 4498 return chars; | 4501 return chars; |
| 4499 } | 4502 } |
| 4500 | 4503 |
| 4501 | 4504 |
| 4502 void LiteralToken::set_literal(const String& literal) const { | 4505 void LiteralToken::set_literal(const String& literal) const { |
| 4503 StorePointer(&raw_ptr()->literal_, literal.raw()); | 4506 StorePointer(&raw_ptr()->literal_, literal.raw()); |
| 4504 } | 4507 } |
| 4505 | 4508 |
| 4506 | 4509 |
| 4507 void LiteralToken::set_value(const Object& value) const { | 4510 void LiteralToken::set_value(const Object& value) const { |
| (...skipping 6338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10846 const String& str = String::Handle(pattern()); | 10849 const String& str = String::Handle(pattern()); |
| 10847 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10850 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10848 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10851 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10849 char* chars = reinterpret_cast<char*>( | 10852 char* chars = reinterpret_cast<char*>( |
| 10850 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10853 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10851 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10854 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10852 return chars; | 10855 return chars; |
| 10853 } | 10856 } |
| 10854 | 10857 |
| 10855 } // namespace dart | 10858 } // namespace dart |
| OLD | NEW |