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

Unified Diff: sdk/lib/html/scripts/htmldartgenerator.py

Issue 11688005: Start unification of overload dispatcher generation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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: sdk/lib/html/scripts/htmldartgenerator.py
diff --git a/sdk/lib/html/scripts/htmldartgenerator.py b/sdk/lib/html/scripts/htmldartgenerator.py
index ff4eb7210c6a95aa13a19284f81b2e532b592e4d..6e96c09e33391469476a888f67193b743d2932e4 100644
--- a/sdk/lib/html/scripts/htmldartgenerator.py
+++ b/sdk/lib/html/scripts/htmldartgenerator.py
@@ -182,6 +182,26 @@ class HtmlDartGenerator(object):
else:
self.EmitOperation(info, method_name)
+ def _OverloadChecks(self,
+ operation,
+ parameter_names,
+ argument_count,
+ can_omit_type_check=lambda type, pos: False):
+ checks = []
+ for i in range(0, argument_count):
+ argument = operation.arguments[i]
+ parameter_name = parameter_names[i]
+ test_type = self._DartType(argument.type.id)
+ if test_type in ['dynamic', 'Object']:
+ checks.append('?%s' % parameter_name)
+ elif not can_omit_type_check(test_type, i):
+ checks.append('(%s is %s || %s == null)' % (
+ parameter_name, test_type, parameter_name))
+ # There can be multiple presence checks. We need them all since a later
+ # optional argument could have been passed by name, leaving 'holes'.
+ checks.extend(['!?%s' % name for name in parameter_names[argument_count:]])
+ return checks
+
def AdditionalImplementedInterfaces(self):
# TODO: Include all implemented interfaces, including other Lists.
implements = []

Powered by Google App Engine
This is Rietveld 408576698