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

Unified Diff: frog/parser.dart

Issue 8457007: Better runtime type checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleaner output 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 side-by-side diff with in-line comments
Download patch
Index: frog/parser.dart
diff --git a/frog/parser.dart b/frog/parser.dart
index e77e28aba75f3962f4d6b92e2f056ee786e428e1..dfe8f7aea87ef2f00f3ed0b1c9fe921ebcc6a58b 100644
--- a/frog/parser.dart
+++ b/frog/parser.dart
@@ -945,8 +945,12 @@ class Parser {
return new TypeReference(span, world.boolType);
}
- _numTypeRef(SourceSpan span) {
- return new TypeReference(span, world.numType);
+ _intTypeRef(SourceSpan span) {
Jennifer Messerly 2011/11/05 00:45:11 I started trying to make sense of ints vs doubles,
+ return new TypeReference(span, world.intType);
+ }
+
+ _doubleTypeRef(SourceSpan span) {
+ return new TypeReference(span, world.doubleType);
}
_stringTypeRef(SourceSpan span) {
@@ -1005,16 +1009,21 @@ class Parser {
return new LiteralExpression(false,_boolTypeRef(_makeSpan(start)),
'false', _makeSpan(start));
- case TokenKind.HEX_NUMBER:
+ case TokenKind.HEX_INTEGER:
var t = _next();
// Remove the 0x or 0X before parsing the hex number.
return new LiteralExpression(parseHex(t.text.substring(2)),
- _numTypeRef(_makeSpan(start)), t.text, _makeSpan(start));
+ _intTypeRef(_makeSpan(start)), t.text, _makeSpan(start));
+
+ case TokenKind.INTEGER:
+ var t = _next();
+ return new LiteralExpression(Math.parseInt(t.text),
+ _intTypeRef(_makeSpan(start)), t.text, _makeSpan(start));
- case TokenKind.NUMBER:
+ case TokenKind.DOUBLE:
var t = _next();
return new LiteralExpression(Math.parseDouble(t.text),
- _numTypeRef(_makeSpan(start)), t.text, _makeSpan(start));
+ _doubleTypeRef(_makeSpan(start)), t.text, _makeSpan(start));
case TokenKind.STRING:
return stringLiteralExpr();

Powered by Google App Engine
This is Rietveld 408576698