mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
4732d4149d
commit
371411d53a
@ -2,7 +2,7 @@ with open("src/opcodes.h", "rt", encoding='utf-8') as f:
|
|||||||
OPCODES_TEXT = f.read()
|
OPCODES_TEXT = f.read()
|
||||||
|
|
||||||
pipeline = [
|
pipeline = [
|
||||||
["common.h", "hash_table5.hpp", "memory.h", "str.h", "safestl.h", "builtins.h", "error.h"],
|
["common.h", "memory.h", "str.h", "tuplelist.h", "namedict.h", "builtins.h", "error.h"],
|
||||||
["obj.h", "parser.h", "ref.h", "codeobject.h", "frame.h"],
|
["obj.h", "parser.h", "ref.h", "codeobject.h", "frame.h"],
|
||||||
["vm.h", "ceval.h", "compiler.h", "repl.h"],
|
["vm.h", "ceval.h", "compiler.h", "repl.h"],
|
||||||
["iter.h", "pocketpy.h"]
|
["iter.h", "pocketpy.h"]
|
||||||
|
@ -28,16 +28,13 @@
|
|||||||
// #include <filesystem>
|
// #include <filesystem>
|
||||||
// namespace fs = std::filesystem;
|
// namespace fs = std::filesystem;
|
||||||
|
|
||||||
#define EMH_EXT 1
|
|
||||||
#define EMH_FIND_HIT 1
|
|
||||||
|
|
||||||
#ifdef POCKETPY_H
|
#ifdef POCKETPY_H
|
||||||
#define UNREACHABLE() throw std::runtime_error( "L" + std::to_string(__LINE__) + " UNREACHABLE()!");
|
#define UNREACHABLE() throw std::runtime_error( "L" + std::to_string(__LINE__) + " UNREACHABLE()!");
|
||||||
#else
|
#else
|
||||||
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PK_VERSION "0.8.9"
|
#define PK_VERSION "0.9.0"
|
||||||
|
|
||||||
#if defined(__EMSCRIPTEN__) || defined(__arm__) || defined(__i386__)
|
#if defined(__EMSCRIPTEN__) || defined(__arm__) || defined(__i386__)
|
||||||
typedef int32_t i64;
|
typedef int32_t i64;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "safestl.h"
|
#include "namedict.h"
|
||||||
|
#include "tuplelist.h"
|
||||||
|
|
||||||
struct NeedMoreLines {
|
struct NeedMoreLines {
|
||||||
NeedMoreLines(bool is_compiling_class) : is_compiling_class(is_compiling_class) {}
|
NeedMoreLines(bool is_compiling_class) : is_compiling_class(is_compiling_class) {}
|
||||||
|
2034
src/hash_table5.hpp
2034
src/hash_table5.hpp
File diff suppressed because it is too large
Load Diff
1788
src/hash_table8.hpp
1788
src/hash_table8.hpp
File diff suppressed because it is too large
Load Diff
@ -147,3 +147,8 @@ struct SmallArrayPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef pkpy::shared_ptr<PyObject> PyVar;
|
||||||
|
typedef PyVar PyVarOrNull;
|
||||||
|
typedef PyVar PyVarRef;
|
@ -1,14 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "safestl.h"
|
#include "common.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "str.h"
|
||||||
|
|
||||||
struct NameDictNode{
|
namespace pkpy{
|
||||||
|
|
||||||
|
struct NameDictNode{
|
||||||
StrName first;
|
StrName first;
|
||||||
PyVar second;
|
PyVar second;
|
||||||
inline bool empty() const { return first.empty(); }
|
inline bool empty() const { return first.empty(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NameDict {
|
struct NameDict {
|
||||||
int _capacity;
|
int _capacity;
|
||||||
int _size;
|
int _size;
|
||||||
float _load_factor;
|
float _load_factor;
|
||||||
@ -40,8 +44,8 @@ struct NameDict {
|
|||||||
|
|
||||||
int size() const { return _size; }
|
int size() const { return _size; }
|
||||||
|
|
||||||
//https://github.com/python/cpython/blob/main/Objects/dictobject.c#L175
|
//https://github.com/python/cpython/blob/main/Objects/dictobject.c#L175
|
||||||
#define HASH_PROBE(key, ok, i) \
|
#define HASH_PROBE(key, ok, i) \
|
||||||
int i = (key).index % _capacity; \
|
int i = (key).index % _capacity; \
|
||||||
bool ok = false; \
|
bool ok = false; \
|
||||||
while(!_a[i].empty()) { \
|
while(!_a[i].empty()) { \
|
||||||
@ -49,7 +53,7 @@ struct NameDict {
|
|||||||
i = (5*i + 1) % _capacity; \
|
i = (5*i + 1) % _capacity; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HASH_PROBE_OVERRIDE(key, ok, i) \
|
#define HASH_PROBE_OVERRIDE(key, ok, i) \
|
||||||
i = (key).index % _capacity; \
|
i = (key).index % _capacity; \
|
||||||
ok = false; \
|
ok = false; \
|
||||||
while(!_a[i].empty()) { \
|
while(!_a[i].empty()) { \
|
||||||
@ -85,6 +89,7 @@ struct NameDict {
|
|||||||
for(int i=0; i<old_capacity; i++){
|
for(int i=0; i<old_capacity; i++){
|
||||||
if(old_a[i].empty()) continue;
|
if(old_a[i].empty()) continue;
|
||||||
HASH_PROBE(old_a[i].first, ok, j);
|
HASH_PROBE(old_a[i].first, ok, j);
|
||||||
|
if(ok) UNREACHABLE();
|
||||||
_a[j].first = old_a[i].first;
|
_a[j].first = old_a[i].first;
|
||||||
_a[j].second = std::move(old_a[i].second);
|
_a[j].second = std::move(old_a[i].second);
|
||||||
_size++;
|
_size++;
|
||||||
@ -155,6 +160,8 @@ struct NameDict {
|
|||||||
inline iterator begin() const { return iterator(this, 0); }
|
inline iterator begin() const { return iterator(this, 0); }
|
||||||
inline iterator end() const { return iterator(this, _capacity); }
|
inline iterator end() const { return iterator(this, _capacity); }
|
||||||
|
|
||||||
#undef HASH_PROBE
|
#undef HASH_PROBE
|
||||||
#undef HASH_PROBE_OVERRIDE
|
#undef HASH_PROBE_OVERRIDE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace pkpy
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "safestl.h"
|
#include "namedict.h"
|
||||||
|
#include "tuplelist.h"
|
||||||
|
|
||||||
struct CodeObject;
|
struct CodeObject;
|
||||||
struct Frame;
|
struct Frame;
|
||||||
|
@ -4,18 +4,7 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
struct PyObject;
|
|
||||||
typedef pkpy::shared_ptr<PyObject> PyVar;
|
|
||||||
typedef PyVar PyVarOrNull;
|
|
||||||
typedef PyVar PyVarRef;
|
|
||||||
|
|
||||||
#include "hash_table5.hpp"
|
|
||||||
namespace pkpy {
|
namespace pkpy {
|
||||||
#include "namedict.h"
|
|
||||||
// template<typename... Args>
|
|
||||||
// using HashMap = emhash5::HashMap<Args...>;
|
|
||||||
// typedef HashMap<StrName, PyVar> NameDict;
|
|
||||||
|
|
||||||
class List: public std::vector<PyVar> {
|
class List: public std::vector<PyVar> {
|
||||||
PyVar& at(size_t) = delete;
|
PyVar& at(size_t) = delete;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user