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

Side by Side Diff: runtime/lib/math.cc

Issue 9264051: Fix for bug 1229: Unary operator plus is not allowed ... except for literals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | runtime/vm/parser.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 #include <ctype.h> // isspace. 5 #include <ctype.h> // isspace.
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bool* is_positive, 82 bool* is_positive,
83 String** value) { 83 String** value) {
84 if ((tokens.length() == 2) && 84 if ((tokens.length() == 2) &&
85 (tokens[0].kind == literal_kind) && 85 (tokens[0].kind == literal_kind) &&
86 (tokens[1].kind == Token::kEOS)) { 86 (tokens[1].kind == Token::kEOS)) {
87 *is_positive = true; 87 *is_positive = true;
88 *value = tokens[0].literal; 88 *value = tokens[0].literal;
89 return true; 89 return true;
90 } 90 }
91 if ((tokens.length() == 3) && 91 if ((tokens.length() == 3) &&
92 ((tokens[0].kind == Token::kADD) || (tokens[0].kind == Token::kSUB)) && 92 ((tokens[0].kind == Token::kTIGHTADD) ||
93 (tokens[0].kind == Token::kSUB)) &&
93 (tokens[1].kind == literal_kind) && 94 (tokens[1].kind == literal_kind) &&
94 (tokens[2].kind == Token::kEOS)) { 95 (tokens[2].kind == Token::kEOS)) {
95 // Check there is no space between "+/-" and number. 96 // Check there is no space between "+/-" and number.
96 if ((tokens[0].offset + 1) != tokens[1].offset) { 97 if ((tokens[0].offset + 1) != tokens[1].offset) {
97 return false; 98 return false;
98 } 99 }
99 *is_positive = tokens[0].kind == Token::kADD; 100 *is_positive = tokens[0].kind == Token::kTIGHTADD;
100 *value = tokens[1].literal; 101 *value = tokens[1].literal;
101 return true; 102 return true;
102 } 103 }
103 return false; 104 return false;
104 } 105 }
105 106
106 107
107 DEFINE_NATIVE_ENTRY(MathNatives_parseInt, 1) { 108 DEFINE_NATIVE_ENTRY(MathNatives_parseInt, 1) {
108 GET_NATIVE_ARGUMENT(String, value, arguments->At(0)); 109 GET_NATIVE_ARGUMENT(String, value, arguments->At(0));
109 Scanner scanner(value, String::Handle()); 110 Scanner scanner(value, String::Handle());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return; 174 return;
174 } 175 }
175 } 176 }
176 177
177 GrowableArray<const Object*> args; 178 GrowableArray<const Object*> args;
178 args.Add(&value); 179 args.Add(&value);
179 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); 180 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args);
180 } 181 }
181 182
182 } // namespace dart 183 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/ast.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698