OLD | NEW |
1 // Copyright (c) 2011, 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 #ifndef VM_BIGINT_STORE_H_ | 5 #ifndef VM_BIGINT_STORE_H_ |
6 #define VM_BIGINT_STORE_H_ | 6 #define VM_BIGINT_STORE_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #include "vm/isolate.h" |
9 | 10 |
10 namespace dart { | 11 namespace dart { |
11 | 12 |
12 // Use to store teporary BIGNUMs. | 13 // Use to store teporary BIGNUMs. |
13 class BigintStore { | 14 class BigintStore { |
14 public: | 15 public: |
15 BigintStore() : bn_(NULL), bn_ctx_(NULL) {} | 16 BigintStore() : bn_(NULL), bn_ctx_(NULL) {} |
16 ~BigintStore() { | 17 ~BigintStore() { |
17 BN_free(bn_); | 18 BN_free(bn_); |
18 BN_CTX_free(bn_ctx_); | 19 BN_CTX_free(bn_ctx_); |
19 } | 20 } |
20 | 21 |
21 static BigintStore* Get() { | 22 static BigintStore* Get() { |
22 BigintStore* store = Isolate::Current()->bigint_store(); | 23 BigintStore* store = Isolate::Current()->bigint_store(); |
23 if (store == NULL) { | 24 if (store == NULL) { |
24 store = new BigintStore(); | 25 store = new BigintStore(); |
25 Isolate::Current()->set_bigint_store(store); | 26 Isolate::Current()->set_bigint_store(store); |
26 } | 27 } |
27 return store; | 28 return store; |
28 } | 29 } |
29 | 30 |
30 BIGNUM* bn_; | 31 BIGNUM* bn_; |
31 BN_CTX* bn_ctx_; | 32 BN_CTX* bn_ctx_; |
32 }; | 33 }; |
33 | 34 |
34 } // namespace dart | 35 } // namespace dart |
35 | 36 |
36 #endif // VM_BIGINT_STORE_H_ | 37 #endif // VM_BIGINT_STORE_H_ |
OLD | NEW |