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

Side by Side Diff: frog/member.dart

Issue 9151015: addressing 3 previous review comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/gen.dart ('k') | frog/minfrog » ('j') | no next file with comments »
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 /** A formal parameter to a [Method]. */ 5 /** A formal parameter to a [Method]. */
6 class Parameter { 6 class Parameter {
7 FormalNode definition; 7 FormalNode definition;
8 Member method; 8 Member method;
9 9
10 String name; 10 String name;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // TODO: Could warn at parse time. 420 // TODO: Could warn at parse time.
421 world.error('static field of hidden native type is inaccessible', 421 world.error('static field of hidden native type is inaccessible',
422 node.span); 422 node.span);
423 } 423 }
424 return new Value(type, '${declaringType.jsname}.$jsname', node.span); 424 return new Value(type, '${declaringType.jsname}.$jsname', node.span);
425 } else { 425 } else {
426 return new Value(type, 426 return new Value(type,
427 '\$globals.${declaringType.jsname}_$jsname', node.span); 427 '\$globals.${declaringType.jsname}_$jsname', node.span);
428 } 428 }
429 } 429 }
430 /*else if (target.isConst && isFinal) {
431 // take advantage of consts and retrieve the value directly if possible
432 var constTarget = target is GlobalValue ? target.dynamic.exp : target;
433 if (constTarget is ConstObjectValue) {
434 return constTarget.fields[name];
435 } else if (constTarget.type == world.stringType && name == 'length') {
436 return new Value(type, '${constTarget.actualValue.length}', node.span);
437 }
438 }*/
439 return new Value(type, '${target.code}.$jsname', node.span); 430 return new Value(type, '${target.code}.$jsname', node.span);
440 } 431 }
441 432
442 Value _set(MethodGenerator context, Node node, Value target, Value value, 433 Value _set(MethodGenerator context, Node node, Value target, Value value,
443 [bool isDynamic=false]) { 434 [bool isDynamic=false]) {
444 var lhs = _get(context, node, target, isDynamic); 435 var lhs = _get(context, node, target, isDynamic);
445 value = value.convertTo(context, type, isDynamic); 436 value = value.convertTo(context, type, isDynamic);
446 return new Value(type, '${lhs.code} = ${value.code}', node.span); 437 return new Value(type, '${lhs.code} = ${value.code}', node.span);
447 } 438 }
448 } 439 }
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 1041
1051 final span = node != null ? node.span : target.span; 1042 final span = node != null ? node.span : target.span;
1052 if (!target.isType) { 1043 if (!target.isType) {
1053 // initializer call to another constructor 1044 // initializer call to another constructor
1054 var code = '${declaringType.nativeName}${ctor}.call($argsString)'; 1045 var code = '${declaringType.nativeName}${ctor}.call($argsString)';
1055 return new Value(target.type, code, span); 1046 return new Value(target.type, code, span);
1056 } else { 1047 } else {
1057 // Start of abstract interpretation to replace const hacks goes here 1048 // Start of abstract interpretation to replace const hacks goes here
1058 // TODO(jmesserly): using the "node" here feels really hacky 1049 // TODO(jmesserly): using the "node" here feels really hacky
1059 if (isConst && node is NewExpression && node.dynamic.isConst) { 1050 if (isConst && node is NewExpression && node.dynamic.isConst) {
1060 // !!!!!! Egregious hack !!!!!!! 1051 // TODO(jimhug): Embedding JSSyntaxRegExp works around an annoying
1052 // issue with tracking native constructors for const objects.
1061 if (isNative || declaringType.name == 'JSSyntaxRegExp') { 1053 if (isNative || declaringType.name == 'JSSyntaxRegExp') {
1062 // check that all args are const? 1054 // check that all args are const?
1063 var code = 'new ${declaringType.nativeName}${ctor}($argsString)'; 1055 var code = 'new ${declaringType.nativeName}${ctor}($argsString)';
1064 return world.gen.globalForConst(new Value(target.type, code, span), 1056 return world.gen.globalForConst(new Value(target.type, code, span),
1065 [args.values]); 1057 [args.values]);
1066 } 1058 }
1067 var newType = declaringType; 1059 var newType = declaringType;
1068 var newObject = new ObjectValue(true, newType, span); 1060 var newObject = new ObjectValue(true, newType, span);
1069 newObject.initFields(); 1061 newObject.initFields();
1070 _evalConstConstructor(newObject, args); 1062 _evalConstConstructor(newObject, args);
1071 // ??? Does args.values include named args???
1072 return world.gen.globalForConst(newObject, [args.values]); 1063 return world.gen.globalForConst(newObject, [args.values]);
1073 } else { 1064 } else {
1074 var code = 'new ${declaringType.nativeName}${ctor}($argsString)'; 1065 var code = 'new ${declaringType.nativeName}${ctor}($argsString)';
1075 return new Value(target.type, code, span); 1066 return new Value(target.type, code, span);
1076 } 1067 }
1077 } 1068 }
1078 } 1069 }
1079 1070
1080 _evalConstConstructor(Value newObject, Arguments args) { 1071 _evalConstConstructor(Value newObject, Arguments args) {
1081 declaringType.markUsed(); 1072 declaringType.markUsed();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 } 1581 }
1591 1582
1592 void forEach(void f(Member member)) { 1583 void forEach(void f(Member member)) {
1593 factories.forEach((_, Map constructors) { 1584 factories.forEach((_, Map constructors) {
1594 constructors.forEach((_, Member member) { 1585 constructors.forEach((_, Member member) {
1595 f(member); 1586 f(member);
1596 }); 1587 });
1597 }); 1588 });
1598 } 1589 }
1599 } 1590 }
OLDNEW
« no previous file with comments | « frog/gen.dart ('k') | frog/minfrog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698