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

Unified Diff: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java

Issue 8566022: Function type checking (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup / refactor Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
diff --git a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
index b9971760c053b235d6fc61454a0f135618170fe6..ec910b05e277ee3c492f7049e78dc18ff136677d 100644
--- a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
+++ b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
@@ -278,7 +278,7 @@ public class GenerateJavascriptAST {
jsNewDeclarationsStack.push(new HashSet<JsName>());
currentHolder = unit.getLibrary().getElement();
rtt = new RuntimeTypeInjector(this, typeProvider, translationContext,
- context.getCompilerConfiguration().developerModeChecks());
+ context.getCompilerConfiguration().developerModeChecks(), mangler, unitLibrary);
}
/**
@@ -1113,6 +1113,9 @@ public class GenerateJavascriptAST {
globalBlock.getStatements().add(func.makeStmt());
globalBlock.getStatements().add(tramp.makeStmt());
+
+ // special case for top level methods
+ rtt.generateRuntimeTypeInfo(x);
}
return func;
@@ -1347,6 +1350,19 @@ public class GenerateJavascriptAST {
asg = assign(namedProp, tramp);
globalBlock.getStatements().add(asg.makeStmt());
+
+ // Generate a lookup method after finally writing function / named tramp
+ assert currentScopeInfo == null : "Nested methods should be impossible";
+ inFactoryOrStaticContext = element.getModifiers().isFactory()
+ || element.getModifiers().isStatic();
+ DartMethodDefinition x = (DartMethodDefinition) element.getNode();
+ currentScopeInfo = ScopeRootInfo.makeScopeInfo(x, !shouldGenerateDeveloperModeChecks());
+ rtt.generateRuntimeTypeInfo(x);
+
+ assert currentScopeInfo != null;
+ inFactoryOrStaticContext = false;
+ currentScopeInfo = null;
+
}
} else {
globalBlock.getStatements().add(func.makeStmt());
@@ -2971,6 +2987,10 @@ public class GenerateJavascriptAST {
hoistedName = globalScope.declareName(mangled);
tramp.setName(hoistedName);
globalBlock.getStatements().add(tramp.makeStmt());
+
+ if(x.getParent() != null && !(x.getParent() instanceof DartFunctionObjectInvocation)) {
+ rtt.generateRuntimeTypeInfo(x, hoistedName + ".");
+ }
}
// 5) Bind the necessary scope references and possibly "this".
@@ -3532,6 +3552,15 @@ public class GenerateJavascriptAST {
@Override
public JsNode visitFunctionTypeAlias(DartFunctionTypeAlias node) {
+ // TODO(codefu): Optimize away if we're never the rhs of a "is" check.
+ ClassElement classElement = node.getSymbol();
+ JsName classJsName = getJsName(classElement);
+ JsFunction jsClass = new JsFunction(globalScope, classJsName).setSourceRef(node);
+ jsClass.setIsConstructor(false);
+ jsClass.setBody(new JsBlock());
+ globalBlock.getStatements().add(jsClass.makeStmt());
+
+ rtt.generateRuntimeTypeInfo(node);
return null;
}
@@ -3629,7 +3658,6 @@ public class GenerateJavascriptAST {
assert (qualifier instanceof DartClass);
boundMethod = AstUtil.newNameRef(getJsName(qualifier.getSymbol()).makeRef(), mangledName);
} else {
- assert (qualifier instanceof DartIdentifier);
boundMethod = AstUtil.newNameRef((JsExpression) generate(qualifier), mangledName);
}
} else {

Powered by Google App Engine
This is Rietveld 408576698