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

Side by Side Diff: frog/leg/ssa/builder.dart

Issue 9283014: Implement field parameter for generative constructors. (Closed) Base URL: http://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 unified diff | Download patch | Annotate | Revision Log
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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 HForeignNew newObject = new HForeignNew(classElement, fieldValues); 235 HForeignNew newObject = new HForeignNew(classElement, fieldValues);
236 add(newObject); 236 add(newObject);
237 237
238 // Call the method body. 238 // Call the method body.
239 SourceString methodName = compiler.namer.getConstructorName(bodyElement); 239 SourceString methodName = compiler.namer.getConstructorName(bodyElement);
240 240
241 List bodyCallInputs = <HInstruction>[]; 241 List bodyCallInputs = <HInstruction>[];
242 bodyCallInputs.add(newObject); 242 bodyCallInputs.add(newObject);
243 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) { 243 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) {
244 Link<Node> identifierLink = link.head.definitions.nodes; 244 Link<Node> nodeLink = link.head.definitions.nodes;
245 // We expect exactly one identifier. 245 // We expect exactly one identifier.
246 assert(!identifierLink.isEmpty() && identifierLink.tail.isEmpty()); 246 assert(!nodeLink.isEmpty() && nodeLink.tail.isEmpty());
247 if (identifierLink.head is !Identifier) { 247 Node current = nodeLink.head;
248 compiler.unimplemented("SsaBuilder.buildFactory non-identifier"); 248 Element parameterElement = elements[current];
249 }
250 Identifier name = identifierLink.head;
251 Element parameterElement = elements[name];
252 HInstruction currentValue = definitions[parameterElement]; 249 HInstruction currentValue = definitions[parameterElement];
253 bodyCallInputs.add(currentValue); 250 bodyCallInputs.add(currentValue);
254 } 251 }
255 add(new HInvokeDynamicMethod(methodName, bodyCallInputs)); 252 add(new HInvokeDynamicMethod(methodName, bodyCallInputs));
256 close(new HReturn(newObject)).addSuccessor(graph.exit); 253 close(new HReturn(newObject)).addSuccessor(graph.exit);
257 return closeFunction(); 254 return closeFunction();
258 } 255 }
259 256
260 void openFunction(FunctionElement functionElement) { 257 void openFunction(FunctionElement functionElement) {
261 stack = new List<HInstruction>(); 258 stack = new List<HInstruction>();
262 definitions = new Map<Element, HInstruction>(); 259 definitions = new Map<Element, HInstruction>();
263 260
264 graph = new HGraph(); 261 graph = new HGraph();
265 HBasicBlock block = graph.addNewBlock(); 262 HBasicBlock block = graph.addNewBlock();
266 263
267 open(graph.entry); 264 open(graph.entry);
268 if (functionElement.isInstanceMember()) { 265 if (functionElement.isInstanceMember()) {
269 thisDefinition = new HThis(); 266 thisDefinition = new HThis();
270 add(thisDefinition); 267 add(thisDefinition);
271 } 268 }
272 FunctionExpression function = functionElement.parseNode(compiler, compiler); 269 FunctionExpression function = functionElement.parseNode(compiler, compiler);
273 visitParameterValues(function.parameters); 270 handleParameterValues(function.parameters);
274 close(new HGoto()).addSuccessor(block); 271 close(new HGoto()).addSuccessor(block);
275 272
276 open(block); 273 open(block);
277 } 274 }
278 275
279 HGraph closeFunction() { 276 HGraph closeFunction() {
280 // TODO(kasperl): Make this goto an implicit return. 277 // TODO(kasperl): Make this goto an implicit return.
281 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); 278 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit);
282 graph.finalize(); 279 graph.finalize();
283 return graph; 280 return graph;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 HBoolify popBoolified() { 324 HBoolify popBoolified() {
328 HBoolify boolified = new HBoolify(pop()); 325 HBoolify boolified = new HBoolify(pop());
329 add(boolified); 326 add(boolified);
330 return boolified; 327 return boolified;
331 } 328 }
332 329
333 void visit(Node node) { 330 void visit(Node node) {
334 if (node !== null) node.accept(this); 331 if (node !== null) node.accept(this);
335 } 332 }
336 333
337 visitParameterValues(NodeList parameters) { 334 handleParameterValues(NodeList parameters) {
338 int parameterIndex = 0; 335 int parameterIndex = 0;
339 for (Link<Node> link = parameters.nodes; 336 for (Link<Node> link = parameters.nodes;
340 !link.isEmpty(); 337 !link.isEmpty();
341 link = link.tail) { 338 link = link.tail) {
342 VariableDefinitions container = link.head; 339 VariableDefinitions container = link.head;
343 Link<Node> identifierLink = container.definitions.nodes; 340 Link<Node> nodeLink = container.definitions.nodes;
344 // The identifier link must contain exactly one argument. 341 // The identifier link must contain exactly one argument.
345 assert(!identifierLink.isEmpty() && identifierLink.tail.isEmpty()); 342 assert(!nodeLink.isEmpty() && nodeLink.tail.isEmpty());
346 if (identifierLink.head is !Identifier) { 343 Node current = nodeLink.head;
347 compiler.unimplemented( 344 VariableElement element = elements[current];
348 "SsaBuilder.visitParameterValues non-identifier", node: parameters);
349 }
350 Identifier parameterId = identifierLink.head;
351 VariableElement element = elements[parameterId];
352 HParameterValue parameter = new HParameterValue(element); 345 HParameterValue parameter = new HParameterValue(element);
353 add(parameter); 346 add(parameter);
354 definitions[element] = parameter; 347 definitions[element] = parameter;
355 } 348 }
356 } 349 }
357 350
358 visitBlock(Block node) { 351 visitBlock(Block node) {
359 for (Link<Node> link = node.statements.nodes; 352 for (Link<Node> link = node.statements.nodes;
360 !link.isEmpty(); 353 !link.isEmpty();
361 link = link.tail) { 354 link = link.tail) {
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 } 1404 }
1412 1405
1413 visitCatchBlock(CatchBlock node) { 1406 visitCatchBlock(CatchBlock node) {
1414 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); 1407 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node);
1415 } 1408 }
1416 1409
1417 visitTypedef(Typedef node) { 1410 visitTypedef(Typedef node) {
1418 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); 1411 compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
1419 } 1412 }
1420 } 1413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698