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

Side by Side Diff: frog/gen.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 | « no previous file | frog/member.dart » ('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 /** 5 /**
6 * Top level generator object for writing code and keeping track of 6 * Top level generator object for writing code and keeping track of
7 * dependencies. 7 * dependencies.
8 * 8 *
9 * Should have two compilation models, but only one implemented so far. 9 * Should have two compilation models, but only one implemented so far.
10 * 10 *
(...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 // Call the constructor on the type we want to construct. 2338 // Call the constructor on the type we want to construct.
2339 // NOTE: this is important for correct type checking of factories. 2339 // NOTE: this is important for correct type checking of factories.
2340 // If the user calls "new Interface()" we want the result type to be the 2340 // If the user calls "new Interface()" we want the result type to be the
2341 // interface, not the class. 2341 // interface, not the class.
2342 var target = new Value.type(type, typeRef.span); 2342 var target = new Value.type(type, typeRef.span);
2343 return m.invoke(this, node, target, _makeArgs(node.arguments)); 2343 return m.invoke(this, node, target, _makeArgs(node.arguments));
2344 } 2344 }
2345 2345
2346 visitListExpression(ListExpression node) { 2346 visitListExpression(ListExpression node) {
2347 var argValues = []; 2347 var argValues = [];
2348 //var listType = node.isConst ? world.immutableListType : world.listType;
2349 var listType = world.listType; 2348 var listType = world.listType;
2350 var type = world.varType; 2349 var type = world.varType;
2351 if (node.itemType != null) { 2350 if (node.itemType != null) {
2352 type = method.resolveType(node.itemType, true); 2351 type = method.resolveType(node.itemType, true);
2353 if (node.isConst && (type is ParameterType || type.hasTypeParams)) { 2352 if (node.isConst && (type is ParameterType || type.hasTypeParams)) {
2354 world.error('type parameter cannot be used in const list literals'); 2353 world.error('type parameter cannot be used in const list literals');
2355 } 2354 }
2356 listType = listType.getOrMakeConcreteType([type]); 2355 listType = listType.getOrMakeConcreteType([type]);
2357 } 2356 }
2358 for (var item in node.values) { 2357 for (var item in node.values) {
(...skipping 12 matching lines...) Expand all
2371 } 2370 }
2372 2371
2373 2372
2374 visitMapExpression(MapExpression node) { 2373 visitMapExpression(MapExpression node) {
2375 // Special case the empty non-const map. 2374 // Special case the empty non-const map.
2376 if (node.items.length == 0 && !node.isConst) { 2375 if (node.items.length == 0 && !node.isConst) {
2377 return world.mapType.getConstructor('').invoke(this, node, 2376 return world.mapType.getConstructor('').invoke(this, node,
2378 new Value.type(world.mapType, node.span), Arguments.EMPTY); 2377 new Value.type(world.mapType, node.span), Arguments.EMPTY);
2379 } 2378 }
2380 2379
2381 var values = new List<Value>(); 2380 var values = <Value>[];
2382 var valueType = world.varType, keyType = world.stringType; 2381 var valueType = world.varType, keyType = world.stringType;
2383 var mapType = world.mapType; // TODO(jimhug): immutable type? 2382 var mapType = world.mapType; // TODO(jimhug): immutable type?
2384 if (node.valueType !== null) { 2383 if (node.valueType !== null) {
2385 if (node.keyType !== null) { 2384 if (node.keyType !== null) {
2386 keyType = method.resolveType(node.keyType, true); 2385 keyType = method.resolveType(node.keyType, true);
2387 // TODO(jimhug): Would be nice to allow arbitrary keys here (this is 2386 // TODO(jimhug): Would be nice to allow arbitrary keys here (this is
2388 // currently not allowed by the spec). 2387 // currently not allowed by the spec).
2389 if (!keyType.isString) { 2388 if (!keyType.isString) {
2390 world.error('the key type of a map literal must be "String"', 2389 world.error('the key type of a map literal must be "String"',
2391 keyType.span); 2390 keyType.span);
2392 } 2391 }
2393 if (node.isConst && (keyType is ParameterType || keyType.hasTypeParams)) { 2392 if (node.isConst &&
2393 (keyType is ParameterType || keyType.hasTypeParams)) {
2394 world.error('type parameter cannot be used in const map literals'); 2394 world.error('type parameter cannot be used in const map literals');
2395 } 2395 }
2396 } 2396 }
2397 2397
2398 valueType = method.resolveType(node.valueType, true); 2398 valueType = method.resolveType(node.valueType, true);
2399 if (node.isConst && (valueType is ParameterType || valueType.hasTypeParams )) { 2399 if (node.isConst &&
2400 (valueType is ParameterType || valueType.hasTypeParams)) {
2400 world.error('type parameter cannot be used in const map literals'); 2401 world.error('type parameter cannot be used in const map literals');
2401 } 2402 }
2402 2403
2403 mapType = mapType.getOrMakeConcreteType([keyType, valueType]); 2404 mapType = mapType.getOrMakeConcreteType([keyType, valueType]);
2404 } 2405 }
2405 2406
2406 for (int i = 0; i < node.items.length; i += 2) { 2407 for (int i = 0; i < node.items.length; i += 2) {
2407 var key = visitTypedValue(node.items[i], keyType); 2408 var key = visitTypedValue(node.items[i], keyType);
2408 if (node.isConst && !key.isConst) { 2409 if (node.isConst && !key.isConst) {
2409 world.error('const map can only contain const keys', key.span); 2410 world.error('const map can only contain const keys', key.span);
2410 } 2411 }
2411 values.add(key); 2412 values.add(key);
2412 2413
2413 var value = visitTypedValue(node.items[i+1], valueType); 2414 var value = visitTypedValue(node.items[i + 1], valueType);
2414 if (node.isConst && !value.isConst) { 2415 if (node.isConst && !value.isConst) {
2415 world.error('const map can only contain const values', value.span); 2416 world.error('const map can only contain const values', value.span);
2416 } 2417 }
2417 values.add(value); 2418 values.add(value);
2418 } 2419 }
2419 2420
2420 var ret = new MapValue(values, node.isConst, mapType, node.span); 2421 var ret = new MapValue(values, node.isConst, mapType, node.span);
2421 if (ret.isConst) return ret.getGlobalValue(); 2422 if (ret.isConst) return ret.getGlobalValue();
2422 return ret; 2423 return ret;
2423 } 2424 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); 2627 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false));
2627 } 2628 }
2628 for (int i = bareCount; i < length; i++) { 2629 for (int i = bareCount; i < length; i++) {
2629 var name = getName(i); 2630 var name = getName(i);
2630 if (name == null) name = '\$$i'; 2631 if (name == null) name = '\$$i';
2631 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); 2632 result.add(new Value(world.varType, name, null, /*needsTemp:*/false));
2632 } 2633 }
2633 return new Arguments(nodes, result); 2634 return new Arguments(nodes, result);
2634 } 2635 }
2635 } 2636 }
OLDNEW
« no previous file with comments | « no previous file | frog/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698