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
b4fabb63
Commit
b4fabb63
authored
Apr 30, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add listAppendArrayInternal which appends an array of elements to a list
parent
87d1620d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+4
-3
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+16
-0
src/runtime/list.cpp
src/runtime/list.cpp
+9
-3
src/runtime/types.h
src/runtime/types.h
+1
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
b4fabb63
...
...
@@ -108,6 +108,7 @@ Box* range1(Box* end) {
BoxedList
*
rtn
=
new
BoxedList
();
i64
iend
=
static_cast
<
BoxedInt
*>
(
end
)
->
n
;
rtn
->
ensure
(
iend
);
for
(
i64
i
=
0
;
i
<
iend
;
i
++
)
{
Box
*
bi
=
boxInt
(
i
);
listAppendInternal
(
rtn
,
bi
);
...
...
@@ -122,10 +123,10 @@ Box* range2(Box* start, Box* end) {
BoxedList
*
rtn
=
new
BoxedList
();
i64
istart
=
static_cast
<
BoxedInt
*>
(
start
)
->
n
;
i64
iend
=
static_cast
<
BoxedInt
*>
(
end
)
->
n
;
if
((
iend
-
istart
)
>
0
)
rtn
->
ensure
(
iend
-
istart
);
for
(
i64
i
=
istart
;
i
<
iend
;
i
++
)
{
Box
*
bi
=
boxInt
(
i
);
listAppendInternal
(
rtn
,
bi
);
listAppendInternal
(
rtn
,
boxInt
(
i
));
}
return
rtn
;
}
...
...
src/runtime/inline/list.cpp
View file @
b4fabb63
...
...
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cstring>
#include "runtime/list.h"
#include "runtime/gc_runtime.h"
...
...
@@ -80,6 +82,20 @@ extern "C" void listAppendInternal(Box* s, Box* v) {
self
->
size
++
;
}
extern
"C"
void
listAppendArrayInternal
(
Box
*
s
,
Box
**
v
,
int
nelts
)
{
assert
(
s
->
cls
==
list_cls
);
BoxedList
*
self
=
static_cast
<
BoxedList
*>
(
s
);
assert
(
self
->
size
<=
self
->
capacity
);
self
->
ensure
(
nelts
);
assert
(
self
->
size
<=
self
->
capacity
);
memcpy
(
&
self
->
elts
->
elts
[
self
->
size
],
&
v
[
0
],
nelts
*
sizeof
(
Box
*
));
self
->
size
+=
nelts
;
}
// TODO the inliner doesn't want to inline these; is there any point to having them in the inline section?
extern
"C"
Box
*
listAppend
(
Box
*
s
,
Box
*
v
)
{
assert
(
s
->
cls
==
list_cls
);
...
...
src/runtime/list.cpp
View file @
b4fabb63
...
...
@@ -224,11 +224,17 @@ Box* listMul(BoxedList* self, Box* rhs) {
int
s
=
self
->
size
;
BoxedList
*
rtn
=
new
BoxedList
();
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
j
=
0
;
j
<
s
;
j
++
)
{
listAppendInternal
(
rtn
,
self
->
elts
->
elts
[
j
]);
rtn
->
ensure
(
n
*
s
);
if
(
s
==
1
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
listAppendInternal
(
rtn
,
self
->
elts
->
elts
[
0
]);
}
}
else
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
listAppendArrayInternal
(
rtn
,
&
self
->
elts
->
elts
[
0
],
s
);
}
}
return
rtn
;
}
...
...
src/runtime/types.h
View file @
b4fabb63
...
...
@@ -75,6 +75,7 @@ extern "C" Box* boxStringPtr(const std::string *s);
Box
*
boxString
(
const
std
::
string
&
s
);
extern
"C"
BoxedString
*
boxStrConstant
(
const
char
*
chars
);
extern
"C"
void
listAppendInternal
(
Box
*
self
,
Box
*
v
);
extern
"C"
void
listAppendArrayInternal
(
Box
*
self
,
Box
**
v
,
int
nelts
);
extern
"C"
Box
*
boxCLFunction
(
CLFunction
*
f
);
extern
"C"
CLFunction
*
unboxCLFunction
(
Box
*
b
);
extern
"C"
Box
*
createClass
(
std
::
string
*
name
,
BoxedModule
*
parent_module
);
...
...
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