diff --git a/compiler_dyn.py b/compiler_dyn.py index 9d7d3e8..beb4b48 100644 --- a/compiler_dyn.py +++ b/compiler_dyn.py @@ -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] @@ -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) diff --git a/compiler_lambda.py b/compiler_lambda.py index 59f8947..c95b0a2 100644 --- a/compiler_lambda.py +++ b/compiler_lambda.py @@ -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])) diff --git a/run-tests-lambda.py b/run-tests-lambda.py index a2e7d7a..d402554 100644 --- a/run-tests-lambda.py +++ b/run-tests-lambda.py @@ -1,6 +1,6 @@ import os import sys -import compiler +# import compiler import compiler_lambda import interp_Pvar import interp_Lvar