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

Unified Diff: runtime/lib/integers.cc

Issue 11316031: - Move MathNatives from dart:core to dart:math. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/integers.cc
===================================================================
--- runtime/lib/integers.cc (revision 14972)
+++ runtime/lib/integers.cc (working copy)
@@ -9,6 +9,7 @@
#include "vm/exceptions.h"
#include "vm/native_entry.h"
#include "vm/object.h"
+#include "vm/symbols.h"
namespace dart {
@@ -172,6 +173,34 @@
}
+DEFINE_NATIVE_ENTRY(Integer_parse, 1) {
+ GET_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0));
+ const String& dummy_key = String::Handle(Symbols::Empty());
+ Scanner scanner(value, dummy_key);
+ const Scanner::GrowableTokenStream& tokens = scanner.GetStream();
+ String* int_string;
+ bool is_positive;
+ if (Scanner::IsValidLiteral(tokens,
+ Token::kINTEGER,
+ &is_positive,
+ &int_string)) {
+ if (is_positive) {
+ return Integer::New(*int_string);
+ } else {
+ String& temp = String::Handle();
+ temp = String::Concat(String::Handle(Symbols::New("-")),
+ *int_string);
+ return Integer::New(temp);
+ }
+ } else {
siva 2012/11/16 01:34:26 Is the else needed here? It could be similar to th
Ivan Posva 2012/11/16 19:26:43 Done here and in similar places such as line 189 a
+ GrowableArray<const Object*> args;
+ args.Add(&value);
+ Exceptions::ThrowByType(Exceptions::kFormat, args);
+ return Object::null();
+ }
+}
+
+
static RawInteger* ShiftOperationHelper(Token::Kind kind,
const Integer& value,
const Smi& amount) {

Powered by Google App Engine
This is Rietveld 408576698