Commit bcd80646 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Move filename and name off of SourceInfo

parent 1b101760
......@@ -297,7 +297,7 @@ void ASTInterpreter::startJITing(CFGBlock* block, int exit_offset, llvm::DenseSe
code_block = code_blocks[code_blocks.size() - 1].get();
if (!code_block || code_block->shouldCreateNewBlock()) {
code_blocks.push_back(llvm::make_unique<JitCodeBlock>(getCode(), source_info->getName()->s()));
code_blocks.push_back(llvm::make_unique<JitCodeBlock>(getCode(), getCode()->name->s()));
code_block = code_blocks[code_blocks.size() - 1].get();
exit_offset = 0;
}
......@@ -1002,7 +1002,7 @@ Value ASTInterpreter::visit_stmt(AST_stmt* node) {
#endif
if (0) {
printf("%20s % 2d ", source_info->getName()->c_str(), current_block->idx);
printf("%20s % 2d ", getCode()->name->c_str(), current_block->idx);
print_ast(node);
printf("\n");
}
......
......@@ -36,27 +36,6 @@
namespace pyston {
BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, std::unique_ptr<SourceInfo> source,
ParamNames param_names)
: source(std::move(source)),
param_names(std::move(param_names)),
takes_varargs(takes_varargs),
takes_kwargs(takes_kwargs),
num_args(num_args),
times_interpreted(0),
internal_callable(NULL, NULL) {
}
BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names)
: source(nullptr),
param_names(param_names),
takes_varargs(takes_varargs),
takes_kwargs(takes_kwargs),
num_args(num_args),
times_interpreted(0),
internal_callable(NULL, NULL) {
}
void BoxedCode::addVersion(CompiledFunction* compiled) {
assert(compiled);
assert((compiled->spec != NULL) + (compiled->entry_descriptor != NULL) == 1);
......@@ -79,15 +58,8 @@ void BoxedCode::addVersion(CompiledFunction* compiled) {
}
}
SourceInfo::SourceInfo(BoxedModule* m, ScopingResults scoping, FutureFlags future_flags, AST* ast, BoxedString* fn)
SourceInfo::SourceInfo(BoxedModule* m, ScopingResults scoping, FutureFlags future_flags, AST* ast)
: parent_module(m), scoping(std::move(scoping)), ast(ast), cfg(NULL), future_flags(future_flags) {
assert(fn);
// TODO: this is a very bad way of handling this:
incref(fn);
late_constants.push_back(fn);
this->fn = fn;
switch (ast->type) {
case AST_TYPE::ClassDef:
......
......@@ -988,14 +988,14 @@ static void computeBlockSetClosure(BlockSet& blocks) {
}
}
// returns a pointer to the function-info mdnode
static llvm::MDNode* setupDebugInfo(SourceInfo* source, llvm::Function* f, std::string origname) {
static llvm::MDNode* setupDebugInfo(BoxedCode* code, llvm::Function* f, std::string origname) {
int lineno = 0;
if (source->ast)
lineno = source->ast->lineno;
if (code->source->ast)
lineno = code->source->ast->lineno;
llvm::DIBuilder builder(*g.cur_module);
BoxedString* fn = source->getFn();
BoxedString* fn = code->filename;
std::string dir = "";
std::string producer = "pyston; git rev " STRINGIFY(GITREV);
......@@ -1102,7 +1102,7 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(BoxedCode* code, SourceI
// g.func_registry.registerFunction(f, g.cur_module);
llvm::MDNode* dbg_funcinfo = setupDebugInfo(source, f, nameprefix);
llvm::MDNode* dbg_funcinfo = setupDebugInfo(code, f, nameprefix);
irgen_us += _t2.split();
......
......@@ -69,33 +69,6 @@ llvm::ArrayRef<AST_stmt*> SourceInfo::getBody() const {
};
}
BORROWED(BoxedString*) SourceInfo::getFn() {
assert(fn->ob_refcnt >= 1);
return fn;
}
BORROWED(BoxedString*) SourceInfo::getName() noexcept {
assert(ast);
static BoxedString* lambda_name = getStaticString("<lambda>");
static BoxedString* module_name = getStaticString("<module>");
switch (ast->type) {
case AST_TYPE::ClassDef:
return ast_cast<AST_ClassDef>(ast)->name.getBox();
case AST_TYPE::FunctionDef:
if (ast_cast<AST_FunctionDef>(ast)->name != InternedString())
return ast_cast<AST_FunctionDef>(ast)->name.getBox();
return lambda_name;
case AST_TYPE::Module:
case AST_TYPE::Expression:
case AST_TYPE::Suite:
return module_name;
default:
RELEASE_ASSERT(0, "%d", ast->type);
}
}
Box* SourceInfo::getDocString() {
auto body = getBody();
if (body.size() > 0 && body[0]->type == AST_TYPE::Expr
......@@ -172,7 +145,7 @@ CompiledFunction* compileFunction(BoxedCode* code, FunctionSpecialization* spec,
SourceInfo* source = code->source.get();
assert(source);
BoxedString* name = source->getName();
BoxedString* name = code->name;
ASSERT(code->versions.size() < 20, "%s %u", name->c_str(), code->versions.size());
......@@ -201,7 +174,7 @@ CompiledFunction* compileFunction(BoxedCode* code, FunctionSpecialization* spec,
RELEASE_ASSERT((int)effort < sizeof(colors) / sizeof(colors[0]), "");
if (spec) {
ss << "\033[" << colors[(int)effort] << ";1mJIT'ing " << source->getFn()->s() << ":" << name->s()
ss << "\033[" << colors[(int)effort] << ";1mJIT'ing " << code->filename->s() << ":" << name->s()
<< " with signature (";
for (int i = 0; i < spec->arg_types.size(); i++) {
if (i > 0)
......@@ -212,7 +185,7 @@ CompiledFunction* compileFunction(BoxedCode* code, FunctionSpecialization* spec,
ss << ") -> ";
ss << spec->rtn_type->debugName();
} else {
ss << "\033[" << colors[(int)effort] << ";1mDoing OSR-entry partial compile of " << source->getFn()->s()
ss << "\033[" << colors[(int)effort] << ";1mDoing OSR-entry partial compile of " << code->filename->s()
<< ":" << name->s() << ", starting with backedge to block " << entry_descriptor->backedge->target->idx;
}
ss << " at effort level " << (int)effort << " with exception style "
......@@ -243,7 +216,7 @@ CompiledFunction* compileFunction(BoxedCode* code, FunctionSpecialization* spec,
static StatCounter us_compiling("us_compiling");
us_compiling.log(us);
if (VERBOSITY() >= 1 && us > 100000) {
printf("Took %ldms to compile %s::%s (effort %d)!\n", us / 1000, source->getFn()->c_str(), name->c_str(),
printf("Took %ldms to compile %s::%s (effort %d)!\n", us / 1000, code->filename->c_str(), name->c_str(),
(int)effort);
}
......
......@@ -213,7 +213,7 @@ template <typename Builder> static llvm::Value* getGlobalsGep(Builder& builder,
return builder.CreateConstInBoundsGEP2_32(v, 0, 7);
}
template <typename Builder> static llvm::Value* getMDGep(Builder& builder, llvm::Value* v) {
template <typename Builder> static llvm::Value* getCodeGep(Builder& builder, llvm::Value* v) {
static_assert(offsetof(FrameInfo, code) == 72 + 16, "");
return builder.CreateConstInBoundsGEP2_32(v, 0, 9);
}
......@@ -330,8 +330,8 @@ void IRGenState::setupFrameInfoVar(llvm::Value* passed_closure, llvm::Value* pas
builder.CreateStore(vregs, getVRegsGep(builder, al));
builder.CreateStore(getConstantInt(num_user_visible_vregs, g.i32), getNumVRegsGep(builder, al));
builder.CreateStore(
getRefcounts()->setType(embedRelocatablePtr(getMD(), g.llvm_code_type_ptr), RefType::BORROWED),
getMDGep(builder, al));
getRefcounts()->setType(embedRelocatablePtr(getCode(), g.llvm_code_type_ptr), RefType::BORROWED),
getCodeGep(builder, al));
this->frame_info = al;
this->globals = passed_globals;
......@@ -1709,8 +1709,8 @@ private:
// I think it's better to just not generate bad speculations:
if (rtn->canConvertTo(speculated_type)) {
auto source = irstate->getSourceInfo();
printf("On %s:%d, function %s:\n", source->getFn()->c_str(), source->getBody()[0]->lineno,
source->getName()->c_str());
printf("On %s:%d, function %s:\n", irstate->getCode()->filename->c_str(), source->getBody()[0]->lineno,
irstate->getCode()->name->c_str());
irstate->getSourceInfo()->cfg->print();
}
RELEASE_ASSERT(!rtn->canConvertTo(speculated_type), "%s %s", rtn->getType()->debugName().c_str(),
......@@ -2337,7 +2337,7 @@ private:
// Emitting the actual OSR:
emitter.getBuilder()->SetInsertPoint(onramp);
OSREntryDescriptor* entry = OSREntryDescriptor::create(irstate->getMD(), osr_key, irstate->getExceptionStyle());
OSREntryDescriptor* entry = OSREntryDescriptor::create(irstate->getCode(), osr_key, irstate->getExceptionStyle());
OSRExit* exit = new OSRExit(entry);
llvm::Value* partial_func = emitter.getBuilder()->CreateCall(g.funcs.compilePartialFunc,
embedRelocatablePtr(exit, g.i8->getPointerTo()));
......
......@@ -91,7 +91,7 @@ public:
CFG* getCFG() { return getSourceInfo()->cfg; }
CompiledFunction* getCurFunction() { return cf; }
BoxedCode* getMD() { return code; }
BoxedCode* getCode() { return code; }
ExceptionStyle getExceptionStyle() { return cf->exception_style; }
......
......@@ -490,9 +490,7 @@ static const LineInfo lineInfoForFrameInfo(FrameInfo* frame_info) {
auto* code = frame_info->code;
assert(code);
auto source = code->source.get();
return LineInfo(current_stmt->lineno, current_stmt->col_offset, source->getFn(), source->getName());
return LineInfo(current_stmt->lineno, current_stmt->col_offset, code->filename, code->name);
}
// A class that converts a C stack trace to a Python stack trace.
......@@ -1073,7 +1071,7 @@ std::string getCurrentPythonLine() {
auto current_stmt = frame_info->stmt;
stream << source->getFn()->c_str() << ":" << current_stmt->lineno;
stream << code->filename->c_str() << ":" << current_stmt->lineno;
return stream.str();
}
return "unknown:-1";
......
......@@ -263,7 +263,7 @@ public:
void runRecursively(AST* ast, AST_arguments* args, AST* orig_node);
};
static CFG* computeCFG(SourceInfo* source, const ParamNames& param_names, ScopeInfo* scoping,
static CFG* computeCFG(BoxedString* fn, SourceInfo* source, const ParamNames& param_names, ScopeInfo* scoping,
ModuleCFGProcessor* cfgizer);
// A class that crawls the AST of a single function and computes the CFG
......@@ -343,6 +343,7 @@ private:
// ---------- Member fields ----------
private:
BoxedString* filename;
SourceInfo* source;
InternedStringPool& stringpool;
ScopeInfo* scoping;
......@@ -360,12 +361,14 @@ private:
unsigned int next_var_index = 0;
friend CFG* computeCFG(SourceInfo* source, const ParamNames& param_names, ScopeInfo*, ModuleCFGProcessor*);
friend CFG* computeCFG(BoxedString* fn, SourceInfo* source, const ParamNames& param_names, ScopeInfo*,
ModuleCFGProcessor*);
public:
CFGVisitor(SourceInfo* source, InternedStringPool& stringpool, ScopeInfo* scoping, AST_TYPE::AST_TYPE root_type,
FutureFlags future_flags, CFG* cfg, ModuleCFGProcessor* cfgizer)
: source(source),
CFGVisitor(BoxedString* filename, SourceInfo* source, InternedStringPool& stringpool, ScopeInfo* scoping,
AST_TYPE::AST_TYPE root_type, FutureFlags future_flags, CFG* cfg, ModuleCFGProcessor* cfgizer)
: filename(filename),
source(source),
stringpool(stringpool),
scoping(scoping),
root_type(root_type),
......@@ -459,8 +462,7 @@ private:
}
}
raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, source->getFn()->s(), "",
true);
raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, filename->s(), "", true);
}
void doBreak(AST* value) {
......@@ -477,7 +479,7 @@ private:
}
}
raiseSyntaxError("'break' outside loop", value->lineno, value->col_offset, source->getFn()->s(), "", true);
raiseSyntaxError("'break' outside loop", value->lineno, value->col_offset, filename->s(), "", true);
}
AST_expr* callNonzero(AST_expr* e) {
......@@ -2959,7 +2961,7 @@ void VRegInfo::assignVRegs(CFG* cfg, const ParamNames& param_names) {
}
static CFG* computeCFG(SourceInfo* source, const ParamNames& param_names, ScopeInfo* scoping,
static CFG* computeCFG(BoxedString* filename, SourceInfo* source, const ParamNames& param_names, ScopeInfo* scoping,
ModuleCFGProcessor* cfgizer) {
STAT_TIMER(t0, "us_timer_computecfg", 0);
......@@ -2968,7 +2970,7 @@ static CFG* computeCFG(SourceInfo* source, const ParamNames& param_names, ScopeI
CFG* rtn = new CFG();
auto&& stringpool = cfgizer->stringpool;
CFGVisitor visitor(source, stringpool, scoping, source->ast->type, source->future_flags, rtn, cfgizer);
CFGVisitor visitor(filename, source, stringpool, scoping, source->ast->type, source->future_flags, rtn, cfgizer);
bool skip_first = false;
......@@ -3091,7 +3093,6 @@ static CFG* computeCFG(SourceInfo* source, const ParamNames& param_names, ScopeI
if (b->predecessors.size() == 0) {
if (b != rtn->getStartingBlock()) {
rtn->print();
printf("%s\n", source->getName()->c_str());
}
ASSERT(b == rtn->getStartingBlock(), "%d", b->idx);
}
......@@ -3290,19 +3291,19 @@ InternedStringPool& stringpoolForAST(AST* ast) {
void ModuleCFGProcessor::runRecursively(AST* ast, AST_arguments* args, AST* orig_node) {
ScopeInfo* scope_info = scoping.getScopeInfoForNode(orig_node);
std::unique_ptr<SourceInfo> si(
new SourceInfo(bm, ScopingResults(scope_info, scoping.areGlobalsFromModule()), future_flags, ast, fn));
new SourceInfo(bm, ScopingResults(scope_info, scoping.areGlobalsFromModule()), future_flags, ast));
ParamNames param_names(ast, stringpool);
for (auto e : param_names.allArgsAsName())
fillScopingInfo(e, scope_info);
si->cfg = computeCFG(si.get(), param_names, scope_info, this);
si->cfg = computeCFG(fn, si.get(), param_names, scope_info, this);
BoxedCode* code;
if (args)
code = new BoxedCode(args->args.size(), args->vararg, args->kwarg, std::move(si), std::move(param_names));
code = new BoxedCode(args->args.size(), args->vararg, args->kwarg, std::move(si), std::move(param_names), fn);
else
code = new BoxedCode(0, false, false, std::move(si), std::move(param_names));
code = new BoxedCode(0, false, false, std::move(si), std::move(param_names), fn);
// XXX very bad! Should properly track this:
constants.push_back(code);
......
......@@ -486,7 +486,6 @@ public:
// Data about a single textual function definition.
class SourceInfo {
private:
BoxedString* fn; // equivalent of code.co_filename
std::unique_ptr<LivenessAnalysis> liveness_info;
public:
......@@ -499,15 +498,11 @@ public:
LivenessAnalysis* getLiveness();
// does not throw CXX or CAPI exceptions:
BORROWED(BoxedString*) getName() noexcept;
BORROWED(BoxedString*) getFn();
llvm::ArrayRef<AST_stmt*> getBody() const;
Box* getDocString();
SourceInfo(BoxedModule* m, ScopingResults scoping, FutureFlags future_flags, AST* ast, BoxedString* fn);
SourceInfo(BoxedModule* m, ScopingResults scoping, FutureFlags future_flags, AST* ast);
~SourceInfo();
};
......
......@@ -26,28 +26,36 @@ extern "C" {
BoxedClass* code_cls;
}
#if 0
BORROWED(Box*) BoxedCode::name(Box* b, void*) noexcept {
RELEASE_ASSERT(b->cls == code_cls, "");
BoxedCode* code = static_cast<BoxedCode*>(b);
if (code->_name)
return code->_name;
return code->source->getName();
return code->name;
}
#endif
Box* BoxedCode::co_name(Box* b, void* arg) noexcept {
return incref(name(b, arg));
RELEASE_ASSERT(b->cls == code_cls, "");
BoxedCode* code = static_cast<BoxedCode*>(b);
return incref(code->name);
}
#if 0
BORROWED(Box*) BoxedCode::filename(Box* b, void*) noexcept {
RELEASE_ASSERT(b->cls == code_cls, "");
BoxedCode* code = static_cast<BoxedCode*>(b);
if (code->_filename)
return code->_filename;
return code->source->getFn();
return code->filename;
}
#endif
Box* BoxedCode::co_filename(Box* b, void* arg) noexcept {
return incref(filename(b, arg));
RELEASE_ASSERT(b->cls == code_cls, "");
BoxedCode* code = static_cast<BoxedCode*>(b);
return incref(code->filename);
}
Box* BoxedCode::firstlineno(Box* b, void*) noexcept {
......@@ -102,19 +110,67 @@ Box* BoxedCode::flags(Box* b, void*) noexcept {
void BoxedCode::dealloc(Box* b) noexcept {
BoxedCode* o = static_cast<BoxedCode*>(b);
Py_XDECREF(o->_filename);
Py_XDECREF(o->_name);
Py_XDECREF(o->filename);
Py_XDECREF(o->name);
o->source.~decltype(o->source)();
o->cls->tp_free(o);
}
BORROWED(BoxedString*) getASTName(AST* ast) noexcept {
assert(ast);
static BoxedString* lambda_name = getStaticString("<lambda>");
static BoxedString* module_name = getStaticString("<module>");
switch (ast->type) {
case AST_TYPE::ClassDef:
return ast_cast<AST_ClassDef>(ast)->name.getBox();
case AST_TYPE::FunctionDef:
if (ast_cast<AST_FunctionDef>(ast)->name != InternedString())
return ast_cast<AST_FunctionDef>(ast)->name.getBox();
return lambda_name;
case AST_TYPE::Module:
case AST_TYPE::Expression:
case AST_TYPE::Suite:
return module_name;
default:
RELEASE_ASSERT(0, "%d", ast->type);
}
}
BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, std::unique_ptr<SourceInfo> source,
ParamNames param_names, BoxedString* filename)
: source(std::move(source)),
filename(incref(filename)),
name(incref(getASTName(this->source->ast))),
param_names(std::move(param_names)),
takes_varargs(takes_varargs),
takes_kwargs(takes_kwargs),
num_args(num_args),
times_interpreted(0),
internal_callable(NULL, NULL) {
}
BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names,
BoxedString* filename)
: source(nullptr),
// This should probably be just an "incref"?
filename(xincref(filename)),
name(boxString("???")),
param_names(param_names),
takes_varargs(takes_varargs),
takes_kwargs(takes_kwargs),
num_args(num_args),
times_interpreted(0),
internal_callable(NULL, NULL) {
}
// The dummy constructor for PyCode_New:
BoxedCode::BoxedCode(Box* filename, Box* name, int firstline)
: _filename(filename),
_name(name),
BoxedCode::BoxedCode(BoxedString* filename, BoxedString* name, int firstline)
: filename(filename),
name(name),
_firstline(firstline),
param_names(ParamNames::empty()),
takes_varargs(false),
......@@ -143,7 +199,8 @@ extern "C" PyCodeObject* PyCode_New(int argcount, int nlocals, int stacksize, in
RELEASE_ASSERT(PyString_Check(filename), "");
RELEASE_ASSERT(PyString_Check(name), "");
return (PyCodeObject*)new BoxedCode(filename, name, firstlineno);
return (PyCodeObject*)new BoxedCode(static_cast<BoxedString*>(filename), static_cast<BoxedString*>(name),
firstlineno);
}
extern "C" PyCodeObject* PyCode_NewEmpty(const char* filename, const char* funcname, int firstlineno) noexcept {
......@@ -198,12 +255,12 @@ extern "C" int PyCode_GetArgCount(PyCodeObject* op) noexcept {
extern "C" BORROWED(PyObject*) PyCode_GetFilename(PyCodeObject* op) noexcept {
RELEASE_ASSERT(PyCode_Check((Box*)op), "");
return BoxedCode::filename((Box*)op, NULL);
return reinterpret_cast<BoxedCode*>(op)->filename;
}
extern "C" BORROWED(PyObject*) PyCode_GetName(PyCodeObject* op) noexcept {
RELEASE_ASSERT(PyCode_Check((Box*)op), "");
return BoxedCode::name((Box*)op, NULL);
return reinterpret_cast<BoxedCode*>(op)->name;
}
extern "C" int PyCode_HasFreeVars(PyCodeObject* _code) noexcept {
......
......@@ -361,7 +361,7 @@ static void print_frame(unw_cursor_t* cursor, const unw_proc_info_t* pip) {
if (frame_type == INTERPRETED && cf && cur_stmt) {
auto source = cf->code_obj->source.get();
// FIXME: dup'ed from lineInfoForFrame
LineInfo line(cur_stmt->lineno, cur_stmt->col_offset, source->getFn(), source->getName());
LineInfo line(cur_stmt->lineno, cur_stmt->col_offset, cf->code_obj->filename, cf->code_obj->name);
printf(" File \"%s\", line %d, in %s\n", line.file->c_str(), line.line, line.func->c_str());
}
}
......
......@@ -531,7 +531,7 @@ Box* generator_name(Box* _self, void* context) noexcept {
assert(isSubclass(_self->cls, generator_cls));
BoxedGenerator* self = static_cast<BoxedGenerator*>(_self);
return incref(self->function->code->source->getName());
return incref(self->function->code->name);
}
extern "C" int PyGen_NeedsFinalizing(PyGenObject* gen) noexcept {
......
......@@ -4011,15 +4011,7 @@ static CompiledFunction* pickVersion(BoxedCode* code, int num_output_args, Box*
}
static llvm::StringRef getFunctionName(BoxedCode* code) {
if (code->source)
return code->source->getName()->s();
else if (code->versions.size()) {
return "<builtin function>";
// std::ostringstream oss;
// oss << "<function at " << code->versions[0]->code << ">";
// return oss.str();
}
return "<unknown function>";
return code->name->s();
}
// A hacky little class that lets us save on some parameter size.
......
......@@ -378,13 +378,8 @@ BoxedFunction::BoxedFunction(BoxedCode* code, llvm::ArrayRef<Box*> defaults, Box
bool can_change_defaults)
: BoxedFunctionBase(code, defaults, closure, globals, can_change_defaults) {
// TODO eventually we want this to assert(f->source), I think, but there are still
// some builtin functions that are BoxedFunctions but really ought to be a type that
// we don't have yet.
if (code->source) {
assert(!this->name);
this->name = incref(static_cast<BoxedString*>(code->source->getName()));
}
assert(!this->name);
this->name = incref(code->name);
}
BoxedBuiltinFunctionOrMethod::BoxedBuiltinFunctionOrMethod(BoxedCode* code, const char* name, const char* doc)
......
......@@ -1078,8 +1078,8 @@ class BoxedCode : public Box {
public:
std::unique_ptr<SourceInfo> source; // source can be NULL for functions defined in the C/C++ runtime
Box* _filename = nullptr;
Box* _name = nullptr;
BoxedString* filename = nullptr;
BoxedString* name = nullptr;
int _firstline;
const ParamNames param_names;
......@@ -1110,12 +1110,13 @@ public:
InternalCallable internal_callable;
BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, std::unique_ptr<SourceInfo> source,
ParamNames param_names);
BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names = ParamNames::empty());
ParamNames param_names, BoxedString* filename);
BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names = ParamNames::empty(),
BoxedString* filename = nullptr);
~BoxedCode();
// The dummy constructor for PyCode_New:
BoxedCode(Box* filename, Box* name, int firstline);
BoxedCode(BoxedString* filename, BoxedString* name, int firstline);
DEFAULT_CLASS_SIMPLE(code_cls, false);
......@@ -1161,8 +1162,8 @@ public:
// These need to be static functions rather than methods because function
// pointers could point to them.
static BORROWED(Box*) name(Box* b, void*) noexcept;
static BORROWED(Box*) filename(Box* b, void*) noexcept;
// static BORROWED(Box*) name(Box* b, void*) noexcept;
// static BORROWED(Box*) filename(Box* b, void*) noexcept;
static Box* co_name(Box* b, void*) noexcept;
static Box* co_filename(Box* b, void*) noexcept;
static Box* firstlineno(Box* b, void*) noexcept;
......
......@@ -250,8 +250,8 @@ extern "C" void dumpEx(void* p, int levels) {
BoxedCode* code = f->code;
if (code->source) {
printf("User-defined function '%s'\n", code->source->getName()->c_str());
printf("Defined at %s:%d\n", code->source->getFn()->c_str(), code->source->ast->lineno);
printf("User-defined function '%s'\n", code->name->c_str());
printf("Defined at %s:%d\n", code->filename->c_str(), code->source->ast->lineno);
if (code->source->cfg && levels > 0) {
code->source->cfg->print();
......
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