mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
...
This commit is contained in:
parent
37c46fda68
commit
ef99bf9205
@ -925,8 +925,8 @@ __SUBSCR_END:
|
|||||||
StrName name = prev().str();
|
StrName name = prev().str();
|
||||||
|
|
||||||
// check duplicate argument name
|
// check duplicate argument name
|
||||||
for(int i: decl->args){
|
for(int j: decl->args){
|
||||||
if(decl->code->varnames[i] == name) {
|
if(decl->code->varnames[j] == name) {
|
||||||
SyntaxError("duplicate argument name");
|
SyntaxError("duplicate argument name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ struct Generator{
|
|||||||
if(ret == PY_OP_YIELD){
|
if(ret == PY_OP_YIELD){
|
||||||
// backup the context
|
// backup the context
|
||||||
frame = std::move(vm->callstack.top());
|
frame = std::move(vm->callstack.top());
|
||||||
PyObject* ret = frame._s->popx();
|
ret = frame._s->popx();
|
||||||
for(PyObject* obj: frame.stack_view()) s_backup.push_back(obj);
|
for(PyObject* obj: frame.stack_view()) s_backup.push_back(obj);
|
||||||
vm->_pop_frame();
|
vm->_pop_frame();
|
||||||
state = 1;
|
state = 1;
|
||||||
|
11
src/linalg.h
11
src/linalg.h
@ -260,12 +260,12 @@ struct Mat3x3{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 transform_point(Vec2 v) const {
|
Vec2 transform_point(Vec2 vec) const {
|
||||||
return Vec2(_11 * v.x + _12 * v.y + _13, _21 * v.x + _22 * v.y + _23);
|
return Vec2(_11 * vec.x + _12 * vec.y + _13, _21 * vec.x + _22 * vec.y + _23);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 transform_vector(Vec2 v) const {
|
Vec2 transform_vector(Vec2 vec) const {
|
||||||
return Vec2(_11 * v.x + _12 * v.y, _21 * v.x + _22 * v.y);
|
return Vec2(_11 * vec.x + _12 * vec.y, _21 * vec.x + _22 * vec.y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -617,14 +617,17 @@ struct PyMat3x3: Mat3x3{
|
|||||||
});
|
});
|
||||||
|
|
||||||
vm->bind_func<0>(type, "zeros", [](VM* vm, ArgsView args){
|
vm->bind_func<0>(type, "zeros", [](VM* vm, ArgsView args){
|
||||||
|
PK_UNUSED(args);
|
||||||
return VAR_T(PyMat3x3, Mat3x3::zeros());
|
return VAR_T(PyMat3x3, Mat3x3::zeros());
|
||||||
});
|
});
|
||||||
|
|
||||||
vm->bind_func<0>(type, "ones", [](VM* vm, ArgsView args){
|
vm->bind_func<0>(type, "ones", [](VM* vm, ArgsView args){
|
||||||
|
PK_UNUSED(args);
|
||||||
return VAR_T(PyMat3x3, Mat3x3::ones());
|
return VAR_T(PyMat3x3, Mat3x3::ones());
|
||||||
});
|
});
|
||||||
|
|
||||||
vm->bind_func<0>(type, "identity", [](VM* vm, ArgsView args){
|
vm->bind_func<0>(type, "identity", [](VM* vm, ArgsView args){
|
||||||
|
PK_UNUSED(args);
|
||||||
return VAR_T(PyMat3x3, Mat3x3::identity());
|
return VAR_T(PyMat3x3, Mat3x3::identity());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
4
src/vm.h
4
src/vm.h
@ -487,6 +487,7 @@ public:
|
|||||||
template<typename T, typename __T>
|
template<typename T, typename __T>
|
||||||
PyObject* bind_notimplemented_constructor(__T&& type) {
|
PyObject* bind_notimplemented_constructor(__T&& type) {
|
||||||
return bind_constructor<-1>(std::forward<__T>(type), [](VM* vm, ArgsView args){
|
return bind_constructor<-1>(std::forward<__T>(type), [](VM* vm, ArgsView args){
|
||||||
|
PK_UNUSED(args);
|
||||||
vm->NotImplementedError();
|
vm->NotImplementedError();
|
||||||
return vm->None;
|
return vm->None;
|
||||||
});
|
});
|
||||||
@ -739,6 +740,7 @@ template<> inline float py_cast<float>(VM* vm, PyObject* obj){
|
|||||||
return BitsCvt(bits)._float;
|
return BitsCvt(bits)._float;
|
||||||
}
|
}
|
||||||
template<> inline float _py_cast<float>(VM* vm, PyObject* obj){
|
template<> inline float _py_cast<float>(VM* vm, PyObject* obj){
|
||||||
|
PK_UNUSED(vm);
|
||||||
i64 bits = PK_BITS(obj) & Number::c1;
|
i64 bits = PK_BITS(obj) & Number::c1;
|
||||||
return BitsCvt(bits)._float;
|
return BitsCvt(bits)._float;
|
||||||
}
|
}
|
||||||
@ -748,6 +750,7 @@ template<> inline double py_cast<double>(VM* vm, PyObject* obj){
|
|||||||
return BitsCvt(bits)._float;
|
return BitsCvt(bits)._float;
|
||||||
}
|
}
|
||||||
template<> inline double _py_cast<double>(VM* vm, PyObject* obj){
|
template<> inline double _py_cast<double>(VM* vm, PyObject* obj){
|
||||||
|
PK_UNUSED(vm);
|
||||||
i64 bits = PK_BITS(obj) & Number::c1;
|
i64 bits = PK_BITS(obj) & Number::c1;
|
||||||
return BitsCvt(bits)._float;
|
return BitsCvt(bits)._float;
|
||||||
}
|
}
|
||||||
@ -777,6 +780,7 @@ PY_VAR_INT(unsigned long long)
|
|||||||
|
|
||||||
#define PY_VAR_FLOAT(T) \
|
#define PY_VAR_FLOAT(T) \
|
||||||
inline PyObject* py_var(VM* vm, T _val){ \
|
inline PyObject* py_var(VM* vm, T _val){ \
|
||||||
|
PK_UNUSED(vm); \
|
||||||
BitsCvt val(static_cast<f64>(_val)); \
|
BitsCvt val(static_cast<f64>(_val)); \
|
||||||
i64 bits = val._int & Number::c1; \
|
i64 bits = val._int & Number::c1; \
|
||||||
i64 tail = val._int & Number::c2; \
|
i64 tail = val._int & Number::c2; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user