Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
bannsec committed Mar 31, 2016
1 parent a238737 commit dd87ad9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions pyState/ListComp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

logger = logging.getLogger("pyState:ListComp")

#import astunparse
import astunparse

def _findAllInputVariables(haystack):
"""
Find all input variables (ast.Name objects). Return as a list
"""
ret = []
print("type",type(haystack))

if type(haystack) is ast.ListComp:
for generator in haystack.generators:
Expand All @@ -35,8 +36,16 @@ def _findAllInputVariables(haystack):
if haystack.kwargs is not None:
for arg in haystack.kwargs:
ret += _findAllInputVariables(arg)
if type(haystack.func) is not ast.Name:
ret += _findAllInputVariables(haystack.func)
return ret

if type(haystack) is ast.Attribute:
return [] + _findAllInputVariables(haystack.value)

if type(haystack) is ast.Subscript:
return [] + _findAllInputVariables(haystack.value)

return []


Expand Down Expand Up @@ -105,7 +114,7 @@ def handle(state,element,ctx=None):
for inputVar in allInputVars:
fun.args.args.append(ast.arg(inputVar.id,0))

#print(astunparse.unparse(fun))
print(astunparse.unparse(fun))

# Call our new function.
state.Call(ast.parse("blergy({0})".format(','.join([x.id for x in allInputVars]))).body[0].value,func=fun,retObj=retObj)
Expand Down
3 changes: 2 additions & 1 deletion pyState/functions/int.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pyObjectManager.Real import Real
from pyObjectManager.BitVec import BitVec
from pyObjectManager.String import String
from pyObjectManager.Char import Char
import logging

logger = logging.getLogger("pyState:functions:int")
Expand All @@ -14,7 +15,7 @@ def handle(state,call,obj,base=10):
# Resolve the object
obj = state.resolveObject(obj)

if type(obj) not in [Int, Real, BitVec, String]:
if type(obj) not in [Int, Real, BitVec, String, Char]:
err = "handle: Don't know how to handle type {0}".format(type(obj))
logger.error(err)
raise Exception(err)
Expand Down

0 comments on commit dd87ad9

Please sign in to comment.