Skip to content

Commit

Permalink
fix input_int not inject
Browse files Browse the repository at this point in the history
  • Loading branch information
jiamo committed Jun 18, 2022
1 parent 7fdaffc commit 1105b65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions compiler_dyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ def cast_insert_exp(self, e):
case FunRef(name, airth):
args_types = [AnyType() for i in range(airth)]
return Inject(e, FunctionType(args_types, AnyType()))
case Call(Name('input_int'), args):
return Inject(e, IntType())
case Call(x, args):
x = self.cast_insert_exp(x)
args = [self.cast_insert_exp(i) for i in args]
Expand Down Expand Up @@ -594,6 +596,11 @@ def cast_insert_stmt(self, stmt):
new_arg = self.cast_insert_exp(arg)
# new_arg = Project(new_arg, IntType())
return Expr(Call(Name('print'), [new_arg]))
case Expr(Call(Name('input_int'), [])):
# Find bug need cast_insert_stmt for all
# new_arg = self.cast_insert_exp(arg)
# new_arg = Project(new_arg, IntType())
return stmt
case Expr(value):
expr = self.cast_insert_exp(value)
return Expr(expr)
Expand Down
4 changes: 2 additions & 2 deletions compiler_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ def reveal_functions_exp(self, exp, func_map):

def reveal_functions_stmt(self, stmt, func_map):
match stmt:
case Expr(Call(Name('input'), [])):
case Expr(Call(Name('input_int'), [])):
# new_arg = self.reveal_functions_exp(arg, func_map)
# breakpoint()
return Expr(Call(Name('input'), [])) # may be build in function
return Expr(Call(Name('input_int'), [])) # may be build in function
case Expr(Call(Name('print'), [arg])):
new_arg = self.reveal_functions_exp(arg, func_map)
return Expr(Call(Name('print'), [new_arg]))
Expand Down
2 changes: 1 addition & 1 deletion run-tests-lambda.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import compiler
# import compiler
import compiler_lambda
import interp_Pvar
import interp_Lvar
Expand Down

0 comments on commit 1105b65

Please sign in to comment.