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

Unified Diff: dart/lib/compiler/implementation/native_handler.dart

Issue 9958011: Building the Ssa graph has some sanity checks. (Closed) Base URL: http://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/native_handler.dart
===================================================================
--- dart/lib/compiler/implementation/native_handler.dart (revision 6027)
+++ dart/lib/compiler/implementation/native_handler.dart (working copy)
@@ -131,6 +131,8 @@
return token;
}
+RegExp nativeRedirectionRegExp = const RegExp(@'^[a-zA-Z][a-zA-Z_$0-9]*$');
+
Token handleNativeFunctionBody(ElementListener listener, Token token) {
checkAllowedLibrary(listener, token);
Token begin = token;
@@ -140,10 +142,17 @@
if (token.kind === STRING_TOKEN) {
listener.beginLiteralString(token);
listener.endLiteralString(0);
- listener.pushNode(new NodeList.singleton(listener.popNode()));
+ LiteralString str = listener.popNode();
+ listener.pushNode(new NodeList.singleton(str));
listener.endSend(token);
token = token.next;
- listener.endExpressionStatement(token);
+ // If this native method is just redirecting to another method,
+ // we add a return node to match the SSA builder expactations.
floitsch 2012/03/30 19:41:26 expectations
+ if (nativeRedirectionRegExp.hasMatch(str.dartString.slowToString())) {
+ listener.endReturnStatement(true, begin, token);
+ } else {
+ listener.endExpressionStatement(token);
+ }
} else {
listener.pushNode(new NodeList.empty());
listener.endSend(token);
@@ -223,7 +232,7 @@
}
LiteralString jsCode = node.arguments.head;
String str = jsCode.dartString.slowToString();
- if (const RegExp(@'^[a-zA-Z][a-zA-Z_$0-9]*$').hasMatch(str)) {
+ if (nativeRedirectionRegExp.hasMatch(str)) {
nativeMethodName = str;
isRedirecting = true;
} else {
@@ -332,13 +341,6 @@
builder.current.addPhi(phi);
builder.stack.add(phi);
}
- if (isRedirecting) {
- // The parser creates a return node if there is no string literal
- // after the native keyword. In case of a redirecting method, there
- // is a string literal, therefore we must emit a return instruction
- // in the builder.
- builder.push(new HReturn(builder.pop()));
- }
} else {
// This is JS code written in a Dart file with the construct
// native """ ... """;. It does not work well with mangling,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698