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

Unified Diff: frog/member.dart

Issue 9121025: cleanup to Value - fix for StringEscapesTest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/library.dart ('k') | frog/minfrog » ('j') | frog/parser.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/member.dart
diff --git a/frog/member.dart b/frog/member.dart
index 7d6f255c4466180fbd970dc1706b06745ef7eb0c..83db4b9a5e8d2394621e77b2bc265eed01bdb38f 100644
--- a/frog/member.dart
+++ b/frog/member.dart
@@ -28,7 +28,9 @@ class Parameter {
// To match VM, detect cases where value was not actually specified in
// code and don't signal errors.
// TODO(jimhug): Clean up after issue #352 is resolved.
- if (!hasDefaultValue) return;
+ if (definition.value.span.start == definition.span.start) {
Jennifer Messerly 2012/01/09 20:16:26 I think I originally suggested the property to mak
jimhug 2012/01/09 21:19:05 I believe that Bob is going to undo this change, s
+ return;
+ }
if (method.name == ':call') {
// TODO(jimhug): Need simpler way to detect "true" function types vs.
@@ -70,13 +72,6 @@ class Parameter {
}
bool get isOptional() => definition != null && definition.value != null;
-
- /**
- * Gets whether this named parameter has an explicit default value or relies
- * on the implicit `null`.
- */
- bool get hasDefaultValue() => definition.value is! NullExpression ||
- (definition.value.span.start != definition.span.start);
}
@@ -1259,11 +1254,11 @@ class MethodMember extends Member {
node.span);
} else if (name == ':add') {
if (allConst) {
- final value = _normConcat(target, args.values[0]);
- return new EvaluatedValue(world.stringType, value, value, node.span);
+ final value = target.dynamic.actualValue +
+ args.values[0].dynamic.actualValue;
+ return Value.fromString(value, node.span);
}
- // Ensure we generate toString on the right side
return new Value(declaringType, '${target.code} + ${argsCode[0]}',
node.span);
}
@@ -1326,38 +1321,6 @@ class MethodMember extends Member {
node.span);
}
- /**
- * Return the string concatenation of two values, which is normalized to use
- * double-quotes if any of the input strings used double-quotes.
- */
- String _normConcat(Value a, Value b) {
Jennifer Messerly 2012/01/09 20:16:26 yay
- assert(b.type.isString);
- var val0 = a.dynamic.actualValue;
- var quote0 = val0[0];
- val0 = val0.substring(1, val0.length - 1);
- var val1 = b.dynamic.actualValue;
- var quote1 = null;
- if (b.type.isString) {
- quote1 = val1[0];
- val1 = val1.substring(1, val1.length - 1);
- }
- var value;
- if (quote0 == quote1 || quote1 == null) {
- // If both strings use the same quote, then keep using it.
- value = '$quote0${val0}${val1}$quote0';
- } else if (quote0 == '"') {
- // If they are different, escape the single-quote to be double-quote
- // the choice of single vs double is arbitrary, but choosing one
- // ensures that we only do this escaping once on a string portion.
- assert(quote1 == "'");
- value = '$quote0${val0}${toDoubleQuote(val1)}$quote0';
- } else {
- assert(quote1 == '"');
- value = '$quote1${toDoubleQuote(val0)}${val1}$quote1';
- }
- return value;
- }
-
resolve() {
// TODO(jimhug): cut-and-paste-and-edit from Field.resolve
isStatic = declaringType.isTop;
« no previous file with comments | « frog/library.dart ('k') | frog/minfrog » ('j') | frog/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698