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
3ec5c835
Commit
3ec5c835
authored
Mar 05, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #353 from toshok/get-json-module-working
add a json test and get it running
parents
62f6f344
73186c03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+1
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+2
-0
test/tests/json_test.py
test/tests/json_test.py
+56
-0
No files found.
src/asm_writing/rewriter.h
View file @
3ec5c835
...
...
@@ -123,7 +123,7 @@ template <class T> class LocMap {
private:
static
const
int
N_REGS
=
16
;
static
const
int
N_XMM
=
16
;
static
const
int
N_SCRATCH
=
16
;
static
const
int
N_SCRATCH
=
32
;
static
const
int
N_STACK
=
16
;
T
map_reg
[
N_REGS
];
...
...
src/codegen/irgen/irgenerator.cpp
View file @
3ec5c835
...
...
@@ -1863,6 +1863,8 @@ private:
// Currently we represent 'undef's as 'i16 undef'
val
=
emitter
.
getBuilder
()
->
CreateIntToPtr
(
val
,
g
.
llvm_value_type_ptr
);
}
else
if
(
var
->
getType
()
==
CLOSURE
)
{
ptr
=
emitter
.
getBuilder
()
->
CreateBitCast
(
ptr
,
g
.
llvm_closure_type_ptr
->
getPointerTo
());
}
else
{
assert
(
val
->
getType
()
==
g
.
llvm_value_type_ptr
);
}
...
...
test/tests/json_test.py
0 → 100644
View file @
3ec5c835
# skip-if: '-x' in EXTRA_JIT_ARGS
from
StringIO
import
StringIO
import
json
# encoding basic python object hierarchies
print
1
,
json
.
dumps
(
""
)
print
2
,
json
.
dumps
([
'foo'
,
{
'bar'
:
(
'baz'
,
None
,
1.0
,
2
)}])
print
3
,
json
.
dumps
(
"
\
"
foo
\
b
ar"
)
print
4
,
json
.
dumps
(
u'
\
u1234
'
)
print
5
,
json
.
dumps
(
'
\
\
'
)
print
6
,
json
.
dumps
({
"c"
:
0
,
"b"
:
0
,
"a"
:
0
},
sort_keys
=
True
)
io
=
StringIO
()
json
.
dump
([
'streaming API'
],
io
)
print
7
,
io
.
getvalue
()
# compact encoding
print
8
,
json
.
dumps
([
1
,
2
,
3
,{
'4'
:
5
,
'6'
:
7
}],
sort_keys
=
True
,
separators
=
(
','
,
':'
))
# pretty printing
print
9
,
json
.
dumps
({
'4'
:
5
,
'6'
:
7
},
sort_keys
=
True
,
indent
=
4
,
separators
=
(
','
,
': '
))
# decoding json
print
10
,
json
.
loads
(
'["foo", {"bar":["baz", null, 1.0, 2]}]'
)
print
11
,
json
.
loads
(
'"
\
\
"foo
\
\
bar"'
)
io
=
StringIO
(
'["streaming API"]'
)
print
12
,
json
.
load
(
io
)
# specializing json object decoding
def
as_complex
(
dct
):
if
'__complex__'
in
dct
:
return
complex
(
dct
[
'real'
],
dct
[
'imag'
])
return
dct
# disable this part for now. pyston formats the real/imaginary parts as floats always, but cpython
# formats them as integers if they are. i.e. (1+2j) in cpython vs (1.0+2.0j) in pyston.
#print 13, json.loads('{"__complex__": true, "real": 1, "imag": 2}', object_hook=as_complex)
# Pyston doesn't support the decimal module yet
#import decimal
#print type(json.loads('1.1', parse_float=decimal.Decimal))
# extending JSONEncoder
class
ComplexEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
obj
):
if
isinstance
(
obj
,
complex
):
return
[
obj
.
real
,
obj
.
imag
]
# Let the base class default method raise the TypeError
return
json
.
JSONEncoder
.
default
(
self
,
obj
)
print
14
,
json
.
dumps
(
complex
(
2
,
1
),
cls
=
ComplexEncoder
)
print
15
,
ComplexEncoder
().
encode
(
complex
(
2
,
1
))
print
16
,
list
(
ComplexEncoder
().
iterencode
(
complex
(
2
,
1
)))
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