Commit 69880e2e authored by Kevin Modzelewski's avatar Kevin Modzelewski

Refactor: remove extra ExceptionStyle namespace

parent 7405db05
...@@ -716,8 +716,7 @@ void CompiledFunction::speculationFailed() { ...@@ -716,8 +716,7 @@ void CompiledFunction::speculationFailed() {
} }
CompiledFunction::CompiledFunction(llvm::Function* func, FunctionSpecialization* spec, void* code, EffortLevel effort, CompiledFunction::CompiledFunction(llvm::Function* func, FunctionSpecialization* spec, void* code, EffortLevel effort,
ExceptionStyle::ExceptionStyle exception_style, ExceptionStyle exception_style, const OSREntryDescriptor* entry_descriptor)
const OSREntryDescriptor* entry_descriptor)
: clfunc(NULL), : clfunc(NULL),
func(func), func(func),
spec(spec), spec(spec),
...@@ -834,7 +833,7 @@ CLFunction* createRTFunction(int num_args, int num_defaults, bool takes_varargs, ...@@ -834,7 +833,7 @@ CLFunction* createRTFunction(int num_args, int num_defaults, bool takes_varargs,
} }
CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, const ParamNames& param_names, CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, const ParamNames& param_names,
ExceptionStyle::ExceptionStyle exception_style) { ExceptionStyle exception_style) {
assert(!param_names.takes_param_names || num_args == param_names.args.size()); assert(!param_names.takes_param_names || num_args == param_names.args.size());
assert(param_names.vararg.str() == ""); assert(param_names.vararg.str() == "");
assert(param_names.kwarg.str() == ""); assert(param_names.kwarg.str() == "");
...@@ -843,8 +842,7 @@ CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, ...@@ -843,8 +842,7 @@ CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args,
} }
CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, int num_defaults, bool takes_varargs, CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, int num_defaults, bool takes_varargs,
bool takes_kwargs, const ParamNames& param_names, bool takes_kwargs, const ParamNames& param_names, ExceptionStyle exception_style) {
ExceptionStyle::ExceptionStyle exception_style) {
assert(!param_names.takes_param_names || num_args == param_names.args.size()); assert(!param_names.takes_param_names || num_args == param_names.args.size());
assert(takes_varargs || param_names.vararg.str() == ""); assert(takes_varargs || param_names.vararg.str() == "");
assert(takes_kwargs || param_names.kwarg.str() == ""); assert(takes_kwargs || param_names.kwarg.str() == "");
...@@ -855,8 +853,7 @@ CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args, ...@@ -855,8 +853,7 @@ CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args,
return cl_f; return cl_f;
} }
void addRTFunction(CLFunction* cl_f, void* f, ConcreteCompilerType* rtn_type, void addRTFunction(CLFunction* cl_f, void* f, ConcreteCompilerType* rtn_type, ExceptionStyle exception_style) {
ExceptionStyle::ExceptionStyle exception_style) {
std::vector<ConcreteCompilerType*> arg_types(cl_f->numReceivedArgs(), UNKNOWN); std::vector<ConcreteCompilerType*> arg_types(cl_f->numReceivedArgs(), UNKNOWN);
return addRTFunction(cl_f, f, rtn_type, arg_types, exception_style); return addRTFunction(cl_f, f, rtn_type, arg_types, exception_style);
} }
...@@ -867,8 +864,7 @@ static ConcreteCompilerType* processType(ConcreteCompilerType* type) { ...@@ -867,8 +864,7 @@ static ConcreteCompilerType* processType(ConcreteCompilerType* type) {
} }
void addRTFunction(CLFunction* cl_f, void* f, ConcreteCompilerType* rtn_type, void addRTFunction(CLFunction* cl_f, void* f, ConcreteCompilerType* rtn_type,
const std::vector<ConcreteCompilerType*>& arg_types, const std::vector<ConcreteCompilerType*>& arg_types, ExceptionStyle exception_style) {
ExceptionStyle::ExceptionStyle exception_style) {
assert(arg_types.size() == cl_f->numReceivedArgs()); assert(arg_types.size() == cl_f->numReceivedArgs());
#ifndef NDEBUG #ifndef NDEBUG
for (ConcreteCompilerType* t : arg_types) for (ConcreteCompilerType* t : arg_types)
......
...@@ -68,12 +68,10 @@ enum class EffortLevel { ...@@ -68,12 +68,10 @@ enum class EffortLevel {
MAXIMAL = 3, MAXIMAL = 3,
}; };
namespace ExceptionStyle {
enum ExceptionStyle { enum ExceptionStyle {
CAPI, CAPI,
CXX, CXX,
}; };
};
template <typename R, typename... Args> struct ExceptionSwitchableFunction { template <typename R, typename... Args> struct ExceptionSwitchableFunction {
public: public:
...@@ -83,13 +81,13 @@ public: ...@@ -83,13 +81,13 @@ public:
ExceptionSwitchableFunction(FTy capi_ptr, FTy cxx_ptr) : capi_ptr(capi_ptr), cxx_ptr(cxx_ptr) {} ExceptionSwitchableFunction(FTy capi_ptr, FTy cxx_ptr) : capi_ptr(capi_ptr), cxx_ptr(cxx_ptr) {}
template <ExceptionStyle::ExceptionStyle S> FTy get() { template <ExceptionStyle S> FTy get() {
if (S == ExceptionStyle::CAPI) if (S == CAPI)
return capi_ptr; return capi_ptr;
else else
return cxx_ptr; return cxx_ptr;
} }
template <ExceptionStyle::ExceptionStyle S> R call(Args... args) noexcept(S == ExceptionStyle::CAPI) { template <ExceptionStyle S> R call(Args... args) noexcept(S == ExceptionStyle::CAPI) {
return get()(args...); return get()(args...);
} }
}; };
...@@ -283,7 +281,7 @@ public: ...@@ -283,7 +281,7 @@ public:
int code_size; int code_size;
EffortLevel effort; EffortLevel effort;
ExceptionStyle::ExceptionStyle exception_style; ExceptionStyle exception_style;
int64_t times_called, times_speculation_failed; int64_t times_called, times_speculation_failed;
ICInvalidator dependent_callsites; ICInvalidator dependent_callsites;
...@@ -293,7 +291,7 @@ public: ...@@ -293,7 +291,7 @@ public:
std::vector<ICInfo*> ics; std::vector<ICInfo*> ics;
CompiledFunction(llvm::Function* func, FunctionSpecialization* spec, void* code, EffortLevel effort, CompiledFunction(llvm::Function* func, FunctionSpecialization* spec, void* code, EffortLevel effort,
ExceptionStyle::ExceptionStyle exception_style, const OSREntryDescriptor* entry_descriptor); ExceptionStyle exception_style, const OSREntryDescriptor* entry_descriptor);
ConcreteCompilerType* getReturnType(); ConcreteCompilerType* getReturnType();
...@@ -414,15 +412,12 @@ CLFunction* createRTFunction(int num_args, int num_defaults, bool takes_varargs, ...@@ -414,15 +412,12 @@ CLFunction* createRTFunction(int num_args, int num_defaults, bool takes_varargs,
const ParamNames& param_names = ParamNames::empty()); const ParamNames& param_names = ParamNames::empty());
CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int nargs, int num_defaults, bool takes_varargs, CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int nargs, int num_defaults, bool takes_varargs,
bool takes_kwargs, const ParamNames& param_names = ParamNames::empty(), bool takes_kwargs, const ParamNames& param_names = ParamNames::empty(),
ExceptionStyle::ExceptionStyle exception_style = ExceptionStyle::CXX); ExceptionStyle exception_style = CXX);
CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int nargs, CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int nargs,
const ParamNames& param_names = ParamNames::empty(), const ParamNames& param_names = ParamNames::empty(), ExceptionStyle exception_style = CXX);
ExceptionStyle::ExceptionStyle exception_style = ExceptionStyle::CXX); void addRTFunction(CLFunction* cf, void* f, ConcreteCompilerType* rtn_type, ExceptionStyle exception_style = CXX);
void addRTFunction(CLFunction* cf, void* f, ConcreteCompilerType* rtn_type,
ExceptionStyle::ExceptionStyle exception_style = ExceptionStyle::CXX);
void addRTFunction(CLFunction* cf, void* f, ConcreteCompilerType* rtn_type, void addRTFunction(CLFunction* cf, void* f, ConcreteCompilerType* rtn_type,
const std::vector<ConcreteCompilerType*>& arg_types, const std::vector<ConcreteCompilerType*>& arg_types, ExceptionStyle exception_style = CXX);
ExceptionStyle::ExceptionStyle exception_style = ExceptionStyle::CXX);
CLFunction* unboxRTFunction(Box*); CLFunction* unboxRTFunction(Box*);
// Compiles a new version of the function with the given signature and adds it to the list; // Compiles a new version of the function with the given signature and adds it to the list;
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
namespace pyston { namespace pyston {
using namespace pyston::ExceptionStyle;
using pyston::ExceptionStyle::ExceptionStyle;
Box* dictRepr(BoxedDict* self) { Box* dictRepr(BoxedDict* self) {
std::vector<char> chars; std::vector<char> chars;
chars.push_back('{'); chars.push_back('{');
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
namespace pyston { namespace pyston {
using namespace pyston::ExceptionStyle;
using pyston::ExceptionStyle::ExceptionStyle;
BoxedListIterator::BoxedListIterator(BoxedList* l, int start) : l(l), pos(start) { BoxedListIterator::BoxedListIterator(BoxedList* l, int start) : l(l), pos(start) {
} }
...@@ -68,7 +65,7 @@ i1 listiterHasnextUnboxed(Box* s) { ...@@ -68,7 +65,7 @@ i1 listiterHasnextUnboxed(Box* s) {
return ans; return ans;
} }
template <enum ExceptionStyle S> Box* listiterNext(Box* s) noexcept(S == CAPI) { template <ExceptionStyle S> Box* listiterNext(Box* s) noexcept(S == CAPI) {
assert(s->cls == list_iterator_cls); assert(s->cls == list_iterator_cls);
BoxedListIterator* self = static_cast<BoxedListIterator*>(s); BoxedListIterator* self = static_cast<BoxedListIterator*>(s);
......
...@@ -704,7 +704,7 @@ private: ...@@ -704,7 +704,7 @@ private:
public: public:
PyCmpComparer(Box* cmp) : cmp(cmp) {} PyCmpComparer(Box* cmp) : cmp(cmp) {}
bool operator()(Box* lhs, Box* rhs) { bool operator()(Box* lhs, Box* rhs) {
Box* r = runtimeCallInternal<ExceptionStyle::CXX>(cmp, NULL, ArgPassSpec(2), lhs, rhs, NULL, NULL, NULL); Box* r = runtimeCallInternal<CXX>(cmp, NULL, ArgPassSpec(2), lhs, rhs, NULL, NULL, NULL);
if (!isSubclass(r->cls, int_cls)) if (!isSubclass(r->cls, int_cls))
raiseExcHelper(TypeError, "comparison function must return int, not %.200s", r->cls->tp_name); raiseExcHelper(TypeError, "comparison function must return int, not %.200s", r->cls->tp_name);
return static_cast<BoxedInt*>(r)->n < 0; return static_cast<BoxedInt*>(r)->n < 0;
...@@ -1170,8 +1170,8 @@ void setupList() { ...@@ -1170,8 +1170,8 @@ void setupList() {
list_iterator_cls->giveAttr( list_iterator_cls->giveAttr(
"__iter__", new BoxedFunction(boxRTFunction((void*)listIterIter, typeFromClass(list_iterator_cls), 1))); "__iter__", new BoxedFunction(boxRTFunction((void*)listIterIter, typeFromClass(list_iterator_cls), 1)));
CLFunction* listiter_next = boxRTFunction((void*)listiterNext<ExceptionStyle::CXX>, UNKNOWN, 1); CLFunction* listiter_next = boxRTFunction((void*)listiterNext<CXX>, UNKNOWN, 1);
addRTFunction(listiter_next, (void*)listiterNext<ExceptionStyle::CAPI>, UNKNOWN, ExceptionStyle::CAPI); addRTFunction(listiter_next, (void*)listiterNext<CAPI>, UNKNOWN, CAPI);
list_iterator_cls->giveAttr("next", new BoxedFunction(listiter_next)); list_iterator_cls->giveAttr("next", new BoxedFunction(listiter_next));
list_iterator_cls->freeze(); list_iterator_cls->freeze();
......
...@@ -35,7 +35,7 @@ Box* listIter(Box* self); ...@@ -35,7 +35,7 @@ Box* listIter(Box* self);
Box* listIterIter(Box* self); Box* listIterIter(Box* self);
Box* listiterHasnext(Box* self); Box* listiterHasnext(Box* self);
i1 listiterHasnextUnboxed(Box* self); i1 listiterHasnextUnboxed(Box* self);
template <ExceptionStyle::ExceptionStyle S> Box* listiterNext(Box* self) noexcept(S == ExceptionStyle::CAPI); template <ExceptionStyle S> Box* listiterNext(Box* self) noexcept(S == CAPI);
Box* listReversed(Box* self); Box* listReversed(Box* self);
Box* listreviterHasnext(Box* self); Box* listreviterHasnext(Box* self);
i1 listreviterHasnextUnboxed(Box* self); i1 listreviterHasnextUnboxed(Box* self);
......
...@@ -60,9 +60,6 @@ ...@@ -60,9 +60,6 @@
namespace pyston { namespace pyston {
using namespace pyston::ExceptionStyle;
using pyston::ExceptionStyle::ExceptionStyle;
static const std::string iter_str("__iter__"); static const std::string iter_str("__iter__");
static const std::string new_str("__new__"); static const std::string new_str("__new__");
static const std::string none_str("None"); static const std::string none_str("None");
...@@ -76,20 +73,20 @@ void REWRITE_ABORTED(const char* reason) { ...@@ -76,20 +73,20 @@ void REWRITE_ABORTED(const char* reason) {
#define REWRITE_ABORTED(reason) ((void)(reason)) #define REWRITE_ABORTED(reason) ((void)(reason))
#endif #endif
template <enum ExceptionStyle S> template <ExceptionStyle S>
static inline Box* runtimeCallInternal0(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec) { static inline Box* runtimeCallInternal0(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec) {
return runtimeCallInternal<S>(obj, rewrite_args, argspec, NULL, NULL, NULL, NULL, NULL); return runtimeCallInternal<S>(obj, rewrite_args, argspec, NULL, NULL, NULL, NULL, NULL);
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
static inline Box* runtimeCallInternal1(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1) { static inline Box* runtimeCallInternal1(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1) {
return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, NULL, NULL, NULL, NULL); return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, NULL, NULL, NULL, NULL);
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
static inline Box* runtimeCallInternal2(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, static inline Box* runtimeCallInternal2(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1,
Box* arg2) { Box* arg2) {
return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, arg2, NULL, NULL, NULL); return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, arg2, NULL, NULL, NULL);
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
static inline Box* runtimeCallInternal3(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, static inline Box* runtimeCallInternal3(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1,
Box* arg2, Box* arg3) { Box* arg2, Box* arg3) {
return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, arg2, arg3, NULL, NULL); return runtimeCallInternal<S>(obj, rewrite_args, argspec, arg1, arg2, arg3, NULL, NULL);
...@@ -1342,9 +1339,9 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedS ...@@ -1342,9 +1339,9 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedS
return NULL; return NULL;
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_args, bool cls_only, bool for_call, Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_args, bool cls_only, bool for_call,
Box** bind_obj_out, RewriterVar** r_bind_obj_out) noexcept(S == ExceptionStyle::CAPI) { Box** bind_obj_out, RewriterVar** r_bind_obj_out) noexcept(S == CAPI) {
assert(gc::isValidGCObject(attr)); assert(gc::isValidGCObject(attr));
if (S == CAPI) { if (S == CAPI) {
...@@ -1848,9 +1845,8 @@ Box* getattrInternalGeneric(Box* obj, BoxedString* attr, GetattrRewriteArgs* rew ...@@ -1848,9 +1845,8 @@ Box* getattrInternalGeneric(Box* obj, BoxedString* attr, GetattrRewriteArgs* rew
return NULL; return NULL;
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* getattrInternal(Box* obj, BoxedString* attr, Box* getattrInternal(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_args) noexcept(S == CAPI) {
GetattrRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI) {
return getattrInternalEx<S>(obj, attr, rewrite_args, return getattrInternalEx<S>(obj, attr, rewrite_args,
/* cls_only */ false, /* cls_only */ false,
/* for_call */ false, NULL, NULL); /* for_call */ false, NULL, NULL);
...@@ -2458,8 +2454,7 @@ extern "C" BoxedInt* hash(Box* obj) { ...@@ -2458,8 +2454,7 @@ extern "C" BoxedInt* hash(Box* obj) {
return new BoxedInt(r); return new BoxedInt(r);
} }
template <enum ExceptionStyle S> template <ExceptionStyle S> BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI) {
BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI) {
static BoxedString* len_str = internStringImmortal("__len__"); static BoxedString* len_str = internStringImmortal("__len__");
if (S == CAPI) { if (S == CAPI) {
...@@ -2793,7 +2788,7 @@ static inline RewriterVar* getArg(int idx, CallRewriteArgs* rewrite_args) { ...@@ -2793,7 +2788,7 @@ static inline RewriterVar* getArg(int idx, CallRewriteArgs* rewrite_args) {
} }
static StatCounter slowpath_pickversion("slowpath_pickversion"); static StatCounter slowpath_pickversion("slowpath_pickversion");
static CompiledFunction* pickVersion(CLFunction* f, enum ExceptionStyle S, int num_output_args, Box* oarg1, Box* oarg2, static CompiledFunction* pickVersion(CLFunction* f, ExceptionStyle S, int num_output_args, Box* oarg1, Box* oarg2,
Box* oarg3, Box** oargs) { Box* oarg3, Box** oargs) {
LOCK_REGION(codegen_rwlock.asWrite()); LOCK_REGION(codegen_rwlock.asWrite());
...@@ -3256,7 +3251,7 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name ...@@ -3256,7 +3251,7 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
} }
static StatCounter slowpath_callfunc("slowpath_callfunc"); static StatCounter slowpath_callfunc("slowpath_callfunc");
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2,
Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI) { Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI) {
#if STAT_TIMERS #if STAT_TIMERS
...@@ -3389,7 +3384,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe ...@@ -3389,7 +3384,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
return res; return res;
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
static Box* callChosenCF(CompiledFunction* chosen_cf, BoxedClosure* closure, BoxedGenerator* generator, Box* oarg1, static Box* callChosenCF(CompiledFunction* chosen_cf, BoxedClosure* closure, BoxedGenerator* generator, Box* oarg1,
Box* oarg2, Box* oarg3, Box** oargs) noexcept(S == CAPI) { Box* oarg2, Box* oarg3, Box** oargs) noexcept(S == CAPI) {
if (S != chosen_cf->exception_style) { if (S != chosen_cf->exception_style) {
...@@ -3431,7 +3426,7 @@ static Box* astInterpretHelper(CLFunction* f, int num_args, BoxedClosure* closur ...@@ -3431,7 +3426,7 @@ static Box* astInterpretHelper(CLFunction* f, int num_args, BoxedClosure* closur
return astInterpretFunction(f, num_args, closure, generator, globals, arg1, arg2, arg3, (Box**)args); return astInterpretFunction(f, num_args, closure, generator, globals, arg1, arg2, arg3, (Box**)args);
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure, Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure,
BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3, BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3,
Box** oargs) noexcept(S == CAPI) { Box** oargs) noexcept(S == CAPI) {
...@@ -3543,7 +3538,7 @@ template Box* callCLFunc<CAPI>(CLFunction* f, CallRewriteArgs* rewrite_args, int ...@@ -3543,7 +3538,7 @@ template Box* callCLFunc<CAPI>(CLFunction* f, CallRewriteArgs* rewrite_args, int
template Box* callCLFunc<CXX>(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure, template Box* callCLFunc<CXX>(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure,
BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3, Box** oargs); BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3, Box** oargs);
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3, Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3,
Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI) { Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI) {
int npassed_args = argspec.totalPassed(); int npassed_args = argspec.totalPassed();
...@@ -4416,8 +4411,8 @@ Box* callItemOrSliceAttr(Box* target, BoxedString* item_str, BoxedString* slice_ ...@@ -4416,8 +4411,8 @@ Box* callItemOrSliceAttr(Box* target, BoxedString* item_str, BoxedString* slice_
} }
} }
template <enum ExceptionStyle S> template <ExceptionStyle S>
Box* getitemInternal(Box* target, Box* slice, GetitemRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI) { Box* getitemInternal(Box* target, Box* slice, GetitemRewriteArgs* rewrite_args) noexcept(S == CAPI) {
if (S == CAPI) { if (S == CAPI) {
assert(!rewrite_args && "implement me"); assert(!rewrite_args && "implement me");
rewrite_args = NULL; rewrite_args = NULL;
......
...@@ -107,25 +107,22 @@ struct BinopRewriteArgs; ...@@ -107,25 +107,22 @@ struct BinopRewriteArgs;
extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, BinopRewriteArgs* rewrite_args); extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, BinopRewriteArgs* rewrite_args);
struct CallRewriteArgs; struct CallRewriteArgs;
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S>
Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3, Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3,
Box** args, Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI);
const std::vector<BoxedString*>* keyword_names) noexcept(S == ExceptionStyle::CAPI);
struct GetitemRewriteArgs; struct GetitemRewriteArgs;
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S>
Box* getitemInternal(Box* target, Box* slice, GetitemRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI); Box* getitemInternal(Box* target, Box* slice, GetitemRewriteArgs* rewrite_args) noexcept(S == CAPI);
struct LenRewriteArgs; struct LenRewriteArgs;
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S> BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == CAPI);
BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI);
Box* lenCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* lenCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2,
Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names); Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names);
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S>
Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2,
Box* arg3, Box** args, Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI);
const std::vector<BoxedString*>* keyword_names) noexcept(S == ExceptionStyle::CAPI);
enum LookupScope { enum LookupScope {
CLASS_ONLY = 1, CLASS_ONLY = 1,
...@@ -141,8 +138,8 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -141,8 +138,8 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
// This is the equivalent of PyObject_GetAttr. Unlike getattrInternalGeneric, it checks for custom __getattr__ or // This is the equivalent of PyObject_GetAttr. Unlike getattrInternalGeneric, it checks for custom __getattr__ or
// __getattribute__ methods. // __getattribute__ methods.
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S>
Box* getattrInternal(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_args) noexcept(S == ExceptionStyle::CAPI); Box* getattrInternal(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_args) noexcept(S == CAPI);
// This is the equivalent of PyObject_GenericGetAttr, which performs the default lookup rules for getattr() (check for // This is the equivalent of PyObject_GenericGetAttr, which performs the default lookup rules for getattr() (check for
// data descriptor, check for instance attribute, check for non-data descriptor). It does not check for __getattr__ or // data descriptor, check for instance attribute, check for non-data descriptor). It does not check for __getattr__ or
...@@ -168,10 +165,10 @@ Box* typeNew(Box* cls, Box* arg1, Box* arg2, Box** _args); ...@@ -168,10 +165,10 @@ Box* typeNew(Box* cls, Box* arg1, Box* arg2, Box** _args);
Box* processDescriptor(Box* obj, Box* inst, Box* owner); Box* processDescriptor(Box* obj, Box* inst, Box* owner);
Box* processDescriptorOrNull(Box* obj, Box* inst, Box* owner); Box* processDescriptorOrNull(Box* obj, Box* inst, Box* owner);
template <ExceptionStyle::ExceptionStyle S> template <ExceptionStyle S>
Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure, Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_args, BoxedClosure* closure,
BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3, BoxedGenerator* generator, Box* globals, Box* oarg1, Box* oarg2, Box* oarg3,
Box** oargs) noexcept(S == ExceptionStyle::CAPI); Box** oargs) noexcept(S == CAPI);
static const char* objectNewParameterTypeErrorMsg() { static const char* objectNewParameterTypeErrorMsg() {
if (PYTHON_VERSION_HEX >= version_hex(2, 7, 4)) { if (PYTHON_VERSION_HEX >= version_hex(2, 7, 4)) {
......
...@@ -639,7 +639,7 @@ static Box* typeCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args ...@@ -639,7 +639,7 @@ static Box* typeCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args
if (argspec.has_starargs || argspec.num_args == 0) { if (argspec.has_starargs || argspec.num_args == 0) {
// Get callFunc to expand the arguments. // Get callFunc to expand the arguments.
// TODO: update this to use rearrangeArguments instead. // TODO: update this to use rearrangeArguments instead.
return callFunc<ExceptionStyle::CXX>(f, rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names); return callFunc<CXX>(f, rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names);
} }
return typeCallInner(rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names); return typeCallInner(rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names);
...@@ -997,8 +997,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -997,8 +997,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if (new_npassed_args >= 4) if (new_npassed_args >= 4)
srewrite_args.args = rewrite_args->args; srewrite_args.args = rewrite_args->args;
made = runtimeCallInternal<ExceptionStyle::CXX>(new_attr, &srewrite_args, new_argspec, cls, arg2, arg3, made
args, keyword_names); = runtimeCallInternal<CXX>(new_attr, &srewrite_args, new_argspec, cls, arg2, arg3, args, keyword_names);
if (!srewrite_args.out_success) { if (!srewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1015,8 +1015,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1015,8 +1015,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if (cls->tp_new == object_cls->tp_new && cls->tp_init != object_cls->tp_init) if (cls->tp_new == object_cls->tp_new && cls->tp_init != object_cls->tp_init)
made = objectNewNoArgs(cls); made = objectNewNoArgs(cls);
else else
made = runtimeCallInternal<ExceptionStyle::CXX>(new_attr, NULL, new_argspec, cls, arg2, arg3, args, made = runtimeCallInternal<CXX>(new_attr, NULL, new_argspec, cls, arg2, arg3, args, keyword_names);
keyword_names);
} }
assert(made); assert(made);
...@@ -1066,8 +1065,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1066,8 +1065,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
// initrtn = callattrInternal(cls, _init_str, INST_ONLY, &srewrite_args, argspec, made, arg2, arg3, args, // initrtn = callattrInternal(cls, _init_str, INST_ONLY, &srewrite_args, argspec, made, arg2, arg3, args,
// keyword_names); // keyword_names);
initrtn = runtimeCallInternal<ExceptionStyle::CXX>(init_attr, &srewrite_args, argspec, made, arg2, arg3, initrtn
args, keyword_names); = runtimeCallInternal<CXX>(init_attr, &srewrite_args, argspec, made, arg2, arg3, args, keyword_names);
if (!srewrite_args.out_success) { if (!srewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1086,11 +1085,11 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1086,11 +1085,11 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
// If we weren't passed the args array, it's not safe to index into it // If we weren't passed the args array, it's not safe to index into it
if (passed <= 2) if (passed <= 2)
initrtn = runtimeCallInternal<ExceptionStyle::CXX>(init_attr, NULL, init_argspec, arg2, arg3, NULL, initrtn
NULL, keyword_names); = runtimeCallInternal<CXX>(init_attr, NULL, init_argspec, arg2, arg3, NULL, NULL, keyword_names);
else else
initrtn = runtimeCallInternal<ExceptionStyle::CXX>(init_attr, NULL, init_argspec, arg2, arg3, args[0], initrtn = runtimeCallInternal<CXX>(init_attr, NULL, init_argspec, arg2, arg3, args[0], &args[1],
&args[1], keyword_names); keyword_names);
} }
assertInitNone(initrtn); assertInitNone(initrtn);
} else { } else {
...@@ -1659,7 +1658,7 @@ static Box* instancemethodRepr(Box* b) { ...@@ -1659,7 +1658,7 @@ static Box* instancemethodRepr(Box* b) {
const char* sfuncname = "?", * sklassname = "?"; const char* sfuncname = "?", * sklassname = "?";
static BoxedString* name_str = internStringImmortal("__name__"); static BoxedString* name_str = internStringImmortal("__name__");
funcname = getattrInternal<ExceptionStyle::CXX>(func, name_str, NULL); funcname = getattrInternal<CXX>(func, name_str, NULL);
if (funcname != NULL) { if (funcname != NULL) {
if (!PyString_Check(funcname)) { if (!PyString_Check(funcname)) {
...@@ -1671,7 +1670,7 @@ static Box* instancemethodRepr(Box* b) { ...@@ -1671,7 +1670,7 @@ static Box* instancemethodRepr(Box* b) {
if (klass == NULL) { if (klass == NULL) {
klassname = NULL; klassname = NULL;
} else { } else {
klassname = getattrInternal<ExceptionStyle::CXX>(klass, name_str, NULL); klassname = getattrInternal<CXX>(klass, name_str, NULL);
if (klassname != NULL) { if (klassname != NULL) {
if (!PyString_Check(klassname)) { if (!PyString_Check(klassname)) {
klassname = NULL; klassname = NULL;
......
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