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
36192fb0
Commit
36192fb0
authored
Aug 15, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AttrWrapper.__contains__
parent
85beb314
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
src/Makefile
src/Makefile
+5
-5
src/runtime/types.cpp
src/runtime/types.cpp
+18
-3
No files found.
src/Makefile
View file @
36192fb0
...
...
@@ -268,14 +268,14 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS
:=
stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
STDMODULE
S_SRCS
:=
errnomodule.c shamodule.c md5.c md5module.c
STDMODULE
S_SRCS
:=
$(
addprefix
../lib_python/2.7_Modules/,
$(STDMODULES
_SRCS)
)
STDMODULE
_SRCS
:=
errnomodule.c shamodule.c md5.c md5module.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE
_SRCS
:=
$(
addprefix
../lib_python/2.7_Modules/,
$(STDMODULE
_SRCS)
)
# The stdlib objects have slightly longer dependency chains,
# so put them first in the list:
OBJS
:=
$(STDLIB_OBJS)
$(SRCS:.cpp=.o)
$(STDMODULE
S
_SRCS:.c=.o)
PROFILE_OBJS
:=
$(STDLIB_RELEASE_OBJS)
$(MAIN_SRCS:.cpp=.prof.o)
$(STDLIB_SRCS:.cpp=.release.o)
$(STDMODULE
S
_SRCS:.c=.release.o)
OPT_OBJS
:=
$(STDLIB_RELEASE_OBJS)
$(SRCS:.cpp=.release.o)
$(STDMODULE
S
_SRCS:.c=.release.o)
OBJS
:=
$(STDLIB_OBJS)
$(SRCS:.cpp=.o)
$(STDMODULE_SRCS:.c=.o)
PROFILE_OBJS
:=
$(STDLIB_RELEASE_OBJS)
$(MAIN_SRCS:.cpp=.prof.o)
$(STDLIB_SRCS:.cpp=.release.o)
$(STDMODULE_SRCS:.c=.release.o)
OPT_OBJS
:=
$(STDLIB_RELEASE_OBJS)
$(SRCS:.cpp=.release.o)
$(STDMODULE_SRCS:.c=.release.o)
OPTIONAL_SRCS
:=
codegen/profiling/oprofile.cpp codegen/profiling/pprof.cpp
TOOL_SRCS
:=
$(
wildcard
$(TOOLS_DIR)
/
*
.cpp
)
...
...
src/runtime/types.cpp
View file @
36192fb0
...
...
@@ -489,7 +489,7 @@ public:
RELEASE_ASSERT
(
_key
->
cls
==
str_cls
,
""
);
BoxedString
*
key
=
static_cast
<
BoxedString
*>
(
_key
);
pyston
::
setattr
(
self
->
b
,
key
->
s
.
c_str
(),
value
);
self
->
b
->
setattr
(
key
->
s
,
value
,
NULL
);
return
None
;
}
...
...
@@ -499,8 +499,11 @@ public:
RELEASE_ASSERT
(
_key
->
cls
==
str_cls
,
""
);
BoxedString
*
key
=
static_cast
<
BoxedString
*>
(
_key
);
// TODO swap between AttributeError and KeyError?
return
pyston
::
getattr
(
self
->
b
,
key
->
s
.
c_str
());
Box
*
r
=
self
->
b
->
getattr
(
key
->
s
);
if
(
!
r
)
{
raiseExcHelper
(
KeyError
,
"'%s'"
,
key
->
s
.
c_str
());
}
return
r
;
}
static
Box
*
str
(
Box
*
_self
)
{
...
...
@@ -523,6 +526,16 @@ public:
os
<<
"})"
;
return
boxString
(
os
.
str
());
}
static
Box
*
contains
(
Box
*
_self
,
Box
*
_key
)
{
RELEASE_ASSERT
(
_self
->
cls
==
attrwrapper_cls
,
""
);
AttrWrapper
*
self
=
static_cast
<
AttrWrapper
*>
(
_self
);
RELEASE_ASSERT
(
_key
->
cls
==
str_cls
,
""
);
BoxedString
*
key
=
static_cast
<
BoxedString
*>
(
_key
);
Box
*
r
=
self
->
b
->
getattr
(
key
->
s
);
return
r
?
True
:
False
;
}
};
Box
*
makeAttrWrapper
(
Box
*
b
)
{
...
...
@@ -702,6 +715,8 @@ void setupRuntime() {
attrwrapper_cls
->
giveAttr
(
"__setitem__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
setitem
,
UNKNOWN
,
3
)));
attrwrapper_cls
->
giveAttr
(
"__getitem__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
getitem
,
UNKNOWN
,
2
)));
attrwrapper_cls
->
giveAttr
(
"__str__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
str
,
UNKNOWN
,
1
)));
attrwrapper_cls
->
giveAttr
(
"__contains__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
contains
,
UNKNOWN
,
2
)));
attrwrapper_cls
->
freeze
();
// sys is the first module that needs to be set up, due to modules
...
...
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