diff --git a/src/codeobject.h b/src/codeobject.h index 1123bfca..55df6123 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -65,8 +65,6 @@ struct CodeObject { NameDictInt labels; std::vector func_decls; - void optimize(VM* vm); - void _gc_mark() const { for(PyObject* v : consts) OBJ_MARK(v); for(auto& decl: func_decls) decl->_gc_mark(); diff --git a/src/common.h b/src/common.h index 2e75afec..898a4b6d 100644 --- a/src/common.h +++ b/src/common.h @@ -161,7 +161,4 @@ inline PyObject* const PY_BEGIN_CALL = (PyObject*)0b010011; inline PyObject* const PY_OP_CALL = (PyObject*)0b100011; inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011; -struct Expr; -typedef std::unique_ptr Expr_; - } // namespace pkpy \ No newline at end of file diff --git a/src/compiler.h b/src/compiler.h index 02b69f4a..5a2c77ad 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -67,7 +67,7 @@ class Compiler { // however, this is buggy...since there may be a jump to the end (out of bound) even if the last opcode is a return ctx()->emit(OP_LOAD_NONE, BC_NOARG, BC_KEEPLINE); ctx()->emit(OP_RETURN_VALUE, BC_NOARG, BC_KEEPLINE); - ctx()->co->optimize(vm); + // ctx()->co->optimize(vm); if(ctx()->co->varnames.size() > PK_MAX_CO_VARNAMES){ SyntaxError("maximum number of local variables exceeded"); } diff --git a/src/expr.h b/src/expr.h index 3a3e31f7..1a249b9d 100644 --- a/src/expr.h +++ b/src/expr.h @@ -6,11 +6,12 @@ #include "error.h" #include "ceval.h" #include "str.h" -#include namespace pkpy{ struct CodeEmitContext; +struct Expr; +typedef std::unique_ptr Expr_; struct Expr{ int line = 0; diff --git a/src/linalg.h b/src/linalg.h index a2fe1b3c..5161a9b1 100644 --- a/src/linalg.h +++ b/src/linalg.h @@ -204,14 +204,6 @@ struct Mat3x3{ } /*************** affine transformations ***************/ - static Mat3x3 rotate(float radian){ - float cr = cosf(radian); - float sr = sinf(radian); - return Mat3x3(cr, -sr, 0.0f, - sr, cr, 0.0f, - 0.0f, 0.0f, 1.0f); - } - static Mat3x3 trs(Vec2 t, float radian, Vec2 s){ float cr = cosf(radian); float sr = sinf(radian); @@ -350,7 +342,12 @@ struct PyVec2: Vec2 { vm->bind_method<1>(type, "rotate", [](VM* vm, ArgsView args){ Vec2 self = _CAST(PyVec2&, args[0]); float radian = vm->num_to_float(args[1]); - self = Mat3x3::rotate(radian).transform_vector(self); + float cr = cosf(radian); + float sr = sinf(radian); + Mat3x3 rotate(cr, -sr, 0.0f, + sr, cr, 0.0f, + 0.0f, 0.0f, 1.0f); + self = rotate.transform_vector(self); return VAR(self); }); diff --git a/src/vm.h b/src/vm.h index e48d71d8..374ec315 100644 --- a/src/vm.h +++ b/src/vm.h @@ -591,7 +591,7 @@ public: inline PyObject* NativeFunc::operator()(VM* vm, ArgsView args) const{ int args_size = args.size() - (int)method; // remove self - if(argc != -1 && args_size != argc) { + if(args_size != argc && argc != -1) { vm->TypeError(fmt("expected ", argc, " arguments, but got ", args_size)); } #if DEBUG_EXTRA_CHECK @@ -600,12 +600,6 @@ inline PyObject* NativeFunc::operator()(VM* vm, ArgsView args) const{ return f(vm, args); } -inline void CodeObject::optimize(VM* vm){ - // uint32_t base_n = (uint32_t)(names.size() / kLocalsLoadFactor + 0.5); - // perfect_locals_capacity = std::max(find_next_capacity(base_n), NameDict::__Capacity); - // perfect_hash_seed = find_perfect_hash_seed(perfect_locals_capacity, names); -} - DEF_NATIVE_2(Str, tp_str) DEF_NATIVE_2(List, tp_list) DEF_NATIVE_2(Tuple, tp_tuple)