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

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
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/integers_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,32 @@
}
+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);
+ }
+ String& temp = String::Handle();
+ temp = String::Concat(String::Handle(Symbols::New("-")), *int_string);
+ return Integer::New(temp);
+ }
+
+ 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) {
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/integers_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698