Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
69880e2e
Commit
69880e2e
authored
Jul 28, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: remove extra ExceptionStyle namespace
parent
7405db05
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
82 deletions
+58
-82
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+5
-9
src/core/types.h
src/core/types.h
+9
-14
src/runtime/dict.cpp
src/runtime/dict.cpp
+0
-3
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+1
-4
src/runtime/list.cpp
src/runtime/list.cpp
+3
-3
src/runtime/list.h
src/runtime/list.h
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+16
-21
src/runtime/objmodel.h
src/runtime/objmodel.h
+11
-14
src/runtime/types.cpp
src/runtime/types.cpp
+12
-13
No files found.
src/codegen/irgen/hooks.cpp
View file @
69880e2e
...
...
@@ -716,8 +716,7 @@ void CompiledFunction::speculationFailed() {
}
CompiledFunction
::
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
)
:
clfunc
(
NULL
),
func
(
func
),
spec
(
spec
),
...
...
@@ -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
,
ExceptionStyle
::
ExceptionStyle
exception_style
)
{
ExceptionStyle
exception_style
)
{
assert
(
!
param_names
.
takes_param_names
||
num_args
==
param_names
.
args
.
size
());
assert
(
param_names
.
vararg
.
str
()
==
""
);
assert
(
param_names
.
kwarg
.
str
()
==
""
);
...
...
@@ -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
,
bool
takes_kwargs
,
const
ParamNames
&
param_names
,
ExceptionStyle
::
ExceptionStyle
exception_style
)
{
bool
takes_kwargs
,
const
ParamNames
&
param_names
,
ExceptionStyle
exception_style
)
{
assert
(
!
param_names
.
takes_param_names
||
num_args
==
param_names
.
args
.
size
());
assert
(
takes_varargs
||
param_names
.
vararg
.
str
()
==
""
);
assert
(
takes_kwargs
||
param_names
.
kwarg
.
str
()
==
""
);
...
...
@@ -855,8 +853,7 @@ CLFunction* boxRTFunction(void* f, ConcreteCompilerType* rtn_type, int num_args,
return
cl_f
;
}
void
addRTFunction
(
CLFunction
*
cl_f
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
ExceptionStyle
::
ExceptionStyle
exception_style
)
{
void
addRTFunction
(
CLFunction
*
cl_f
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
ExceptionStyle
exception_style
)
{
std
::
vector
<
ConcreteCompilerType
*>
arg_types
(
cl_f
->
numReceivedArgs
(),
UNKNOWN
);
return
addRTFunction
(
cl_f
,
f
,
rtn_type
,
arg_types
,
exception_style
);
}
...
...
@@ -867,8 +864,7 @@ static ConcreteCompilerType* processType(ConcreteCompilerType* type) {
}
void
addRTFunction
(
CLFunction
*
cl_f
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
ExceptionStyle
::
ExceptionStyle
exception_style
)
{
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
ExceptionStyle
exception_style
)
{
assert
(
arg_types
.
size
()
==
cl_f
->
numReceivedArgs
());
#ifndef NDEBUG
for
(
ConcreteCompilerType
*
t
:
arg_types
)
...
...
src/core/types.h
View file @
69880e2e
...
...
@@ -68,12 +68,10 @@ enum class EffortLevel {
MAXIMAL
=
3
,
};
namespace
ExceptionStyle
{
enum
ExceptionStyle
{
CAPI
,
CXX
,
};
};
template
<
typename
R
,
typename
...
Args
>
struct
ExceptionSwitchableFunction
{
public:
...
...
@@ -83,13 +81,13 @@ public:
ExceptionSwitchableFunction
(
FTy
capi_ptr
,
FTy
cxx_ptr
)
:
capi_ptr
(
capi_ptr
),
cxx_ptr
(
cxx_ptr
)
{}
template
<
ExceptionStyle
::
ExceptionStyle
S
>
FTy
get
()
{
if
(
S
==
ExceptionStyle
::
CAPI
)
template
<
ExceptionStyle
S
>
FTy
get
()
{
if
(
S
==
CAPI
)
return
capi_ptr
;
else
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
...);
}
};
...
...
@@ -283,7 +281,7 @@ public:
int
code_size
;
EffortLevel
effort
;
ExceptionStyle
::
ExceptionStyle
exception_style
;
ExceptionStyle
exception_style
;
int64_t
times_called
,
times_speculation_failed
;
ICInvalidator
dependent_callsites
;
...
...
@@ -293,7 +291,7 @@ public:
std
::
vector
<
ICInfo
*>
ics
;
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
();
...
...
@@ -414,15 +412,12 @@ CLFunction* createRTFunction(int num_args, int num_defaults, bool takes_varargs,
const
ParamNames
&
param_names
=
ParamNames
::
empty
());
CLFunction
*
boxRTFunction
(
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
int
nargs
,
int
num_defaults
,
bool
takes_varargs
,
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
,
const
ParamNames
&
param_names
=
ParamNames
::
empty
(),
ExceptionStyle
::
ExceptionStyle
exception_style
=
ExceptionStyle
::
CXX
);
void
addRTFunction
(
CLFunction
*
cf
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
ExceptionStyle
::
ExceptionStyle
exception_style
=
ExceptionStyle
::
CXX
);
const
ParamNames
&
param_names
=
ParamNames
::
empty
(),
ExceptionStyle
exception_style
=
CXX
);
void
addRTFunction
(
CLFunction
*
cf
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
ExceptionStyle
exception_style
=
CXX
);
void
addRTFunction
(
CLFunction
*
cf
,
void
*
f
,
ConcreteCompilerType
*
rtn_type
,
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
ExceptionStyle
::
ExceptionStyle
exception_style
=
ExceptionStyle
::
CXX
);
const
std
::
vector
<
ConcreteCompilerType
*>&
arg_types
,
ExceptionStyle
exception_style
=
CXX
);
CLFunction
*
unboxRTFunction
(
Box
*
);
// Compiles a new version of the function with the given signature and adds it to the list;
...
...
src/runtime/dict.cpp
View file @
69880e2e
...
...
@@ -27,9 +27,6 @@
namespace
pyston
{
using
namespace
pyston
::
ExceptionStyle
;
using
pyston
::
ExceptionStyle
::
ExceptionStyle
;
Box
*
dictRepr
(
BoxedDict
*
self
)
{
std
::
vector
<
char
>
chars
;
chars
.
push_back
(
'{'
);
...
...
src/runtime/inline/list.cpp
View file @
69880e2e
...
...
@@ -22,9 +22,6 @@
namespace
pyston
{
using
namespace
pyston
::
ExceptionStyle
;
using
pyston
::
ExceptionStyle
::
ExceptionStyle
;
BoxedListIterator
::
BoxedListIterator
(
BoxedList
*
l
,
int
start
)
:
l
(
l
),
pos
(
start
)
{
}
...
...
@@ -68,7 +65,7 @@ i1 listiterHasnextUnboxed(Box* s) {
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
);
BoxedListIterator
*
self
=
static_cast
<
BoxedListIterator
*>
(
s
);
...
...
src/runtime/list.cpp
View file @
69880e2e
...
...
@@ -704,7 +704,7 @@ private:
public:
PyCmpComparer
(
Box
*
cmp
)
:
cmp
(
cmp
)
{}
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
))
raiseExcHelper
(
TypeError
,
"comparison function must return int, not %.200s"
,
r
->
cls
->
tp_name
);
return
static_cast
<
BoxedInt
*>
(
r
)
->
n
<
0
;
...
...
@@ -1170,8 +1170,8 @@ void setupList() {
list_iterator_cls
->
giveAttr
(
"__iter__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
listIterIter
,
typeFromClass
(
list_iterator_cls
),
1
)));
CLFunction
*
listiter_next
=
boxRTFunction
((
void
*
)
listiterNext
<
ExceptionStyle
::
CXX
>
,
UNKNOWN
,
1
);
addRTFunction
(
listiter_next
,
(
void
*
)
listiterNext
<
ExceptionStyle
::
CAPI
>
,
UNKNOWN
,
ExceptionStyle
::
CAPI
);
CLFunction
*
listiter_next
=
boxRTFunction
((
void
*
)
listiterNext
<
CXX
>
,
UNKNOWN
,
1
);
addRTFunction
(
listiter_next
,
(
void
*
)
listiterNext
<
CAPI
>
,
UNKNOWN
,
CAPI
);
list_iterator_cls
->
giveAttr
(
"next"
,
new
BoxedFunction
(
listiter_next
));
list_iterator_cls
->
freeze
();
...
...
src/runtime/list.h
View file @
69880e2e
...
...
@@ -35,7 +35,7 @@ Box* listIter(Box* self);
Box
*
listIterIter
(
Box
*
self
);
Box
*
listiterHasnext
(
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
*
listreviterHasnext
(
Box
*
self
);
i1
listreviterHasnextUnboxed
(
Box
*
self
);
...
...
src/runtime/objmodel.cpp
View file @
69880e2e
...
...
@@ -60,9 +60,6 @@
namespace
pyston
{
using
namespace
pyston
::
ExceptionStyle
;
using
pyston
::
ExceptionStyle
::
ExceptionStyle
;
static
const
std
::
string
iter_str
(
"__iter__"
);
static
const
std
::
string
new_str
(
"__new__"
);
static
const
std
::
string
none_str
(
"None"
);
...
...
@@ -76,20 +73,20 @@ void REWRITE_ABORTED(const char* reason) {
#define REWRITE_ABORTED(reason) ((void)(reason))
#endif
template
<
enum
ExceptionStyle
S
>
template
<
ExceptionStyle
S
>
static
inline
Box
*
runtimeCallInternal0
(
Box
*
obj
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
)
{
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
)
{
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
,
Box
*
arg2
)
{
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
,
Box
*
arg2
,
Box
*
arg3
)
{
return
runtimeCallInternal
<
S
>
(
obj
,
rewrite_args
,
argspec
,
arg1
,
arg2
,
arg3
,
NULL
,
NULL
);
...
...
@@ -1342,9 +1339,9 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedS
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
**
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
));
if
(
S
==
CAPI
)
{
...
...
@@ -1848,9 +1845,8 @@ Box* getattrInternalGeneric(Box* obj, BoxedString* attr, GetattrRewriteArgs* rew
return
NULL
;
}
template
<
enum
ExceptionStyle
S
>
Box
*
getattrInternal
(
Box
*
obj
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
)
{
template
<
ExceptionStyle
S
>
Box
*
getattrInternal
(
Box
*
obj
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
)
{
return
getattrInternalEx
<
S
>
(
obj
,
attr
,
rewrite_args
,
/* cls_only */
false
,
/* for_call */
false
,
NULL
,
NULL
);
...
...
@@ -2458,8 +2454,7 @@ extern "C" BoxedInt* hash(Box* obj) {
return
new
BoxedInt
(
r
);
}
template
<
enum
ExceptionStyle
S
>
BoxedInt
*
lenInternal
(
Box
*
obj
,
LenRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
)
{
template
<
ExceptionStyle
S
>
BoxedInt
*
lenInternal
(
Box
*
obj
,
LenRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
)
{
static
BoxedString
*
len_str
=
internStringImmortal
(
"__len__"
);
if
(
S
==
CAPI
)
{
...
...
@@ -2793,7 +2788,7 @@ static inline RewriterVar* getArg(int idx, CallRewriteArgs* rewrite_args) {
}
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
)
{
LOCK_REGION
(
codegen_rwlock
.
asWrite
());
...
...
@@ -3256,7 +3251,7 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
}
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
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
#if STAT_TIMERS
...
...
@@ -3389,7 +3384,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
return
res
;
}
template
<
enum
ExceptionStyle
S
>
template
<
ExceptionStyle
S
>
static
Box
*
callChosenCF
(
CompiledFunction
*
chosen_cf
,
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
oarg1
,
Box
*
oarg2
,
Box
*
oarg3
,
Box
**
oargs
)
noexcept
(
S
==
CAPI
)
{
if
(
S
!=
chosen_cf
->
exception_style
)
{
...
...
@@ -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
);
}
template
<
enum
ExceptionStyle
S
>
template
<
ExceptionStyle
S
>
Box
*
callCLFunc
(
CLFunction
*
f
,
CallRewriteArgs
*
rewrite_args
,
int
num_output_args
,
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
globals
,
Box
*
oarg1
,
Box
*
oarg2
,
Box
*
oarg3
,
Box
**
oargs
)
noexcept
(
S
==
CAPI
)
{
...
...
@@ -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
,
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
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
int
npassed_args
=
argspec
.
totalPassed
();
...
...
@@ -4416,8 +4411,8 @@ Box* callItemOrSliceAttr(Box* target, BoxedString* item_str, BoxedString* slice_
}
}
template
<
enum
ExceptionStyle
S
>
Box
*
getitemInternal
(
Box
*
target
,
Box
*
slice
,
GetitemRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
)
{
template
<
ExceptionStyle
S
>
Box
*
getitemInternal
(
Box
*
target
,
Box
*
slice
,
GetitemRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
)
{
if
(
S
==
CAPI
)
{
assert
(
!
rewrite_args
&&
"implement me"
);
rewrite_args
=
NULL
;
...
...
src/runtime/objmodel.h
View file @
69880e2e
...
...
@@ -107,25 +107,22 @@ struct BinopRewriteArgs;
extern
"C"
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
bool
inplace
,
BinopRewriteArgs
*
rewrite_args
);
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
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
);
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
);
struct
GetitemRewriteArgs
;
template
<
ExceptionStyle
::
ExceptionStyle
S
>
Box
*
getitemInternal
(
Box
*
target
,
Box
*
slice
,
GetitemRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
);
template
<
ExceptionStyle
S
>
Box
*
getitemInternal
(
Box
*
target
,
Box
*
slice
,
GetitemRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
);
struct
LenRewriteArgs
;
template
<
ExceptionStyle
::
ExceptionStyle
S
>
BoxedInt
*
lenInternal
(
Box
*
obj
,
LenRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
);
template
<
ExceptionStyle
S
>
BoxedInt
*
lenInternal
(
Box
*
obj
,
LenRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
);
Box
*
lenCallInternal
(
BoxedFunctionBase
*
f
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
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
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
);
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
);
enum
LookupScope
{
CLASS_ONLY
=
1
,
...
...
@@ -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
// __getattribute__ methods.
template
<
ExceptionStyle
::
ExceptionStyle
S
>
Box
*
getattrInternal
(
Box
*
obj
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
ExceptionStyle
::
CAPI
);
template
<
ExceptionStyle
S
>
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
// 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);
Box
*
processDescriptor
(
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
,
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
()
{
if
(
PYTHON_VERSION_HEX
>=
version_hex
(
2
,
7
,
4
))
{
...
...
src/runtime/types.cpp
View file @
69880e2e
...
...
@@ -639,7 +639,7 @@ static Box* typeCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args
if
(
argspec
.
has_starargs
||
argspec
.
num_args
==
0
)
{
// Get callFunc to expand the arguments.
// 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
);
...
...
@@ -997,8 +997,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if
(
new_npassed_args
>=
4
)
srewrite_args
.
args
=
rewrite_args
->
args
;
made
=
runtimeCallInternal
<
ExceptionStyle
::
CXX
>
(
new_attr
,
&
srewrite_args
,
new_argspec
,
cls
,
arg2
,
arg3
,
args
,
keyword_names
);
made
=
runtimeCallInternal
<
CXX
>
(
new_attr
,
&
srewrite_args
,
new_argspec
,
cls
,
arg2
,
arg3
,
args
,
keyword_names
);
if
(
!
srewrite_args
.
out_success
)
{
rewrite_args
=
NULL
;
...
...
@@ -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
)
made
=
objectNewNoArgs
(
cls
);
else
made
=
runtimeCallInternal
<
ExceptionStyle
::
CXX
>
(
new_attr
,
NULL
,
new_argspec
,
cls
,
arg2
,
arg3
,
args
,
keyword_names
);
made
=
runtimeCallInternal
<
CXX
>
(
new_attr
,
NULL
,
new_argspec
,
cls
,
arg2
,
arg3
,
args
,
keyword_names
);
}
assert
(
made
);
...
...
@@ -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,
// keyword_names);
initrtn
=
runtimeCallInternal
<
ExceptionStyle
::
CXX
>
(
init_attr
,
&
srewrite_args
,
argspec
,
made
,
arg2
,
arg3
,
args
,
keyword_names
);
initrtn
=
runtimeCallInternal
<
CXX
>
(
init_attr
,
&
srewrite_args
,
argspec
,
made
,
arg2
,
arg3
,
args
,
keyword_names
);
if
(
!
srewrite_args
.
out_success
)
{
rewrite_args
=
NULL
;
...
...
@@ -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
(
passed
<=
2
)
initrtn
=
runtimeCallInternal
<
ExceptionStyle
::
CXX
>
(
init_attr
,
NULL
,
init_argspec
,
arg2
,
arg3
,
NULL
,
NULL
,
keyword_names
);
initrtn
=
runtimeCallInternal
<
CXX
>
(
init_attr
,
NULL
,
init_argspec
,
arg2
,
arg3
,
NULL
,
NULL
,
keyword_names
);
else
initrtn
=
runtimeCallInternal
<
ExceptionStyle
::
CXX
>
(
init_attr
,
NULL
,
init_argspec
,
arg2
,
arg3
,
args
[
0
],
&
args
[
1
],
keyword_names
);
initrtn
=
runtimeCallInternal
<
CXX
>
(
init_attr
,
NULL
,
init_argspec
,
arg2
,
arg3
,
args
[
0
],
&
args
[
1
],
keyword_names
);
}
assertInitNone
(
initrtn
);
}
else
{
...
...
@@ -1659,7 +1658,7 @@ static Box* instancemethodRepr(Box* b) {
const
char
*
sfuncname
=
"?"
,
*
sklassname
=
"?"
;
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
(
!
PyString_Check
(
funcname
))
{
...
...
@@ -1671,7 +1670,7 @@ static Box* instancemethodRepr(Box* b) {
if
(
klass
==
NULL
)
{
klassname
=
NULL
;
}
else
{
klassname
=
getattrInternal
<
ExceptionStyle
::
CXX
>
(
klass
,
name_str
,
NULL
);
klassname
=
getattrInternal
<
CXX
>
(
klass
,
name_str
,
NULL
);
if
(
klassname
!=
NULL
)
{
if
(
!
PyString_Check
(
klassname
))
{
klassname
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment