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

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: Unbreak long line. 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 visitExpression(node.left), 324 visitExpression(node.left),
325 visitExpression(node.right)); 325 visitExpression(node.right));
326 } 326 }
327 327
328 @override 328 @override
329 js.Expression visitNot(tree_ir.Not node) { 329 js.Expression visitNot(tree_ir.Not node) {
330 return new js.Prefix("!", visitExpression(node.operand)); 330 return new js.Prefix("!", visitExpression(node.operand));
331 } 331 }
332 332
333 @override 333 @override
334 js.Expression visitReifyTypeVar(tree_ir.ReifyTypeVar node) {
335 return giveup(node);
336 // TODO: implement visitReifyTypeVar
337 }
338
339 @override
340 js.Expression visitThis(tree_ir.This node) { 334 js.Expression visitThis(tree_ir.This node) {
341 return new js.This(); 335 return new js.This();
342 } 336 }
343 337
344 @override 338 @override
345 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { 339 js.Expression visitTypeOperator(tree_ir.TypeOperator node) {
346 return giveup(node); 340 return giveup(node);
347 // TODO: implement visitTypeOperator 341 // TODO: implement visitTypeOperator
348 } 342 }
349 343
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 void visitSetField(tree_ir.SetField node) { 504 void visitSetField(tree_ir.SetField node) {
511 js.PropertyAccess field = 505 js.PropertyAccess field =
512 new js.PropertyAccess.field( 506 new js.PropertyAccess.field(
513 visitExpression(node.object), 507 visitExpression(node.object),
514 glue.instanceFieldPropertyName(node.field)); 508 glue.instanceFieldPropertyName(node.field));
515 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); 509 js.Assignment asn = new js.Assignment(field, visitExpression(node.value));
516 accumulator.add(new js.ExpressionStatement(asn)); 510 accumulator.add(new js.ExpressionStatement(asn));
517 visitStatement(node.next); 511 visitStatement(node.next);
518 } 512 }
519 513
514 js.Expression buildStaticHelperInvocation(FunctionElement helper,
515 List<js.Expression> arguments) {
516 registry.registerStaticUse(helper);
517 return buildStaticInvoke(new Selector.fromElement(helper), helper,
518 arguments);
519 }
520
521 @override
522 js.Expression visitReifyRuntimeType(tree_ir.ReifyRuntimeType node) {
523 FunctionElement createType = glue.getCreateRuntimeType();
524 FunctionElement typeToString = glue.getRuntimeTypeToString();
525 return buildStaticHelperInvocation(createType,
526 [buildStaticHelperInvocation(typeToString,
527 [visitExpression(node.value)])]);
528 }
529
530 @override
531 js.Expression visitReadTypeVariable(tree_ir.ReadTypeVariable node) {
532 ClassElement context = node.variable.element.enclosingClass;
533 js.Expression index = js.number(glue.getTypeVariableIndex(node.variable));
534 if (glue.needsSubstitutionForTypeVariableAccess(context)) {
535 js.Expression substitution = glue.getSubstitutionName(context);
536 return buildStaticHelperInvocation(
537 glue.getTypeArgumentWithSubstitution(),
538 [visitExpression(node.target), substitution, index]);
539 } else {
540 return buildStaticHelperInvocation(
541 glue.getTypeArgumentByIndex(),
542 [visitExpression(node.target), index]);
543 }
544 }
545
546
520 // Dart-specific IR nodes 547 // Dart-specific IR nodes
521 548
522 @override 549 @override
550 visitReifyTypeVar(tree_ir.ReifyTypeVar node) {
551 return errorUnsupportedNode(node);
552 }
553
554 @override
523 visitFunctionExpression(tree_ir.FunctionExpression node) { 555 visitFunctionExpression(tree_ir.FunctionExpression node) {
524 return errorUnsupportedNode(node); 556 return errorUnsupportedNode(node);
525 } 557 }
526 558
527 @override 559 @override
528 visitFunctionDeclaration(tree_ir.FunctionDeclaration node) { 560 visitFunctionDeclaration(tree_ir.FunctionDeclaration node) {
529 return errorUnsupportedNode(node); 561 return errorUnsupportedNode(node);
530 } 562 }
531 563
532 @override 564 @override
533 visitFieldInitializer(tree_ir.FieldInitializer node) { 565 visitFieldInitializer(tree_ir.FieldInitializer node) {
534 return errorUnsupportedNode(node); 566 return errorUnsupportedNode(node);
535 } 567 }
536 568
537 @override 569 @override
538 visitSuperInitializer(tree_ir.SuperInitializer node) { 570 visitSuperInitializer(tree_ir.SuperInitializer node) {
539 return errorUnsupportedNode(node); 571 return errorUnsupportedNode(node);
540 } 572 }
541 573
542 dynamic errorUnsupportedNode(tree_ir.DartSpecificNode node) { 574 errorUnsupportedNode(tree_ir.DartSpecificNode node) {
543 throw "Unsupported node in JS backend: $node"; 575 throw "Unsupported node in JS backend: $node";
544 } 576 }
545 } 577 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698