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

Side by Side Diff: lib/integers.cc

Issue 9481019: Changes to get rid of dependency on openssl in the dart VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 10 months 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
OLDNEW
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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 switch (kind) { 98 switch (kind) {
99 case Token::kBIT_AND: 99 case Token::kBIT_AND:
100 return Integer::New(a & b); 100 return Integer::New(a & b);
101 case Token::kBIT_OR: 101 case Token::kBIT_OR:
102 return Integer::New(a | b); 102 return Integer::New(a | b);
103 case Token::kBIT_XOR: 103 case Token::kBIT_XOR:
104 return Integer::New(a ^ b); 104 return Integer::New(a ^ b);
105 default: 105 default:
106 UNIMPLEMENTED(); 106 UNIMPLEMENTED();
107 } 107 }
108 } else if (op1_int.IsSmi()) {
109 return IntegerBitOperation(kind, op2_int, op1_int);
110 } else if (op2_int.IsSmi()) {
111 Bigint& op1 = Bigint::Handle(AsBigint(op1_int));
112 Smi& op2 = Smi::Handle();
113 op2 ^= op2_int.raw();
114 switch (kind) {
115 case Token::kBIT_AND:
116 return BigintOperations::BitAndWithSmi(op1, op2);
117 case Token::kBIT_OR:
118 return BigintOperations::BitOrWithSmi(op1, op2);
119 case Token::kBIT_XOR:
120 return BigintOperations::BitXorWithSmi(op1, op2);
121 default:
122 UNIMPLEMENTED();
123 }
124 } else { 108 } else {
125 Bigint& op1 = Bigint::Handle(AsBigint(op1_int)); 109 Bigint& op1 = Bigint::Handle(AsBigint(op1_int));
126 Bigint& op2 = Bigint::Handle(AsBigint(op2_int)); 110 Bigint& op2 = Bigint::Handle(AsBigint(op2_int));
127 switch (kind) { 111 switch (kind) {
128 case Token::kBIT_AND: 112 case Token::kBIT_AND:
129 return BigintOperations::BitAnd(op1, op2); 113 return BigintOperations::BitAnd(op1, op2);
130 case Token::kBIT_OR: 114 case Token::kBIT_OR:
131 return BigintOperations::BitOr(op1, op2); 115 return BigintOperations::BitOr(op1, op2);
132 case Token::kBIT_XOR: 116 case Token::kBIT_XOR:
133 return BigintOperations::BitXor(op1, op2); 117 return BigintOperations::BitXor(op1, op2);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 562
579 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { 563 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) {
580 const Bigint& value = Bigint::CheckedHandle(arguments->At(0)); 564 const Bigint& value = Bigint::CheckedHandle(arguments->At(0));
581 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); 565 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value));
582 ASSERT(CheckInteger(value)); 566 ASSERT(CheckInteger(value));
583 ASSERT(CheckInteger(result)); 567 ASSERT(CheckInteger(result));
584 arguments->SetReturn(Integer::Handle(AsInteger(result))); 568 arguments->SetReturn(Integer::Handle(AsInteger(result)));
585 } 569 }
586 570
587 } // namespace dart 571 } // namespace dart
OLDNEW
« no previous file with comments | « bin/bin.gypi ('k') | vm/bigint_operations.h » ('j') | vm/bigint_operations.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698