floats are working now too, the whole thing seems to be pretty solid.

This commit is contained in:
David Halter
2012-04-07 02:15:36 +02:00
parent af786b9924
commit 95835250d7
4 changed files with 16 additions and 11 deletions

View File

@@ -72,16 +72,18 @@ class Execution(Exec):
if get_returns: if get_returns:
ret = scope.returns ret = scope.returns
for s in ret: for s in ret:
for stmt in follow_statement(s): #for stmt in follow_statement(s):
stmts += remove_executions(stmt) # stmts += remove_executions(stmt)
stmts += follow_statement(s)
else: else:
stmts.append(scope) stmts.append(scope)
return stmts return stmts
# check cache # check cache
try: try:
debug.dbg('hit function cache', self.base) ex = Execution.cache[self.base]
return Execution.cache[self.base] debug.dbg('hit function cache', self.base, ex)
return ex
except KeyError: except KeyError:
# cache is not only here as a cache, but also to prevent an # cache is not only here as a cache, but also to prevent an
# endless recursion. # endless recursion.
@@ -206,14 +208,16 @@ def follow_call(scope, call):
path = call.generate_call_list() path = call.generate_call_list()
current = next(path) current = next(path)
print 'call', scope, call, current
if isinstance(current, parsing.Array): if isinstance(current, parsing.Array):
result = [current] result = [current]
else: else:
# TODO add better care for int/unicode, now str/float are just used # TODO add better care for int/unicode, now str/float are just used
# instead # instead
if current.type == parsing.Call.STRING: not_name_part = not isinstance(current, parsing.NamePart)
if not_name_part and current.type == parsing.Call.STRING:
scopes = get_scopes_for_name(builtin.Builtin.scope, 'str') scopes = get_scopes_for_name(builtin.Builtin.scope, 'str')
elif current.type == parsing.Call.NUMBER: elif not_name_part and current.type == parsing.Call.NUMBER:
scopes = get_scopes_for_name(builtin.Builtin.scope, 'float') scopes = get_scopes_for_name(builtin.Builtin.scope, 'float')
else: else:
scopes = get_scopes_for_name(scope, current, search_global=True) scopes = get_scopes_for_name(scope, current, search_global=True)

View File

@@ -82,9 +82,10 @@ class FileWithCursor(modules.File):
break break
elif tok in close_brackets: elif tok in close_brackets:
level += 1 level += 1
elif token_type in [tokenize.NAME, tokenize.STRING, elif token_type in [tokenize.NAME, tokenize.STRING]:
tokenize.NUMBER]:
force_point = True force_point = True
elif token_type == tokenize.NUMBER:
pass
else: else:
#print 'break', token_type, tok #print 'break', token_type, tok
break break

View File

@@ -608,7 +608,7 @@ class Statement(Simple):
"behaviour. Please submit a bug" % level) "behaviour. Please submit a bug" % level)
self.assignment_calls = top self.assignment_calls = top
print 'top', top.values print 'top', top.values, top.values[0][0].name, repr(top.values[0][0].name)
return top return top

View File

@@ -133,7 +133,7 @@ class c1():
import os as c4 #from parsing import Scope as c4 import os as c4 #from parsing import Scope as c4
c5 = c4 c5 = c4
c5 = 1 c5 = 1
return c5+1+'asdf' return c5+'asdf'
(c1().c2.\ (c1().c2.\
@@ -147,4 +147,4 @@ b= asdf2
#import parsing as test #import parsing as test
c = b().c3() c = b().c3()
"1.0".join() 1.0.fromhex()