Permalink
Browse files
compiler2: Code style tweaks.
- Loading branch information...
Showing
with
18 additions
and
13 deletions.
-
+9
−4
opy/compiler2/pyassem.py
-
+7
−7
opy/compiler2/pycodegen.py
-
+2
−2
opy/compiler2/symbols.py
|
|
@@ -264,17 +264,22 @@ def find_next(): |
|
|
return order
|
|
|
|
|
|
|
|
|
gBlockCounter = 0
|
|
|
|
|
|
|
|
|
class Block(object):
|
|
|
_count = 0
|
|
|
|
|
|
def __init__(self, label=''):
|
|
|
self.label = label
|
|
|
|
|
|
global gBlockCounter
|
|
|
self.bid = gBlockCounter
|
|
|
gBlockCounter += 1
|
|
|
|
|
|
self.insts = []
|
|
|
self.outEdges = set()
|
|
|
self.label = label
|
|
|
self.bid = Block._count
|
|
|
self.next = []
|
|
|
self.prev = []
|
|
|
Block._count += 1
|
|
|
|
|
|
# BUG FIX: This is needed for deterministic order in sets (and dicts?).
|
|
|
# See OrderBlocks() below. remaining is set() of blocks. If we rely on
|
|
|
|
|
|
@@ -28,7 +28,7 @@ |
|
|
|
|
|
|
|
|
# TODO: Move this mutable global somewhere.
|
|
|
gLambdaCount = 0
|
|
|
gLambdaCounter = 0
|
|
|
|
|
|
|
|
|
PY27_MAGIC = b'\x03\xf3\r\n' # removed host dep imp.get_magic()
|
|
|
@@ -346,9 +346,9 @@ def visitFunction(self, node): |
|
|
self.storeName(node.name)
|
|
|
|
|
|
def visitLambda(self, node):
|
|
|
global gLambdaCount
|
|
|
obj_name = "<lambda.%d>" % gLambdaCount
|
|
|
gLambdaCount += 1
|
|
|
global gLambdaCounter
|
|
|
obj_name = "<lambda.%d>" % gLambdaCounter
|
|
|
gLambdaCounter += 1
|
|
|
|
|
|
_CheckNoTupleArgs(node)
|
|
|
graph = pyassem.PyFlowGraph(obj_name, node.filename, optimized=1)
|
|
|
@@ -661,9 +661,9 @@ def _makeClosure(self, gen, args): |
|
|
def visitGenExpr(self, node):
|
|
|
isLambda = 1 # TODO: Shouldn't be a lambda? Note Finish().
|
|
|
if isLambda:
|
|
|
global gLambdaCount
|
|
|
obj_name = "<lambda.%d>" % gLambdaCount
|
|
|
gLambdaCount += 1
|
|
|
global gLambdaCounter
|
|
|
obj_name = "<lambda.%d>" % gLambdaCounter
|
|
|
gLambdaCounter += 1
|
|
|
else:
|
|
|
# TODO: enable this. This is more like CPython. Note that I worked
|
|
|
# worked around a bug in byterun due to NOT having this.
|
|
|
|
|
|
@@ -394,12 +394,12 @@ def visitAugAssign(self, node, scope): |
|
|
|
|
|
# prune if statements if tests are false
|
|
|
|
|
|
_const_types = types.StringType, types.IntType, types.FloatType
|
|
|
_CONST_TYPES = (types.StringType, types.IntType, types.FloatType)
|
|
|
|
|
|
def visitIf(self, node, scope):
|
|
|
for test, body in node.tests:
|
|
|
if isinstance(test, ast.Const):
|
|
|
if type(test.value) in self._const_types:
|
|
|
if isinstance(test.value, self._CONST_TYPES):
|
|
|
if not test.value:
|
|
|
continue
|
|
|
self.visit(test, scope)
|
|
|
|
0 comments on commit
cb13573