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

Unified Diff: lib/dom/scripts/systemhtml.py

Issue 10869029: Remove trivially redundant tests from dispatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | lib/html/dart2js/html_dart2js.dart » ('j') | lib/html/dart2js/html_dart2js.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemhtml.py
diff --git a/lib/dom/scripts/systemhtml.py b/lib/dom/scripts/systemhtml.py
index 19a121aef2162f6cc471f2469092e4dee9533b67..c75cc6258ca6d62721512976e7c5dd5e35ec97ce 100644
--- a/lib/dom/scripts/systemhtml.py
+++ b/lib/dom/scripts/systemhtml.py
@@ -1070,15 +1070,16 @@ class HtmlDart2JSClassGenerator(Dart2JSInterfaceGenerator):
HTML_NAME=html_name,
PARAMS=info.ParametersImplementationDeclaration(InputType, '_default'))
- argument_names = [param_info.name for param_info in info.param_infos]
- argument_types = [InputType(param_info.dart_type)
- for param_info in info.param_infos]
+ parameter_names = [param_info.name for param_info in info.param_infos]
+ parameter_types = [InputType(param_info.dart_type)
+ for param_info in info.param_infos]
operations = info.operations
method_version = [0]
temp_version = [0]
def GenerateCall(operation, argument_count, checks):
+ checks = filter(lambda e: e != 'true', checks)
if checks:
(stmts_emitter, call_emitter) = body.Emit(
' if ($CHECKS) {\n$!STMTS$!CALL }\n',
@@ -1103,12 +1104,12 @@ class HtmlDart2JSClassGenerator(Dart2JSInterfaceGenerator):
TYPE=TypeOrVar(temp_type),
NAME=temp_name,
CONVERT=conversion.function_name,
- ARG=argument_names[position])
+ ARG=parameter_names[position])
arguments.append(temp_name)
param_type = temp_type
verified_type = temp_type # verified by assignment in checked mode.
else:
- arguments.append(argument_names[position])
+ arguments.append(parameter_names[position])
param_type = self._NarrowInputType(DartType(arg.type.id))
# Verified by argument checking on entry to the dispatcher.
verified_type = InputType(info.param_infos[position].dart_type)
@@ -1144,16 +1145,21 @@ class HtmlDart2JSClassGenerator(Dart2JSInterfaceGenerator):
NATIVE=info.declared_name)
def GenerateChecksAndCall(operation, argument_count):
- checks = ['_default == %s' % name for name in argument_names]
+ checks = ['_default == %s' % name for name in parameter_names]
for i in range(0, argument_count):
argument = operation.arguments[i]
- argument_name = argument_names[i]
+ parameter_name = parameter_names[i]
test_type = self._DartType(argument.type.id)
if test_type in ['Dynamic', 'Object']:
- checks[i] = '_default != %s' % argument_name
+ checks[i] = '_default != %s' % parameter_name
+ elif test_type == parameter_types[i]:
+ checks[i] = 'true'
else:
checks[i] = '(%s is %s || %s == null)' % (
- argument_name, self._DartType(argument.type.id), argument_name)
+ parameter_name, test_type, parameter_name)
+ # Only need first _default check since we don't have any other default
+ # values in the dispatch method's signature.
+ checks = checks[:argument_count + 1]
GenerateCall(operation, argument_count, checks)
# TODO: Optimize the dispatch to avoid repeated checks.
@@ -1169,7 +1175,7 @@ class HtmlDart2JSClassGenerator(Dart2JSInterfaceGenerator):
argument_count = len(operation.arguments)
for position, argument in list(enumerate(operation.arguments))[::-1]:
if self._IsOptional(operation, argument):
- check = '_default != %s' % argument_names[position]
+ check = '_default != %s' % parameter_names[position]
GenerateCall(operation, position + 1, [check])
argument_count = position
GenerateCall(operation, argument_count, [])
« no previous file with comments | « no previous file | lib/html/dart2js/html_dart2js.dart » ('j') | lib/html/dart2js/html_dart2js.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698