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 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4327 Heap::kOld); | 4327 Heap::kOld); |
4328 return reinterpret_cast<RawLiteralToken*>(raw); | 4328 return reinterpret_cast<RawLiteralToken*>(raw); |
4329 } | 4329 } |
4330 | 4330 |
4331 | 4331 |
4332 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { | 4332 RawLiteralToken* LiteralToken::New(Token::Kind kind, const String& literal) { |
4333 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); | 4333 const LiteralToken& result = LiteralToken::Handle(LiteralToken::New()); |
4334 result.set_kind(kind); | 4334 result.set_kind(kind); |
4335 result.set_literal(literal); | 4335 result.set_literal(literal); |
4336 if (kind == Token::kINTEGER) { | 4336 if (kind == Token::kINTEGER) { |
4337 const Integer& value = Integer::Handle(Integer::New(literal)); | 4337 const Integer& value = Integer::Handle(Integer::New(literal, Heap::kOld)); |
4338 result.set_value(value); | 4338 result.set_value(value); |
4339 } else if (kind == Token::kDOUBLE) { | 4339 } else if (kind == Token::kDOUBLE) { |
4340 const Double& value = Double::Handle(Double::NewCanonical(literal)); | 4340 const Double& value = Double::Handle(Double::NewCanonical(literal)); |
4341 result.set_value(value); | 4341 result.set_value(value); |
4342 } else { | 4342 } else { |
4343 ASSERT(Token::NeedsLiteralToken(kind)); | 4343 ASSERT(Token::NeedsLiteralToken(kind)); |
4344 result.set_value(literal); | 4344 result.set_value(literal); |
4345 } | 4345 } |
4346 return result.raw(); | 4346 return result.raw(); |
4347 } | 4347 } |
(...skipping 2978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7326 } | 7326 } |
7327 | 7327 |
7328 | 7328 |
7329 const char* Integer::ToCString() const { | 7329 const char* Integer::ToCString() const { |
7330 // Integer is an interface. No instances of Integer should exist. | 7330 // Integer is an interface. No instances of Integer should exist. |
7331 UNREACHABLE(); | 7331 UNREACHABLE(); |
7332 return "Integer"; | 7332 return "Integer"; |
7333 } | 7333 } |
7334 | 7334 |
7335 | 7335 |
7336 RawInteger* Integer::New(const String& str) { | 7336 RawInteger* Integer::New(const String& str, Heap::Space space) { |
| 7337 // TODO(iposva): If returning a big integer it will not necessarily be in the |
| 7338 // requested space. |
7337 const Bigint& big = Bigint::Handle(Bigint::New(str)); | 7339 const Bigint& big = Bigint::Handle(Bigint::New(str)); |
7338 if (BigintOperations::FitsIntoSmi(big)) { | 7340 if (BigintOperations::FitsIntoSmi(big)) { |
7339 return BigintOperations::ToSmi(big); | 7341 return BigintOperations::ToSmi(big); |
7340 } else if (BigintOperations::FitsIntoMint(big)) { | 7342 } else if (BigintOperations::FitsIntoMint(big)) { |
7341 return Mint::New(BigintOperations::ToMint(big)); | 7343 return Mint::New(BigintOperations::ToMint(big), space); |
7342 } else { | 7344 } else { |
7343 return big.raw(); | 7345 return big.raw(); |
7344 } | 7346 } |
7345 } | 7347 } |
7346 | 7348 |
7347 | 7349 |
7348 RawInteger* Integer::New(int64_t value) { | 7350 RawInteger* Integer::New(int64_t value, Heap::Space space) { |
7349 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { | 7351 if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) { |
7350 return Smi::New(value); | 7352 return Smi::New(value); |
7351 } | 7353 } |
7352 return Mint::New(value); | 7354 return Mint::New(value, space); |
7353 } | 7355 } |
7354 | 7356 |
7355 | 7357 |
7356 double Integer::AsDoubleValue() const { | 7358 double Integer::AsDoubleValue() const { |
7357 UNIMPLEMENTED(); | 7359 UNIMPLEMENTED(); |
7358 return 0.0; | 7360 return 0.0; |
7359 } | 7361 } |
7360 | 7362 |
7361 | 7363 |
7362 int64_t Integer::AsInt64Value() const { | 7364 int64_t Integer::AsInt64Value() const { |
(...skipping 2843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10206 const String& str = String::Handle(pattern()); | 10208 const String& str = String::Handle(pattern()); |
10207 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10209 const char* format = "JSRegExp: pattern=%s flags=%s"; |
10208 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10210 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
10209 char* chars = reinterpret_cast<char*>( | 10211 char* chars = reinterpret_cast<char*>( |
10210 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10212 Isolate::Current()->current_zone()->Allocate(len + 1)); |
10211 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10213 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
10212 return chars; | 10214 return chars; |
10213 } | 10215 } |
10214 | 10216 |
10215 } // namespace dart | 10217 } // namespace dart |
OLD | NEW |