Commit d915f9e4 authored by Boxiang Sun's avatar Boxiang Sun

index_id temp fix

parent df55c251
...@@ -822,8 +822,8 @@ Value ASTInterpreter::visit_importfrom(BST_ImportFrom* node) { ...@@ -822,8 +822,8 @@ Value ASTInterpreter::visit_importfrom(BST_ImportFrom* node) {
InternedString name = getCodeConstants().getInternedString(node->index_id); InternedString name = getCodeConstants().getInternedString(node->index_id);
Value v; Value v;
if (jit) if (jit)
v.var = jit->emitImportFrom(module, name); v.var = jit->emitImportFrom(module, name.getBox());
v.o = importFrom(module.o, (BoxedString*)name); v.o = importFrom(module.o, name.getBox());
return v; return v;
} }
...@@ -836,7 +836,7 @@ Value ASTInterpreter::visit_importname(BST_ImportName* node) { ...@@ -836,7 +836,7 @@ Value ASTInterpreter::visit_importname(BST_ImportName* node) {
Value v; Value v;
if (jit) if (jit)
v.var = jit->emitImportName(level, froms, name.getBox()); v.var = jit->emitImportName(level, froms, name.getBox());
v.o = import(level, froms.o, (BoxedString*)name); v.o = import(level, froms.o, name.getBox());
return v; return v;
} }
......
...@@ -946,6 +946,8 @@ private: ...@@ -946,6 +946,8 @@ private:
InternedString name = irstate->getCodeConstants().getInternedString(node->index_id); InternedString name = irstate->getCodeConstants().getInternedString(node->index_id);
llvm::Value* converted_name = embedRelocatablePtr(name, g.llvm_boxedstring_type_ptr); llvm::Value* converted_name = embedRelocatablePtr(name, g.llvm_boxedstring_type_ptr);
emitter.setType(converted_name, RefType::BORROWED);
llvm::Value* r = emitter.createCall2(unw_info, g.funcs.importFrom, converted_module->getValue(), llvm::Value* r = emitter.createCall2(unw_info, g.funcs.importFrom, converted_module->getValue(),
converted_name); converted_name);
emitter.setType(r, RefType::OWNED); emitter.setType(r, RefType::OWNED);
...@@ -976,6 +978,8 @@ private: ...@@ -976,6 +978,8 @@ private:
InternedString name = irstate->getCodeConstants().getInternedString(node->index_id); InternedString name = irstate->getCodeConstants().getInternedString(node->index_id);
llvm::Value* converted_name = embedRelocatablePtr(name, g.llvm_boxedstring_type_ptr); llvm::Value* converted_name = embedRelocatablePtr(name, g.llvm_boxedstring_type_ptr);
emitter.setType(converted_name, RefType::BORROWED);
llvm::Value* imported llvm::Value* imported
= emitter.createCall(unw_info, g.funcs.import, { getConstantInt(level, g.i32), converted_froms->getValue(), = emitter.createCall(unw_info, g.funcs.import, { getConstantInt(level, g.i32), converted_froms->getValue(),
converted_name }); converted_name });
......
...@@ -133,9 +133,8 @@ extern "C" PyObject* PyImport_ExecCodeModuleEx(const char* name, PyObject* co, c ...@@ -133,9 +133,8 @@ extern "C" PyObject* PyImport_ExecCodeModuleEx(const char* name, PyObject* co, c
} }
} }
extern "C" Box* import(int level, Box* from_imports, Box* _module_name) { extern "C" Box* import(int level, Box* from_imports, BoxedString* module_name) {
assert(_module_name->cls == str_cls); assert(module_name->cls == str_cls);
BoxedString* module_name = (BoxedString*)_module_name;
Box* rtn = PyImport_ImportModuleLevel(module_name->c_str(), getGlobalsDict(), NULL, from_imports, level); Box* rtn = PyImport_ImportModuleLevel(module_name->c_str(), getGlobalsDict(), NULL, from_imports, level);
if (!rtn) if (!rtn)
throwCAPIException(); throwCAPIException();
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
namespace pyston { namespace pyston {
extern "C" PyObject* PyImport_GetImporter(PyObject* path) noexcept; extern "C" PyObject* PyImport_GetImporter(PyObject* path) noexcept;
extern "C" Box* import(int level, Box* from_imports, Box* module_name); extern "C" Box* import(int level, Box* from_imports, BoxedString* module_name);
BoxedModule* importCExtension(BoxedString* full_name, const std::string& last_name, const std::string& path); BoxedModule* importCExtension(BoxedString* full_name, const std::string& last_name, const std::string& path);
#ifdef Py_REF_DEBUG #ifdef Py_REF_DEBUG
......
...@@ -7636,11 +7636,10 @@ extern "C" void setGlobal(Box* globals, BoxedString* name, STOLEN(Box*) value) { ...@@ -7636,11 +7636,10 @@ extern "C" void setGlobal(Box* globals, BoxedString* name, STOLEN(Box*) value) {
} }
} }
extern "C" Box* importFrom(Box* _m, Box* _name) { extern "C" Box* importFrom(Box* _m, BoxedString* name) {
STAT_TIMER(t0, "us_timer_importFrom", 10); STAT_TIMER(t0, "us_timer_importFrom", 10);
assert(_name->cls == str_cls); assert(name->cls == str_cls);
BoxedString* name = (BoxedString*)_name;
Box* r = getattrInternal<CXX>(_m, name); Box* r = getattrInternal<CXX>(_m, name);
if (r) if (r)
......
...@@ -94,7 +94,7 @@ extern "C" void assignSlice(PyObject* u, PyObject* v, PyObject* w, PyObject* x); ...@@ -94,7 +94,7 @@ extern "C" void assignSlice(PyObject* u, PyObject* v, PyObject* w, PyObject* x);
extern "C" Box* getclsattr(Box* obj, BoxedString* attr) __attribute__((noinline)); extern "C" Box* getclsattr(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" Box* getclsattrMaybeNonstring(Box* obj, Box* attr) __attribute__((noinline)); extern "C" Box* getclsattrMaybeNonstring(Box* obj, Box* attr) __attribute__((noinline));
extern "C" Box* unaryop(Box* operand, int op_type) __attribute__((noinline)); extern "C" Box* unaryop(Box* operand, int op_type) __attribute__((noinline));
extern "C" Box* importFrom(Box* obj, Box* attr) __attribute__((noinline)); extern "C" Box* importFrom(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" Box* importStar(Box* from_module, Box* to_globals) __attribute__((noinline)); extern "C" Box* importStar(Box* from_module, Box* to_globals) __attribute__((noinline));
extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size, Box** out_keep_alive); extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size, Box** out_keep_alive);
extern "C" void assertNameDefined(bool b, const char* name, BoxedClass* exc_cls, bool local_var_msg); extern "C" void assertNameDefined(bool b, const char* name, BoxedClass* exc_cls, bool local_var_msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment