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
ebdaab07
Commit
ebdaab07
authored
Aug 27, 2014
by
Travis Hance
Committed by
Travis Hance
Aug 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
real and imag member descriptors
parent
f1683788
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
0 deletions
+13
-0
src/runtime/complex.cpp
src/runtime/complex.cpp
+4
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+5
-0
src/runtime/types.h
src/runtime/types.h
+1
-0
test/tests/complex.py
test/tests/complex.py
+3
-0
No files found.
src/runtime/complex.cpp
View file @
ebdaab07
...
...
@@ -222,6 +222,10 @@ void setupComplex() {
complex_cls
->
giveAttr
(
"__str__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
complexStr
,
STR
,
1
)));
complex_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
complexRepr
,
STR
,
1
)));
complex_cls
->
giveAttr
(
"real"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
FLOAT
,
offsetof
(
BoxedComplex
,
real
)));
complex_cls
->
giveAttr
(
"imag"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
FLOAT
,
offsetof
(
BoxedComplex
,
imag
)));
complex_cls
->
freeze
();
}
...
...
src/runtime/objmodel.cpp
View file @
ebdaab07
...
...
@@ -842,6 +842,11 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box* o
int
rtn
=
reinterpret_cast
<
int
*>
(
obj
)[
member_desc
->
offset
/
sizeof
(
int
)];
return
boxInt
(
rtn
);
}
case
BoxedMemberDescriptor
:
:
FLOAT
:
{
rewrite_args
=
NULL
;
double
rtn
=
reinterpret_cast
<
double
*>
(
obj
)[
member_desc
->
offset
/
sizeof
(
double
)];
return
boxFloat
(
rtn
);
}
default:
RELEASE_ASSERT
(
0
,
"%d"
,
member_desc
->
type
);
}
...
...
src/runtime/types.h
View file @
ebdaab07
...
...
@@ -346,6 +346,7 @@ public:
BYTE
=
T_BYTE
,
INT
=
T_INT
,
OBJECT
=
T_OBJECT
,
FLOAT
=
T_FLOAT
,
}
type
;
int
offset
;
...
...
test/tests/complex.py
View file @
ebdaab07
...
...
@@ -12,3 +12,6 @@ print 0.5j - 1.5
print
0.5j
*
1.5
print
0.5j
*
1.5
print
0.5j
*
1.5
print
(
0.5j
+
1.5
).
real
print
(
0.5j
+
1.5
).
imag
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