Skip to content

Commit

Permalink
[BUG #5706] adapted basecall optimizer to new ast
Browse files Browse the repository at this point in the history
  • Loading branch information
thron7 committed Feb 28, 2012
1 parent 95b7280 commit 928c6b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tool/pylib/ecmascript/transform/optimizer/basecalloptimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def patch(node):
classDefNodes = list(treeutil.findQxDefineR(node))

for classDefNode in classDefNodes:
patchCount += optimize(classDefNode, classDefNodes,)
patchCount += optimize(classDefNode, classDefNodes)

return patchCount

Expand All @@ -56,7 +56,7 @@ def optimize(classDefine, classDefNodes):
if not "extend" in classMap:
return 0

if classMap["extend"].type == "variable":
if classMap["extend"].isVar():
superClass = treeutil.assembleVariable(classMap["extend"])[0]
else:
return 0 # interfaces can have a list-valued "extend", but we currently don't optimize those
Expand Down Expand Up @@ -91,7 +91,7 @@ def optimizeConstruct(node, superClass, methodName, classDefNodes):
if node in classDefNodes:
return 0

elif node.type == "variable" and node.hasParentContext("call/operand"):
elif node.isVar() and node.hasParentContext("call/operand"):

varName, complete = treeutil.assembleVariable(node)
if not (complete and varName == "this.base"):
Expand All @@ -100,7 +100,7 @@ def optimizeConstruct(node, superClass, methodName, classDefNodes):
call = node.parent.parent

try:
firstArgName = treeutil.selectNode(call, "params/1/identifier/@name")
firstArgName = treeutil.selectNode(call, "params/1/@value")
except tree.NodeAccessException:
return 0

Expand All @@ -114,7 +114,7 @@ def optimizeConstruct(node, superClass, methodName, classDefNodes):
else:
newCall = treeutil.compileString("%s.prototype.%s.call()" % (superClass, methodName))
newCall.replaceChild(newCall.getChild("params"), call.getChild("params")) # replace with old arglist
treeutil.selectNode(newCall, "params/1/identifier").set("name", "this") # arguments -> this
treeutil.selectNode(newCall, "params/1").set("value", "this") # arguments -> this
call.parent.replaceChild(call, newCall)
patchCount += 1

Expand Down Expand Up @@ -142,6 +142,6 @@ def optimizeConstruct(node, superClass, methodName, classDefNodes):
node = treeutil.compileString(cls)
patch(node)

print node.toJavascript()
print node.toJS()


0 comments on commit 928c6b9

Please sign in to comment.