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

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

Issue 9689045: Library privacy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/ssa/nodes.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 String generate(WorkItem work, HGraph graph) { 9 String generate(WorkItem work, HGraph graph) {
10 return measure(() { 10 return measure(() {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 HGraph currentGraph; 101 HGraph currentGraph;
102 HBasicBlock currentBlock; 102 HBasicBlock currentBlock;
103 103
104 // Records a block-information that is being handled specially. 104 // Records a block-information that is being handled specially.
105 // Used to break bad recursion. 105 // Used to break bad recursion.
106 HLabeledBlockInformation currentBlockInformation; 106 HLabeledBlockInformation currentBlockInformation;
107 // The subgraph is used to delimit traversal for some constructions, e.g., 107 // The subgraph is used to delimit traversal for some constructions, e.g.,
108 // if branches. 108 // if branches.
109 SubGraph subGraph; 109 SubGraph subGraph;
110 110
111 LibraryElement get currentLibrary() => work.element.getLibrary();
112
111 SsaCodeGenerator(this.compiler, 113 SsaCodeGenerator(this.compiler,
112 this.work, 114 this.work,
113 this.buffer, 115 this.buffer,
114 this.parameters, 116 this.parameters,
115 this.parameterNames) 117 this.parameterNames)
116 : names = new Map<int, String>(), 118 : names = new Map<int, String>(),
117 prefixes = new Map<String, int>() { 119 prefixes = new Map<String, int>() {
118 for (final name in parameterNames.getValues()) { 120 for (final name in parameterNames.getValues()) {
119 prefixes[name] = 0; 121 prefixes[name] = 0;
120 } 122 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 530 }
529 } 531 }
530 532
531 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { 533 visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
532 beginExpression(JSPrecedence.CALL_PRECEDENCE); 534 beginExpression(JSPrecedence.CALL_PRECEDENCE);
533 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 535 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
534 buffer.add('.'); 536 buffer.add('.');
535 // Avoid adding the generative constructor name to the list of 537 // Avoid adding the generative constructor name to the list of
536 // seen selectors. 538 // seen selectors.
537 if (node.inputs[0] is HForeignNew) { 539 if (node.inputs[0] is HForeignNew) {
540 HForeignNew foreignNew = node.inputs[0];
538 // Remove 'this' from the number of arguments. 541 // Remove 'this' from the number of arguments.
539 int argumentCount = node.inputs.length - 1; 542 int argumentCount = node.inputs.length - 1;
540 buffer.add(compiler.namer.instanceMethodName(node.name, argumentCount)); 543
544 // TODO(ahe): The constructor name was statically resolved in
545 // SsaBuilder.buildFactory. Is there a cleaner way to do this?
546 node.name.printOn(buffer);
541 visitArguments(node.inputs); 547 visitArguments(node.inputs);
542 } else { 548 } else {
543 buffer.add(compiler.namer.instanceMethodInvocationName( 549 buffer.add(compiler.namer.instanceMethodInvocationName(
544 node.name, node.selector)); 550 currentLibrary, node.name, node.selector));
545 visitArguments(node.inputs); 551 visitArguments(node.inputs);
546 compiler.registerDynamicInvocation(node.name, node.selector); 552 compiler.registerDynamicInvocation(node.name, node.selector);
547 } 553 }
548 endExpression(JSPrecedence.CALL_PRECEDENCE); 554 endExpression(JSPrecedence.CALL_PRECEDENCE);
549 } 555 }
550 556
551 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { 557 visitInvokeDynamicSetter(HInvokeDynamicSetter node) {
552 beginExpression(JSPrecedence.CALL_PRECEDENCE); 558 beginExpression(JSPrecedence.CALL_PRECEDENCE);
553 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 559 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
554 buffer.add('.'); 560 buffer.add('.');
555 buffer.add(compiler.namer.setterName(node.name)); 561 buffer.add(compiler.namer.setterName(currentLibrary, node.name));
556 visitArguments(node.inputs); 562 visitArguments(node.inputs);
557 compiler.registerDynamicSetter(node.name); 563 compiler.registerDynamicSetter(node.name);
558 endExpression(JSPrecedence.CALL_PRECEDENCE); 564 endExpression(JSPrecedence.CALL_PRECEDENCE);
559 } 565 }
560 566
561 visitInvokeDynamicGetter(HInvokeDynamicGetter node) { 567 visitInvokeDynamicGetter(HInvokeDynamicGetter node) {
562 beginExpression(JSPrecedence.CALL_PRECEDENCE); 568 beginExpression(JSPrecedence.CALL_PRECEDENCE);
563 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 569 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
564 buffer.add('.'); 570 buffer.add('.');
565 buffer.add(compiler.namer.getterName(node.name)); 571 buffer.add(compiler.namer.getterName(currentLibrary, node.name));
566 visitArguments(node.inputs); 572 visitArguments(node.inputs);
567 compiler.registerDynamicGetter(node.name); 573 compiler.registerDynamicGetter(node.name);
568 endExpression(JSPrecedence.CALL_PRECEDENCE); 574 endExpression(JSPrecedence.CALL_PRECEDENCE);
569 } 575 }
570 576
571 visitInvokeClosure(HInvokeClosure node) { 577 visitInvokeClosure(HInvokeClosure node) {
572 beginExpression(JSPrecedence.CALL_PRECEDENCE); 578 beginExpression(JSPrecedence.CALL_PRECEDENCE);
573 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 579 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
574 buffer.add('.'); 580 buffer.add('.');
575 buffer.add(compiler.namer.closureInvocationName(node.selector)); 581 buffer.add(compiler.namer.closureInvocationName(node.selector));
(...skipping 12 matching lines...) Expand all
588 } 594 }
589 595
590 visitInvokeSuper(HInvokeSuper node) { 596 visitInvokeSuper(HInvokeSuper node) {
591 beginExpression(JSPrecedence.CALL_PRECEDENCE); 597 beginExpression(JSPrecedence.CALL_PRECEDENCE);
592 Element superMethod = node.element; 598 Element superMethod = node.element;
593 Element superClass = superMethod.enclosingElement; 599 Element superClass = superMethod.enclosingElement;
594 // Remove the element and 'this'. 600 // Remove the element and 'this'.
595 int argumentCount = node.inputs.length - 2; 601 int argumentCount = node.inputs.length - 2;
596 String className = compiler.namer.isolatePropertyAccess(superClass); 602 String className = compiler.namer.isolatePropertyAccess(superClass);
597 String methodName = compiler.namer.instanceMethodName( 603 String methodName = compiler.namer.instanceMethodName(
598 superMethod.name, argumentCount); 604 currentLibrary, superMethod.name, argumentCount);
599 buffer.add('$className.prototype.$methodName.call'); 605 buffer.add('$className.prototype.$methodName.call');
600 visitArguments(node.inputs); 606 visitArguments(node.inputs);
601 endExpression(JSPrecedence.CALL_PRECEDENCE); 607 endExpression(JSPrecedence.CALL_PRECEDENCE);
602 compiler.registerStaticUse(superMethod); 608 compiler.registerStaticUse(superMethod);
603 } 609 }
604 610
605 visitFieldGet(HFieldGet node) { 611 visitFieldGet(HFieldGet node) {
606 String name = JsNames.getValid(node.element.name.slowToString()); 612 String name = JsNames.getValid(node.element.name.slowToString());
607 if (node.receiver !== null) { 613 if (node.receiver !== null) {
608 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 614 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 startBailoutSwitch(); 1440 startBailoutSwitch();
1435 } 1441 }
1436 } 1442 }
1437 1443
1438 void endElse(HIf node) { 1444 void endElse(HIf node) {
1439 if (node.elseBlock.hasBailouts()) { 1445 if (node.elseBlock.hasBailouts()) {
1440 endBailoutSwitch(); 1446 endBailoutSwitch();
1441 } 1447 }
1442 } 1448 }
1443 } 1449 }
OLDNEW
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698