mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
add emplace
This commit is contained in:
parent
9a085d1767
commit
3a475a78b3
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
run: |
|
||||
python amalgamate.py
|
||||
cd amalgamated
|
||||
cl.exe /std:c++17 /EHsc /utf-8 /O2 /I. /DPK_ENABLE_OS=1 main.cpp /link /out:pkpy.exe
|
||||
cl.exe /std:c++17 /EHsc /utf-8 /Ox /I. /DPK_ENABLE_OS=1 main.cpp /link /out:pkpy.exe
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: amalgamated/pkpy.exe
|
||||
|
@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /Ox /jumptablerdata /GS-")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -frtti -O2")
|
||||
|
||||
|
@ -59,6 +59,12 @@ struct ValueStack {
|
||||
void clear() { _sp = _begin; }
|
||||
bool is_overflow() const { return _sp >= _max_end; }
|
||||
|
||||
template<typename... Args>
|
||||
void emplace(Args&&... args){
|
||||
new(_sp) PyVar(std::forward<Args>(args)...);
|
||||
++_sp;
|
||||
}
|
||||
|
||||
PyVar operator[](int i) const { return _begin[i]; }
|
||||
PyVar& operator[](int i) { return _begin[i]; }
|
||||
|
||||
|
@ -157,7 +157,9 @@ __NEXT_STEP:
|
||||
case OP_LOAD_TRUE: PUSH(True); DISPATCH()
|
||||
case OP_LOAD_FALSE: PUSH(False); DISPATCH()
|
||||
/*****************************************/
|
||||
case OP_LOAD_SMALL_INT: PUSH(VAR((int16_t)byte.arg)); DISPATCH()
|
||||
case OP_LOAD_SMALL_INT:
|
||||
s_data.emplace(tp_int, (i64)(int16_t)byte.arg);
|
||||
DISPATCH()
|
||||
/*****************************************/
|
||||
case OP_LOAD_ELLIPSIS: PUSH(Ellipsis); DISPATCH()
|
||||
case OP_LOAD_FUNCTION: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user