This commit is contained in:
blueloveTH 2023-06-04 19:04:52 +08:00
parent 9182ba5fc5
commit 8e104627cb
2 changed files with 4 additions and 5 deletions

View File

@ -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;

View File

@ -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);