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) {
InternedString name = getCodeConstants().getInternedString(node->index_id);
Value v;
if (jit)
v.var = jit->emitImportFrom(module, name);
v.o = importFrom(module.o, (BoxedString*)name);
v.var = jit->emitImportFrom(module, name.getBox());
v.o = importFrom(module.o, name.getBox());
return v;
}
......@@ -836,7 +836,7 @@ Value ASTInterpreter::visit_importname(BST_ImportName* node) {
Value v;
if (jit)
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;
}
......
......@@ -946,6 +946,8 @@ private:
InternedString name = irstate->getCodeConstants().getInternedString(node->index_id);
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(),
converted_name);
emitter.setType(r, RefType::OWNED);
......@@ -976,6 +978,8 @@ private:
InternedString name = irstate->getCodeConstants().getInternedString(node->index_id);
llvm::Value* converted_name = embedRelocatablePtr(name, g.llvm_boxedstring_type_ptr);
emitter.setType(converted_name, RefType::BORROWED);
llvm::Value* imported
= emitter.createCall(unw_info, g.funcs.import, { getConstantInt(level, g.i32), converted_froms->getValue(),
converted_name });
......
......@@ -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) {
assert(_module_name->cls == str_cls);
BoxedString* module_name = (BoxedString*)_module_name;
extern "C" Box* import(int level, Box* from_imports, BoxedString* module_name) {
assert(module_name->cls == str_cls);
Box* rtn = PyImport_ImportModuleLevel(module_name->c_str(), getGlobalsDict(), NULL, from_imports, level);
if (!rtn)
throwCAPIException();
......
......@@ -20,7 +20,7 @@
namespace pyston {
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);
#ifdef Py_REF_DEBUG
......
......@@ -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);
assert(_name->cls == str_cls);
BoxedString* name = (BoxedString*)_name;
assert(name->cls == str_cls);
Box* r = getattrInternal<CXX>(_m, name);
if (r)
......
......@@ -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* getclsattrMaybeNonstring(Box* obj, Box* attr) __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** 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);
......
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