From 8e104627cbdfd22b4902dc45b3d352d324dae02d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 4 Jun 2023 19:04:52 +0800 Subject: [PATCH] ... --- src/expr.h | 2 ++ src/main.cpp | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/expr.h b/src/expr.h index c735186d..2cfc71f8 100644 --- a/src/expr.h +++ b/src/expr.h @@ -531,6 +531,7 @@ struct FStringExpr: Expr{ } void _load_simple_expr(CodeEmitContext* ctx, Str expr){ + // TODO: pre compile this into a function int dot = expr.index("."); if(dot < 0){ ctx->emit(OP_LOAD_NAME, StrName(expr.sv()).index, line); @@ -700,6 +701,7 @@ struct BinaryExpr: Expr{ case TK("!="): ctx->emit(OP_COMPARE_NE, BC_NOARG, line); break; case TK(">"): ctx->emit(OP_COMPARE_GT, BC_NOARG, line); break; case TK(">="): ctx->emit(OP_COMPARE_GE, BC_NOARG, line); break; + case TK("in"): ctx->emit(OP_CONTAINS_OP, 0, line); break; case TK("not in"): ctx->emit(OP_CONTAINS_OP, 1, line); break; case TK("is"): ctx->emit(OP_IS_OP, 0, line); break; diff --git a/src/main.cpp b/src/main.cpp index 21e40c49..c18f546e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,11 +8,8 @@ int main(int argc, char** argv){ pkpy::VM* vm = pkpy_new_vm(); vm->bind_builtin_func<0>("input", [](pkpy::VM* vm, pkpy::ArgsView args){ - // TODO: we do not use pkpy::getline() here. It doesn't accept unicode characters. - // pkpy::getline() has bugs for PIPE input - static std::string buffer; - std::cin >> buffer; - return VAR(buffer); + // pkpy::getline() has bugs for PIPE input on Windows + return VAR(pkpy::getline()); }); if(argc == 1){ pkpy::REPL* repl = pkpy_new_repl(vm);