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 "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 type.set_token_pos(token_pos); | 2120 type.set_token_pos(token_pos); |
2121 return type.raw(); | 2121 return type.raw(); |
2122 } | 2122 } |
2123 | 2123 |
2124 | 2124 |
2125 RawUnresolvedClass* UnresolvedClass::New() { | 2125 RawUnresolvedClass* UnresolvedClass::New() { |
2126 const Class& unresolved_class_class = | 2126 const Class& unresolved_class_class = |
2127 Class::Handle(Object::unresolved_class_class()); | 2127 Class::Handle(Object::unresolved_class_class()); |
2128 RawObject* raw = Object::Allocate(unresolved_class_class, | 2128 RawObject* raw = Object::Allocate(unresolved_class_class, |
2129 UnresolvedClass::InstanceSize(), | 2129 UnresolvedClass::InstanceSize(), |
2130 Heap::kNew); | 2130 Heap::kOld); |
2131 return reinterpret_cast<RawUnresolvedClass*>(raw); | 2131 return reinterpret_cast<RawUnresolvedClass*>(raw); |
2132 } | 2132 } |
2133 | 2133 |
2134 | 2134 |
2135 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { | 2135 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { |
2136 ASSERT(token_pos >= 0); | 2136 ASSERT(token_pos >= 0); |
2137 raw_ptr()->token_pos_ = token_pos; | 2137 raw_ptr()->token_pos_ = token_pos; |
2138 } | 2138 } |
2139 | 2139 |
2140 | 2140 |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4329 Heap::kOld); | 4329 Heap::kOld); |
4330 return reinterpret_cast<RawLiteralToken*>(raw); | 4330 return reinterpret_cast<RawLiteralToken*>(raw); |
4331 } | 4331 } |
4332 | 4332 |
4333 | 4333 |
4334 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { | 4334 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { |
4335 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); | 4335 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); |
4336 result.set_kind(kind); | 4336 result.set_kind(kind); |
4337 result.set_literal(literal); | 4337 result.set_literal(literal); |
4338 if (kind == Token::kINTEGER) { | 4338 if (kind == Token::kINTEGER) { |
4339 const Integer& value = Integer::Handle(Integer::New(literal)); | 4339 const Integer& value = Integer::Handle(Integer::New(literal, Heap::kOld)); |
4340 result.set_value(value); | 4340 result.set_value(value); |
4341 } else if (kind == Token::kDOUBLE) { | 4341 } else if (kind == Token::kDOUBLE) { |
4342 const Double& value = Double::Handle(Double::NewCanonical(literal)); | 4342 const Double& value = Double::Handle(Double::NewCanonical(literal)); |
4343 result.set_value(value); | 4343 result.set_value(value); |
4344 } else { | 4344 } else { |
4345 ASSERT(Token::NeedsLiteralToken(kind)); | 4345 ASSERT(Token::NeedsLiteralToken(kind)); |
4346 result.set_value(literal); | 4346 result.set_value(literal); |
4347 } | 4347 } |
4348 return result.raw(); | 4348 return result.raw(); |
4349 } | 4349 } |
(...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7342 } | 7342 } |
7343 | 7343 |
7344 | 7344 |
7345 const char* Integer::ToCString() const { | 7345 const char* Integer::ToCString() const { |
7346 // Integer is an interface. No instances of Integer should exist. | 7346 // Integer is an interface. No instances of Integer should exist. |
7347 UNREACHABLE(); | 7347 UNREACHABLE(); |
7348 return "Integer"; | 7348 return "Integer"; |
7349 } | 7349 } |
7350 | 7350 |
7351 | 7351 |
7352 RawInteger* Integer::New(const String& str) { | 7352 RawInteger* Integer::New(const String& str, Heap::Space space) { |
| 7353 // TODO(iposva): If returning a big integer it will not necessarily be in the |
| 7354 // requested space. |
7353 const Bigint& big = Bigint::Handle(Bigint::New(str)); | 7355 const Bigint& big = Bigint::Handle(Bigint::New(str)); |
7354 if (BigintOperations::FitsIntoSmi(big)) { | 7356 if (BigintOperations::FitsIntoSmi(big)) { |
7355 return BigintOperations::ToSmi(big); | 7357 return BigintOperations::ToSmi(big); |
7356 } else if (BigintOperations::FitsIntoMint(big)) { | 7358 } else if (BigintOperations::FitsIntoMint(big)) { |
7357 return Mint::New(BigintOperations::ToMint(big)); | 7359 return Mint::New(BigintOperations::ToMint(big), space); |
7358 } else { | 7360 } else { |
7359 return big.raw(); | 7361 return big.raw(); |
7360 } | 7362 } |
7361 } | 7363 } |
7362 | 7364 |
7363 | 7365 |
7364 RawInteger* Integer::New(int64_t value) { | 7366 RawInteger* Integer::New(int64_t value, Heap::Space space) { |
7365 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { | 7367 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { |
7366 return Smi::New(value); | 7368 return Smi::New(value); |
7367 } | 7369 } |
7368 return Mint::New(value); | 7370 return Mint::New(value, space); |
7369 } | 7371 } |
7370 | 7372 |
7371 | 7373 |
7372 double Integer::AsDoubleValue() const { | 7374 double Integer::AsDoubleValue() const { |
7373 UNIMPLEMENTED(); | 7375 UNIMPLEMENTED(); |
7374 return 0.0; | 7376 return 0.0; |
7375 } | 7377 } |
7376 | 7378 |
7377 | 7379 |
7378 int64_t Integer::AsInt64Value() const { | 7380 int64_t Integer::AsInt64Value() const { |
(...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10258 const String& str = String::Handle(pattern()); | 10260 const String& str = String::Handle(pattern()); |
10259 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10261 const char* format = "JSRegExp: pattern=%s flags=%s"; |
10260 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10262 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
10261 char* chars = reinterpret_cast<char*>( | 10263 char* chars = reinterpret_cast<char*>( |
10262 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10264 Isolate::Current()->current_zone()->Allocate(len + 1)); |
10263 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10265 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
10264 return chars; | 10266 return chars; |
10265 } | 10267 } |
10266 | 10268 |
10267 } // namespace dart | 10269 } // namespace dart |
OLD | NEW |