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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 968843003: Implement type argument access and reification of runtime types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 visitExpression(node.left), 321 visitExpression(node.left),
322 visitExpression(node.right)); 322 visitExpression(node.right));
323 } 323 }
324 324
325 @override 325 @override
326 js.Expression visitNot(tree_ir.Not node) { 326 js.Expression visitNot(tree_ir.Not node) {
327 return new js.Prefix("!", visitExpression(node.operand)); 327 return new js.Prefix("!", visitExpression(node.operand));
328 } 328 }
329 329
330 @override 330 @override
331 js.Expression visitReifyTypeVar(tree_ir.ReifyTypeVar node) {
332 return giveup(node);
333 // TODO: implement visitReifyTypeVar
334 }
335
336 @override
337 js.Expression visitThis(tree_ir.This node) { 331 js.Expression visitThis(tree_ir.This node) {
338 return new js.This(); 332 return new js.This();
339 } 333 }
340 334
341 @override 335 @override
342 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { 336 js.Expression visitTypeOperator(tree_ir.TypeOperator node) {
343 return giveup(node); 337 return giveup(node);
344 // TODO: implement visitTypeOperator 338 // TODO: implement visitTypeOperator
345 } 339 }
346 340
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 void visitSetField(tree_ir.SetField node) { 497 void visitSetField(tree_ir.SetField node) {
504 js.PropertyAccess field = 498 js.PropertyAccess field =
505 new js.PropertyAccess.field( 499 new js.PropertyAccess.field(
506 visitExpression(node.object), 500 visitExpression(node.object),
507 glue.instanceFieldPropertyName(node.field)); 501 glue.instanceFieldPropertyName(node.field));
508 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); 502 js.Assignment asn = new js.Assignment(field, visitExpression(node.value));
509 accumulator.add(new js.ExpressionStatement(asn)); 503 accumulator.add(new js.ExpressionStatement(asn));
510 visitStatement(node.next); 504 visitStatement(node.next);
511 } 505 }
512 506
507 js.Expression buildStaticHelperInvocation(FunctionElement helper,
508 List<js.Expression> arguments) {
509 registry.registerStaticUse(helper);
510 return buildStaticInvoke(new Selector.fromElement(helper), helper,
511 arguments);
512 }
513
514 @override
515 js.Expression visitReifyRuntimeType(tree_ir.ReifyRuntimeType node) {
516 FunctionElement createType = glue.getCreateRuntimeType();
517 FunctionElement typeToString = glue.getRuntimeTypeToString();
518 return buildStaticHelperInvocation(createType,
519 [buildStaticHelperInvocation(typeToString,
520 [visitExpression(node.value)])]);
521 }
522
523 @override
524 js.Expression visitReadTypeVariable(tree_ir.ReadTypeVariable node) {
525 if (node.context != node.variable.element.enclosingClass) {
526 giveup(node, 'substitution not implemented');
asgerf 2015/03/02 13:52:36 I am confused. This should never happen because th
karlklose 2015/03/05 09:54:58 Acknowledged.
527 }
528 js.Expression index = js.number(glue.getTypeVariableIndex(node.variable));
529 if (glue.needsSubstitutionForTypeVariableAccess(node.context)) {
530 js.Expression substitution = glue.getSubstitutionName(node.context);
531 return buildStaticHelperInvocation(
532 glue.getTypeArgumentWithSubstitution(),
533 [visitExpression(node.target), substitution, index]);
534 } else {
535 return buildStaticHelperInvocation(
536 glue.getTypeArgumentByIndex(),
537 [visitExpression(node.target), index]);
538 }
539 }
540
541
513 // Dart-specific IR nodes 542 // Dart-specific IR nodes
514 543
515 @override 544 @override
545 visitReifyTypeVar(tree_ir.ReifyTypeVar node) {
546 return errorUnsupportedNode(node);
547 }
548
549 @override
516 visitFunctionExpression(tree_ir.FunctionExpression node) { 550 visitFunctionExpression(tree_ir.FunctionExpression node) {
517 return errorUnsupportedNode(node); 551 return errorUnsupportedNode(node);
518 } 552 }
519 553
520 @override 554 @override
521 visitFunctionDeclaration(tree_ir.FunctionDeclaration node) { 555 visitFunctionDeclaration(tree_ir.FunctionDeclaration node) {
522 return errorUnsupportedNode(node); 556 return errorUnsupportedNode(node);
523 } 557 }
524 558
525 @override 559 @override
526 visitFieldInitializer(tree_ir.FieldInitializer node) { 560 visitFieldInitializer(tree_ir.FieldInitializer node) {
527 return errorUnsupportedNode(node); 561 return errorUnsupportedNode(node);
528 } 562 }
529 563
530 @override 564 @override
531 visitSuperInitializer(tree_ir.SuperInitializer node) { 565 visitSuperInitializer(tree_ir.SuperInitializer node) {
532 return errorUnsupportedNode(node); 566 return errorUnsupportedNode(node);
533 } 567 }
534 568
535 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { 569 errorUnsupportedNode(tree_ir.DartSpecificNode node) {
536 throw "Unsupported node in JS backend: $node"; 570 throw "Unsupported node in JS backend: $node";
537 } 571 }
538 } 572 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698