mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
10842207ea
commit
fe8d102748
@ -321,10 +321,7 @@ PyVar lua_popx_to_python(VM* vm) {
|
|||||||
|
|
||||||
void initialize_lua_bridge(VM* vm, lua_State* newL){
|
void initialize_lua_bridge(VM* vm, lua_State* newL){
|
||||||
PyObject* mod = vm->new_module("lua");
|
PyObject* mod = vm->new_module("lua");
|
||||||
|
assert(_L == nullptr); // lua bridge already initialized
|
||||||
if(_L != nullptr){
|
|
||||||
throw std::runtime_error("lua bridge already initialized");
|
|
||||||
}
|
|
||||||
_L = newL;
|
_L = newL;
|
||||||
|
|
||||||
vm->register_user_class<PyLuaTable>(mod, "Table");
|
vm->register_user_class<PyLuaTable>(mod, "Table");
|
||||||
|
@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /Ox /jumptablerdata /GS-")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /utf-8 /Ox /jumptablerdata /GS-")
|
||||||
|
add_compile_options(/wd4267 /wd4244)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -frtti -O2")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -frtti -O2")
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "pocketpy/config.h"
|
#include "pocketpy/config.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "pocketpy/interpreter/frame.hpp"
|
#include "pocketpy/interpreter/frame.hpp"
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
namespace pkpy {
|
namespace pkpy {
|
||||||
|
|
||||||
struct _LineRecord{
|
struct _LineRecord{
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "pocketpy/interpreter/frame.hpp"
|
#include "pocketpy/interpreter/frame.hpp"
|
||||||
#include "pocketpy/interpreter/profiler.hpp"
|
#include "pocketpy/interpreter/profiler.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
/* Stack manipulation macros */
|
/* Stack manipulation macros */
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "pocketpy/config.h"
|
#include "pocketpy/config.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "pocketpy/common/version.hpp"
|
#include "pocketpy/common/version.hpp"
|
||||||
#include "pocketpy/interpreter/vm.hpp"
|
#include "pocketpy/interpreter/vm.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
PrattRule Compiler::rules[kTokenCount];
|
PrattRule Compiler::rules[kTokenCount];
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace pkpy{
|
|||||||
|
|
||||||
// clear the expression stack and generate bytecode
|
// clear the expression stack and generate bytecode
|
||||||
void CodeEmitContext::emit_expr(){
|
void CodeEmitContext::emit_expr(){
|
||||||
if(s_expr.size() != 1) throw std::runtime_error("s_expr.size() != 1");
|
assert(s_expr.size() == 1);
|
||||||
Expr_ expr = s_expr.popx();
|
Expr_ expr = s_expr.popx();
|
||||||
expr->emit_(this);
|
expr->emit_(this);
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ namespace pkpy{
|
|||||||
int for_codei = ctx->emit_(OP_FOR_ITER, curr_iblock, BC_KEEPLINE);
|
int for_codei = ctx->emit_(OP_FOR_ITER, curr_iblock, BC_KEEPLINE);
|
||||||
bool ok = vars->emit_store(ctx);
|
bool ok = vars->emit_store(ctx);
|
||||||
// this error occurs in `vars` instead of this line, but...nevermind
|
// this error occurs in `vars` instead of this line, but...nevermind
|
||||||
if(!ok) throw std::runtime_error("SyntaxError");
|
assert(ok); // this should raise a SyntaxError, but we just assert it
|
||||||
ctx->try_merge_for_iter_store(for_codei);
|
ctx->try_merge_for_iter_store(for_codei);
|
||||||
if(cond){
|
if(cond){
|
||||||
cond->emit_(ctx);
|
cond->emit_(ctx);
|
||||||
|
@ -79,7 +79,7 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
|||||||
|
|
||||||
char Lexer::eatchar() {
|
char Lexer::eatchar() {
|
||||||
char c = peekchar();
|
char c = peekchar();
|
||||||
if(c == '\n') throw std::runtime_error("eatchar() cannot consume a newline");
|
assert(c != '\n'); // eatchar() cannot consume a newline
|
||||||
curr_char++;
|
curr_char++;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "pocketpy/objects/stackmemory.hpp"
|
#include "pocketpy/objects/stackmemory.hpp"
|
||||||
#include "pocketpy/interpreter/frame.hpp"
|
#include "pocketpy/interpreter/frame.hpp"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
PyVar* FastLocals::try_get_name(StrName name){
|
PyVar* FastLocals::try_get_name(StrName name){
|
||||||
int index = co->varnames_inv.try_get(name);
|
int index = co->varnames_inv.try_get(name);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
static const char* OP_NAMES[] = {
|
static const char* OP_NAMES[] = {
|
||||||
#define OPCODE(name) #name,
|
#define OPCODE(name) #name,
|
||||||
|
@ -38,9 +38,7 @@ static PyVar stack_item(VM* vm, int index){
|
|||||||
}
|
}
|
||||||
int size = end - begin;
|
int size = end - begin;
|
||||||
if(index < 0) index += size;
|
if(index < 0) index += size;
|
||||||
if(index < 0 || index >= size){
|
assert(index >= 0 && index < size);
|
||||||
throw std::runtime_error("stack_item() => index out of range");
|
|
||||||
}
|
|
||||||
return begin[index];
|
return begin[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user