mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 12:30:19 +00:00
up
This commit is contained in:
parent
2d26f836ae
commit
f13caf5c48
@ -173,7 +173,7 @@ private:
|
||||
if(base == 16) SyntaxError("hex literal should not contain a dot");
|
||||
parser->set_next_token(TK("@num"), vm->PyFloat(S_TO_FLOAT(m[0], &size)));
|
||||
} else {
|
||||
parser->set_next_token(TK("@num"), vm->PyInt(S_TO_INT(m[0], &size, base)));
|
||||
parser->set_next_token(TK("@num"), py_object(vm, S_TO_INT(m[0], &size, base)));
|
||||
}
|
||||
if (size != m.length()) UNREACHABLE();
|
||||
}
|
||||
|
8
src/vm.h
8
src/vm.h
@ -955,10 +955,10 @@ void CodeObject::optimize(VM* vm){
|
||||
}
|
||||
}
|
||||
|
||||
PyVar py_object(VM* vm, i64 val){
|
||||
if(((val << 2) >> 2) != val){
|
||||
vm->_error("OverflowError", std::to_string(val) + " is out of range");
|
||||
}
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_integral_v<T>, PyVar> py_object(VM* vm, T _val){
|
||||
i64 val = static_cast<i64>(_val);
|
||||
if(((val << 2) >> 2) != val) vm->_error("OverflowError", std::to_string(val));
|
||||
val = (val << 2) | 0b01;
|
||||
return PyVar(reinterpret_cast<int*>(val));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user