Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1040)

Side by Side Diff: runtime/vm/bigint_operations.h

Issue 8539034: Add methods for creating Bigint objects from unsigned 64-bit integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/bigint_operations.cc » ('j') | runtime/vm/bigint_operations.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef VM_BIGINT_OPERATIONS_H_ 5 #ifndef VM_BIGINT_OPERATIONS_H_
6 #define VM_BIGINT_OPERATIONS_H_ 6 #define VM_BIGINT_OPERATIONS_H_
7 7
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
11 11
12 // This should be folded into OpenSSL 12 // This should be folded into OpenSSL
13 #undef BN_abs_is_word 13 #undef BN_abs_is_word
14 #define BN_abs_is_word(a, w) (((a)->top == 1) \ 14 #define BN_abs_is_word(a, w) (((a)->top == 1) \
15 && ((a)->d[0] == static_cast<BN_ULONG>(w))) 15 && ((a)->d[0] == static_cast<BN_ULONG>(w)))
16 16
17 namespace dart { 17 namespace dart {
18 18
19 class BigintOperations : public AllStatic { 19 class BigintOperations : public AllStatic {
20 public: 20 public:
21 static RawBigint* NewFromSmi(const Smi& smi, Heap::Space space = Heap::kNew); 21 static RawBigint* NewFromSmi(const Smi& smi, Heap::Space space = Heap::kNew);
22 static RawBigint* NewFromInt64(int64_t value, Heap::Space space = Heap::kNew); 22 static RawBigint* NewFromInt64(int64_t value, Heap::Space space = Heap::kNew);
23 static RawBigint* NewFromUInt64(uint64_t value,
24 Heap::Space space = Heap::kNew);
23 // The given string must be a valid integer representation. It may be 25 // The given string must be a valid integer representation. It may be
24 // prefixed by a minus and/or "0x". 26 // prefixed by a minus and/or "0x".
25 // Returns Bigint::null() if the string cannot be parsed. 27 // Returns Bigint::null() if the string cannot be parsed.
26 static RawBigint* NewFromCString(const char* str, 28 static RawBigint* NewFromCString(const char* str,
27 Heap::Space space = Heap::kNew); 29 Heap::Space space = Heap::kNew);
28 static RawBigint* NewFromDouble(double d, Heap::Space space = Heap::kNew); 30 static RawBigint* NewFromDouble(double d, Heap::Space space = Heap::kNew);
29 31
30 // The given string must be a nul-terminated string of hex-digits. It must 32 // The given string must be a nul-terminated string of hex-digits. It must
31 // only contain hex-digits. No sign or leading "0x" is allowed. 33 // only contain hex-digits. No sign or leading "0x" is allowed.
32 static RawBigint* FromHexCString(const char* str, 34 static RawBigint* FromHexCString(const char* str,
(...skipping 15 matching lines...) Expand all
48 uword (*allocator)(intptr_t size)); 50 uword (*allocator)(intptr_t size));
49 static const char* ToDecCString(const Bigint& bigint, 51 static const char* ToDecCString(const Bigint& bigint,
50 uword (*allocator)(intptr_t size)); 52 uword (*allocator)(intptr_t size));
51 53
52 static bool FitsIntoSmi(const Bigint& bigint); 54 static bool FitsIntoSmi(const Bigint& bigint);
53 static RawSmi* ToSmi(const Bigint& bigint); 55 static RawSmi* ToSmi(const Bigint& bigint);
54 56
55 static bool FitsIntoInt64(const Bigint& bigint); 57 static bool FitsIntoInt64(const Bigint& bigint);
56 static int64_t ToInt64(const Bigint& bigint); 58 static int64_t ToInt64(const Bigint& bigint);
57 59
60 static bool FitsIntoUInt64(const Bigint& bigint);
61 static uint64_t ToUInt64(const Bigint& bigint);
62
58 static RawDouble* ToDouble(const Bigint& bigint); 63 static RawDouble* ToDouble(const Bigint& bigint);
59 64
60 static RawBigint* Add(const Bigint& a, const Bigint& b); 65 static RawBigint* Add(const Bigint& a, const Bigint& b);
61 static RawBigint* Subtract(const Bigint& a, const Bigint& b); 66 static RawBigint* Subtract(const Bigint& a, const Bigint& b);
62 static RawBigint* Multiply(const Bigint& a, const Bigint& b); 67 static RawBigint* Multiply(const Bigint& a, const Bigint& b);
63 // TODO(floitsch): what to do for divisions by zero. 68 // TODO(floitsch): what to do for divisions by zero.
64 static RawBigint* Divide(const Bigint& a, const Bigint& b); 69 static RawBigint* Divide(const Bigint& a, const Bigint& b);
65 static RawBigint* Modulo(const Bigint& a, const Bigint& b); 70 static RawBigint* Modulo(const Bigint& a, const Bigint& b);
66 static RawBigint* Remainder(const Bigint& a, const Bigint& b); 71 static RawBigint* Remainder(const Bigint& a, const Bigint& b);
67 72
(...skipping 23 matching lines...) Expand all
91 static RawSmi* BitOpWithSmi(Token::Kind kind, 96 static RawSmi* BitOpWithSmi(Token::Kind kind,
92 const Bigint& bigint, 97 const Bigint& bigint,
93 const Smi& smi); 98 const Smi& smi);
94 99
95 DISALLOW_IMPLICIT_CONSTRUCTORS(BigintOperations); 100 DISALLOW_IMPLICIT_CONSTRUCTORS(BigintOperations);
96 }; 101 };
97 102
98 } // namespace dart 103 } // namespace dart
99 104
100 #endif // VM_BIGINT_OPERATIONS_H_ 105 #endif // VM_BIGINT_OPERATIONS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/bigint_operations.cc » ('j') | runtime/vm/bigint_operations.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698