Author: Stephan <[email protected]>
Branch:
Changeset: r65:4e960ef0e8c6
Date: 2011-05-18 11:13 +0200
http://bitbucket.org/pypy/lang-js/changeset/4e960ef0e8c6/
Log: express empty default block through EmptyExpression istead of None
diff --git a/js/astbuilder.py b/js/astbuilder.py
--- a/js/astbuilder.py
+++ b/js/astbuilder.py
@@ -394,7 +394,7 @@
if len(node.children) > 1:
defaultblock = self.dispatch(node.children[1])
else:
- defaultblock = None
+ defaultblock = operations.EmptyExpression(pos)
return operations.CaseBlock(pos, caseclauses, defaultblock)
def visit_caseclauses(self, node):
diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -384,10 +384,7 @@
clause.block.emit(bytecode)
bytecode.emit('JUMP', end_of_switch)
bytecode.emit('LABEL', next_clause)
- if self.default_clause is not None:
- self.default_clause.emit(bytecode)
- else:
- bytecode.unpop_or_undefined()
+ self.default_clause.emit(bytecode)
bytecode.emit('LABEL', end_of_switch)
bytecode.emit('POP')
@@ -788,6 +785,10 @@
bytecode.emit('POP')
bytecode.emit('LOAD_UNDEFINED')
+class EmptyExpression(Expression):
+ def emit(self, bytecode):
+ bytecode.unpop_or_undefined()
+
class With(Statement):
def __init__(self, pos, expr, body):
self.pos = pos
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit