Ticket #508: json.patch
File json.patch, 28.8 KB (added by bsdz, 13 years ago) |
---|
-
compilers/json/JSON.pir
1 # Copyright (C) 2005-2008, Parrot Foundation.2 3 =head1 NAME4 5 JSON (JavaScript Object Notation) is a lightweight data-interchange format.6 7 =head1 SYNOPSIS8 9 Given a valid JSON string, the compiler will return a PMC containing the10 appropriate values. For example:11 12 .local pmc JSON13 JSON = compreg 'JSON'14 $P0 = JSON('[1,2,3]')15 16 Will create a pmc that C<does> array, contains the values 1, 2, and 3, and17 store it in register C<$P0>.18 19 For more information about the structure of the JSON representation, see the20 documentation at L<http://www.json.org/>.21 22 =cut23 24 .namespace [ 'JSON' ]25 26 .sub '__onload' :load27 load_bytecode 'PGE.pbc'28 load_bytecode 'PGE/Util.pbc'29 load_bytecode 'TGE.pbc'30 31 load_bytecode 'compilers/json/JSON/grammar.pbc'32 load_bytecode 'compilers/json/JSON/pge2pir.pbc'33 34 $P1 = get_global '__compiler'35 compreg "JSON", $P136 37 $P1 = new 'Hash'38 $P1['\"'] = '"'39 $P1['\\'] = "\\"40 $P1['\/'] = '/'41 $P1['\b'] = "\b"42 $P1['\f'] = "\f"43 $P1['\n'] = "\n"44 $P1['\r'] = "\r"45 $P1['\t'] = "\t"46 47 set_root_global [ 'JSON' ], '$escapes', $P148 .end49 50 .sub '__compiler'51 .param string json_string52 53 .local pmc parse, match54 parse = get_root_global ['parrot'; 'JSON'], 'value'55 56 $P0 = get_root_global ['parrot'; 'PGE'], 'Match'57 match = $P0.'new'(json_string)58 match.'to'(0)59 match = parse(match)60 unless match goto failed61 62 .local pmc pirgrammar, pirbuilder, pir63 pirgrammar = new ['JSON'; 'PIR']64 pirbuilder = pirgrammar.'apply'(match)65 pir = pirbuilder.'get'('result')66 67 .local pmc pirc, result68 pirc = compreg "PIR"69 result = pirc(pir)70 .tailcall result()71 72 failed:73 $P0 = new 'Exception'74 $P0[0] = "invalid JSON value"75 throw $P076 .end77 78 # Local Variables:79 # mode: pir80 # fill-column: 10081 # End:82 # vim: expandtab shiftwidth=4 ft=pir: -
compilers/json/postalcodes.pir
Property changes on: compilers\json\JSONReader.pir ___________________________________________________________________ Added: svn:mergeinfo Merged /branches/RELEASE_0_8_2/compilers/json/JSON.pir:r34004-34020 Merged /branches/removing_stm/compilers/json/JSON.pir:r35464-35502 Merged /branches/assert_args/compilers/json/JSON.pir:r34776-34857 Merged /branches/jit_h_files/compilers/json/JSON.pir:r34166-35215
68 68 $I0 = index json_result, "\r\n\r\n" 69 69 substr json_result, 0, $I0, "" 70 70 71 load_bytecode ' compilers/json/JSON.pbc'71 load_bytecode 'library/JSONReader.pbc' 72 72 $P1 = compreg 'JSON' 73 73 $P2 = $P1(json_result) 74 74 -
compilers/json/test.pir
9 9 10 10 load_bytecode 'PGE.pbc' 11 11 load_bytecode 'PGE/Util.pbc' 12 load_bytecode ' compilers/json/JSON.pbc'12 load_bytecode 'library/JSONReader.pbc' 13 13 14 14 .local pmc JSON 15 15 JSON = compreg "JSON" -
config/gen/makefiles/json.in
9 9 PGE_DIR := ../../compilers/pge 10 10 TGE_DIR := ../../compilers/tge 11 11 12 PARROT_LIBRARY := ../../runtime/parrot/library 13 12 14 # the default target 13 all: JSON.pbc15 all: $(PARROT_LIBRARY)/JSONReader.pbc 14 16 15 17 # This is a listing of all targets, that are meant to be called by users 16 18 help: 17 19 @echo "" 18 20 @echo "Following targets are available for the user:" 19 21 @echo "" 20 @echo " all: JSON .pbc"22 @echo " all: JSONReader.pbc" 21 23 @echo " This is the default." 22 24 @echo "Testing:" 23 25 @echo " test: Run the test suite." … … 36 38 testclean: 37 39 $(RM_F) "../../t/compilers/json/*.pir" 38 40 39 JSON.pbc : JSON/grammar.pbc JSON/pge2pir.pbc JSON.pir40 $(PARROT) --output= JSON.pbc JSON.pir41 $(PARROT_LIBRARY)/JSONReader.pbc : JSON/grammar.pbc JSON/pge2pir.pbc JSONReader.pir 42 $(PARROT) --output=$(PARROT_LIBRARY)/JSONReader.pbc JSONReader.pir 41 43 42 44 JSON/grammar.pbc : JSON/grammar.pir 43 45 $(PARROT) --output=JSON/grammar.pbc JSON/grammar.pir … … 52 54 $(PARROT) $(TGE_DIR)/tgc.pir --output=JSON/pge2pir.pir JSON/pge2pir.tg 53 55 54 56 clean : testclean 55 $(RM_F) "JSON/*.pbc" "JSON/*.pir" JSON.pbc57 $(RM_F) "JSON/*.pbc" "JSON/*.pir" $(PARROT_LIBRARY)/JSONReader.pbc 56 58 57 59 # Local variables: 58 60 # mode: makefile -
config/gen/makefiles/root.in
249 249 $(LIBRARY_DIR)/dumper.pbc \ 250 250 $(LIBRARY_DIR)/yaml_dumper.pbc \ 251 251 $(LIBRARY_DIR)/Getopt/Obj.pbc \ 252 $(LIBRARY_DIR)/JSON .pbc \252 $(LIBRARY_DIR)/JSONWriter.pbc \ 253 253 $(LIBRARY_DIR)/Math/Random/mt19937ar.pbc \ 254 254 $(LIBRARY_DIR)/Math/Rand.pbc \ 255 255 $(LIBRARY_DIR)/MIME/Base64.pbc \ -
MANIFEST
55 55 compilers/imcc/symreg.c [imcc] 56 56 compilers/imcc/symreg.h [imcc] 57 57 compilers/imcc/unit.h [imcc] 58 compilers/json/JSON .pir[json]58 compilers/json/JSONReader.pir [json] 59 59 compilers/json/JSON/grammar.pg [json] 60 60 compilers/json/JSON/pge2pir.tg [json] 61 61 compilers/json/postalcodes.pir [json] … … 1152 1152 runtime/parrot/library/Getopt/Obj.pir [library] 1153 1153 runtime/parrot/library/HTTP/Daemon.pir [library] 1154 1154 runtime/parrot/library/Iter.pir [library] 1155 runtime/parrot/library/JSON .pir[library]1155 runtime/parrot/library/JSONWriter.pir [library] 1156 1156 runtime/parrot/library/MIME/Base64.pir [library] 1157 1157 runtime/parrot/library/Math/Rand.pir [library] 1158 1158 runtime/parrot/library/Math/Random/mt19937ar.pir [library] -
MANIFEST.generated
5 5 blib/lib/libparrot.1.0.0.dylib [main]lib 6 6 blib/lib/libparrot.a [main]lib 7 7 blib/lib/libparrot.dylib [main]lib 8 blib/lib/libparrot.so [main]lib 8 9 blib/lib/libparrot.so.1.0.0 [main]lib 9 blib/lib/libparrot.so [main]lib10 10 compilers/json/JSON/grammar.pbc [json] 11 compilers/json/JSON.pbc [json]12 11 compilers/json/JSON/pge2pir.pbc [json] 13 12 compilers/nqp/nqp.pbc [nqp] 14 13 config/gen/call_list/opengl.in [] … … 36 35 include/parrot/extend_vtable.h [main]include 37 36 include/parrot/feature.h [main]include 38 37 include/parrot/has_header.h [main]include 38 include/parrot/oplib/core_ops.h [main]include 39 39 include/parrot/oplib/core_ops_cg.h [main]include 40 40 include/parrot/oplib/core_ops_cgp.h [main]include 41 include/parrot/oplib/core_ops.h [main]include42 41 include/parrot/oplib/core_ops_switch.h [main]include 43 42 include/parrot/oplib/ops.h [main]include 44 43 include/parrot/pbcversion.h [devel]include … … 47 46 include/parrot/platform_limits.h [devel]include 48 47 include/parrot/vtable.h [main]include 49 48 install_config.fpmc [main]lib 49 installable_parrot [main]bin 50 installable_parrot.exe [main]bin 51 installable_parrot_config [main]bin 50 52 installable_parrot_config.exe [main]bin 51 installable_parrot_ config[main]bin53 installable_parrot_debugger [main]bin 52 54 installable_parrot_debugger.exe [main]bin 53 installable_parrot_debugger [main]bin 54 installable_parrot.exe [main]bin 55 installable_parrot [main]bin 55 installable_pbc_disassemble [main]bin 56 56 installable_pbc_disassemble.exe [main]bin 57 installable_pbc_d isassemble[main]bin57 installable_pbc_dump [main]bin 58 58 installable_pbc_dump.exe [main]bin 59 installable_pbc_ dump[main]bin59 installable_pbc_info [main]bin 60 60 installable_pbc_info.exe [main]bin 61 installable_pbc_ info[main]bin61 installable_pbc_merge [main]bin 62 62 installable_pbc_merge.exe [main]bin 63 installable_pbc_ merge[main]bin63 installable_pbc_to_exe [main]bin 64 64 installable_pbc_to_exe.exe [main]bin 65 installable_pbc_to_exe [main]bin66 65 lib/Parrot/Config/Generated.pm [devel]lib 67 libparrot.dll [main]bin68 66 lib/Parrot/OpLib/core.pm [devel]lib 67 lib/Parrot/PMC.pm [devel]lib 69 68 lib/Parrot/Pmc2c/PCCMETHOD_BITS.pm [devel]lib 70 lib/Parrot/PMC.pm [devel]lib 69 libparrot.dll [main]bin 70 library/JSONReader.pbc [json] 71 71 parrot.pc [main]pkgconfig 72 parrot_debugger [main]bin 73 parrot_debugger.exe [main]bin 74 pbc_disassemble [main]bin 72 75 pbc_disassemble.exe [main]bin 73 pbc_d isassemble[main]bin76 pbc_dump [main]bin 74 77 pbc_dump.exe [main]bin 75 pbc_ dump[main]bin78 pbc_info [main]bin 76 79 pbc_info.exe [main]bin 77 pbc_ info[main]bin80 pbc_merge [main]bin 78 81 pbc_merge.exe [main]bin 79 pbc_ merge[main]bin82 pbc_to_exe [main]bin 80 83 pbc_to_exe.exe [main]bin 81 pbc_to_exe [main]bin 82 parrot_debugger.exe [main]bin 83 parrot_debugger [main]bin 84 pirc [main]bin 84 85 pirc.exe [main]bin 85 pirc [main]bin86 86 runtime/parrot/dynext/digest_group.bundle [library] 87 87 runtime/parrot/dynext/digest_group.dll [library] 88 88 runtime/parrot/dynext/digest_group.dylib [library] … … 145 145 runtime/parrot/include/vtable_methods.pasm [main] 146 146 runtime/parrot/include/warnings.pasm [main] 147 147 runtime/parrot/library/CGI/QueryHash.pbc [main] 148 runtime/parrot/library/config.pbc [main] 149 runtime/parrot/library/config.pir [main] 148 runtime/parrot/library/Data/Dumper.pbc [main] 150 149 runtime/parrot/library/Data/Dumper/Base.pbc [main] 151 150 runtime/parrot/library/Data/Dumper/Default.pbc [main] 152 runtime/parrot/library/Data/Dumper.pbc [main]153 runtime/parrot/library/dumper.pbc [main]154 151 runtime/parrot/library/Getopt/Obj.pbc [main] 152 runtime/parrot/library/MIME/Base64.pbc [main] 153 runtime/parrot/library/Math/Rand.pbc [main] 155 154 runtime/parrot/library/Math/Random/mt19937ar.pbc [main] 156 runtime/parrot/library/Math/Rand.pbc [main]157 runtime/parrot/library/MIME/Base64.pbc [main]158 155 runtime/parrot/library/NCI/call_toolkit_init.pbc [main] 159 runtime/parrot/library/ ncurses.pbc[main]156 runtime/parrot/library/OpenGL.pbc [main] 160 157 runtime/parrot/library/OpenGL_funcs.pir [main] 161 runtime/parrot/library/OpenGL.pbc [main]162 158 runtime/parrot/library/P6object.pbc [main] 163 runtime/parrot/library/Parrot/Capture_PIR.pbc [main] 164 runtime/parrot/library/Parrot/Coroutine.pbc [main] 165 runtime/parrot/library/Parrot/Exception.pbc [main] 166 runtime/parrot/library/Parrot/HLLCompiler.pbc [main] 167 runtime/parrot/library/parrotlib.pbc [main] 168 runtime/parrot/library/pcre.pbc [main] 159 runtime/parrot/library/PCT.pbc [pct] 169 160 runtime/parrot/library/PCT/Grammar.pbc [pct] 170 161 runtime/parrot/library/PCT/HLLCompiler.pbc [pct] 171 162 runtime/parrot/library/PCT/PAST.pbc [pct] 172 runtime/parrot/library/P CT.pbc [pct]163 runtime/parrot/library/PGE.pbc [main] 173 164 runtime/parrot/library/PGE/Dumper.pbc [main] 174 165 runtime/parrot/library/PGE/Glob.pbc [main] 175 166 runtime/parrot/library/PGE/Hs.pbc [main] 176 runtime/parrot/library/PGE.pbc [main]177 167 runtime/parrot/library/PGE/Perl6Grammar.pbc [main] 178 168 runtime/parrot/library/PGE/Text.pbc [main] 179 169 runtime/parrot/library/PGE/Util.pbc [main] 170 runtime/parrot/library/Parrot/Capture_PIR.pbc [main] 171 runtime/parrot/library/Parrot/Coroutine.pbc [main] 172 runtime/parrot/library/Parrot/Exception.pbc [main] 173 runtime/parrot/library/Parrot/HLLCompiler.pbc [main] 180 174 runtime/parrot/library/Protoobject.pbc [main] 181 175 runtime/parrot/library/Stream/Base.pbc [main] 182 176 runtime/parrot/library/Stream/Combiner.pbc [main] … … 188 182 runtime/parrot/library/Stream/Sub.pbc [main] 189 183 runtime/parrot/library/Stream/Writer.pbc [main] 190 184 runtime/parrot/library/TGE.pbc [tge] 185 runtime/parrot/library/config.pbc [main] 186 runtime/parrot/library/config.pir [main] 187 runtime/parrot/library/dumper.pbc [main] 188 runtime/parrot/library/ncurses.pbc [main] 189 runtime/parrot/library/parrotlib.pbc [main] 190 runtime/parrot/library/pcre.pbc [main] 191 191 src/call_list.txt [devel]src 192 192 src/glut_callbacks.c [] 193 193 src/jit_emit.h [] -
ports/cygwin/README
147 147 /usr/lib/parrot/1.0.0/library/Getopt/Obj.pir 148 148 /usr/lib/parrot/1.0.0/library/HTTP/Daemon.pir 149 149 /usr/lib/parrot/1.0.0/library/Iter.pir 150 /usr/lib/parrot/1.0.0/library/JSON .pir150 /usr/lib/parrot/1.0.0/library/JSONWriter.pir 151 151 /usr/lib/parrot/1.0.0/library/libpcre.pir 152 152 /usr/lib/parrot/1.0.0/library/Math/Rand.pbc 153 153 /usr/lib/parrot/1.0.0/library/Math/Rand.pir -
runtime/parrot/library/Config/JSON.pir
33 33 text = fh.'readall'() 34 34 35 35 # convert the text to an object and return it. 36 load_bytecode ' compilers/json/JSON.pbc'36 load_bytecode 'library/JSONReader.pbc' 37 37 38 38 .local pmc JSON, config 39 39 JSON = compreg "JSON" … … 77 77 close $P1 78 78 79 79 .end 80 .include 'library/JSON .pir'80 .include 'library/JSONWriter.pir' 81 81 82 82 # Local Variables: 83 83 # mode: pir -
runtime/parrot/library/JSON.pir
1 =head1 TITLE2 3 JSON.pir - PIR implementation of JSON data interchange format.4 5 =head1 SYNOPSIS6 7 Use the C<_json> method to generate a JSON representation of a PMC.8 9 .include 'library/JSON.pir'10 $S0 = _json( $P0 )11 12 To generate a PMC from a JSON string, see L<compilers/json/JSON.pir>.13 14 =cut15 16 =head1 FUNCTIONS17 18 This library provides the following functions:19 20 =over 421 22 =item (string) = _json(pmc, ?pretty )23 24 Convert a PMC to a JSON-serialized string. Note: If you pass in a cyclic25 structure, JSON will eventually throw a maximum recursion depth exception.26 27 =over 428 29 =item pmc30 31 Required. The PMC to dump.32 33 =item pretty34 35 Optional. Boolean: If true, then the generated string will be very36 readable for humans. Defaults to false, which will generate the37 most compact string possible.38 39 =back40 41 =cut42 43 .const string _json_prefix = ' '44 45 .sub _json46 .param pmc thing47 .param int pretty :optional48 .param int has_pretty :opt_flag49 50 .local string result51 52 if has_pretty goto done_init53 pretty = 054 55 done_init:56 result = _json_any(thing,pretty,0)57 unless pretty goto plain58 result .= "\n"59 plain:60 .return (result)61 .end62 63 .sub _json_any64 .param pmc thing65 .param int pretty66 .param int indent67 68 done_init:69 if_null thing, json_null70 71 $I0 = does thing, "array"72 if $I0 goto json_array73 74 $I0 = does thing, "hash"75 if $I0 goto json_hash76 77 $I0 = does thing, "string"78 if $I0 goto json_string79 80 $I0 = does thing, "boolean"81 if $I0 goto json_boolean82 83 $I0 = does thing, "integer"84 if $I0 goto json_integer85 86 $I0 = does thing, "float"87 if $I0 goto json_float88 89 # Default to a null. We could in the future make this more90 # clever, or conditional.91 json_null:92 .tailcall _json_null(thing,pretty,indent)93 json_string:94 .tailcall _json_string(thing,pretty,indent)95 json_array:96 .tailcall _json_array(thing,pretty,indent)97 json_hash:98 .tailcall _json_hash(thing,pretty,indent)99 json_boolean:100 .tailcall _json_boolean(thing,pretty,indent)101 json_integer:102 .tailcall _json_number(thing,pretty,indent)103 json_float:104 .tailcall _json_number(thing,pretty,indent)105 106 .end107 108 .sub '_json_null'109 .param pmc thing # ignored, but needed for the ``API''110 .param int pretty111 .param int indent112 113 unless pretty goto plain114 unless indent goto plain115 116 .local string result117 result = repeat _json_prefix, indent118 result .= 'null'119 .return (result)120 121 plain:122 .return ('null')123 .end124 125 .sub '_json_string'126 .param string thing127 .param int pretty128 .param int indent129 130 .local string result131 132 thing = escape thing133 134 result = '"' . thing135 result = result . '"'136 137 unless pretty goto plain138 unless indent goto plain139 140 $S0 = repeat _json_prefix, indent141 result = $S0 . result142 143 plain:144 .return (result)145 .end146 147 .sub '_json_boolean'148 .param pmc thing149 .param int pretty150 .param int indent151 152 .local string result153 154 result = 'true'155 if thing goto got_value156 result = 'false'157 158 got_value:159 160 unless pretty goto plain161 unless indent goto plain162 163 $S0 = repeat _json_prefix, indent164 result = $S0 . result165 166 plain:167 .return (result)168 .end169 170 .sub '_json_number'171 .param pmc thing172 .param int pretty173 .param int indent174 175 .local string result176 177 result = thing178 179 unless pretty goto plain180 unless indent goto plain181 182 $S0 = repeat _json_prefix, indent183 result = $S0 . result184 185 plain:186 .return (result)187 .end188 189 .sub '_json_array'190 .param pmc thing191 .param int pretty192 .param int indent193 194 .local string result195 196 result = '['197 .local int len198 len = thing199 200 unless pretty goto pre_loop201 unless indent goto pre_loop202 203 $S0 = repeat _json_prefix, indent204 result = $S0 . result205 if len goto pre_loop206 result .= "\n"207 208 pre_loop:209 inc indent210 .local int pos211 pos = 0212 unless pretty goto loop213 if len == 0 goto done_loop214 result .= "\n"215 216 loop:217 if pos >= len goto done_loop218 $P1 = thing[pos]219 $S0 = _json_any($P1,pretty,indent)220 result .= $S0221 inc pos222 if pos == len goto loop223 result .= ","224 unless pretty goto loop225 result .= "\n"226 goto loop227 228 done_loop:229 dec indent230 231 .local string optional_newline,optional_indent232 optional_newline = ''233 optional_indent = ''234 235 unless pretty goto done236 if len == 0 goto indent1237 optional_newline = "\n"238 239 indent1:240 unless indent goto done241 optional_indent = repeat _json_prefix, indent242 243 done:244 result .= optional_newline245 result .= optional_indent246 result .= ']'247 248 .return (result)249 250 .end251 252 .sub '_json_hash'253 .param pmc thing254 .param int pretty255 .param int indent256 257 .local int not_empty258 not_empty = thing259 260 .local pmc keys261 keys = new 'ResizablePMCArray'262 .local pmc iter263 iter = new 'Iterator', thing264 iter = 0265 .local string key266 267 iter_loop:268 unless iter, done_iter269 shift key, iter270 push keys, key271 goto iter_loop272 273 done_iter:274 keys.'sort'()275 276 .local string result,separator277 278 result = '{'279 separator = ':'280 281 unless pretty goto pre_loop282 separator = ' : '283 unless indent goto pre_loop284 285 $S0 = repeat _json_prefix, indent286 result = $S0 . result287 if not_empty goto pre_loop288 result .= "\n"289 290 pre_loop:291 inc indent292 .local int pos293 pos = 0294 unless pretty goto loop295 unless not_empty goto done_loop296 result .= "\n"297 298 loop:299 if pos >= not_empty goto done_loop300 key = keys[pos]301 $S0 = _json_string(key,pretty,indent)302 result .= $S0303 result .= separator304 $P1 = thing[key]305 $S0 = _json_any($P1,pretty,indent)306 307 # remove any leading whitespace on the value's string.308 unless pretty goto space_loop_skip309 310 .local int space_pos,space_len311 space_pos = 0312 space_len = length $S0313 314 space_loop:315 if space_pos >= space_len goto space_loop_done316 $I0 = ord $S0, space_pos317 if $I0 != 32 goto space_loop_done318 319 inc space_pos320 goto space_loop321 322 space_loop_done:323 $S0 = substr $S0, space_pos324 325 space_loop_skip:326 327 result .= $S0328 inc pos329 if pos == not_empty goto loop330 result .= ","331 unless pretty goto loop332 result .= "\n"333 goto loop334 335 done_loop:336 dec indent337 338 .local string optional_newline,optional_indent339 optional_newline = ''340 optional_indent = ''341 342 unless pretty goto done343 unless not_empty goto indent1344 optional_newline = "\n"345 346 indent1:347 unless indent goto done348 optional_indent = repeat _json_prefix, indent349 350 done:351 result .= optional_newline352 result .= optional_indent353 result .= '}'354 355 .return (result)356 .end357 358 =back359 360 =head1 TODO361 362 =over 4363 364 =item 1365 366 Thunk a better way to deal with the maximum recursion depth exception (Or make it official)367 368 =back369 370 =cut371 372 # Local Variables:373 # mode: pir374 # fill-column: 100375 # End:376 # vim: expandtab shiftwidth=4 ft=pir: -
runtime/parrot/library/JSONWriter.pir
1 1 =head1 TITLE 2 2 3 JSON .pir - PIR implementation of JSON data interchange format.3 JSONWriter.pir - PIR implementation of JSON data interchange format. 4 4 5 5 =head1 SYNOPSIS 6 6 7 7 Use the C<_json> method to generate a JSON representation of a PMC. 8 8 9 .include 'library/JSON .pir'9 .include 'library/JSONWriter.pir' 10 10 $S0 = _json( $P0 ) 11 11 12 To generate a PMC from a JSON string, see L<compilers/json/JSON .pir>.12 To generate a PMC from a JSON string, see L<compilers/json/JSONReader.pir>. 13 13 14 14 =cut 15 15 -
t/compilers/json/from_parrot.t
Property changes on: runtime\parrot\library\JSONWriter.pir ___________________________________________________________________ Added: svn:mergeinfo Merged /branches/assert_args/runtime/parrot/library/JSON.pir:r34776-34857 Merged /branches/jit_h_files/runtime/parrot/library/JSON.pir:r34166-35215 Merged /branches/RELEASE_0_8_2/runtime/parrot/library/JSON.pir:r34004-34020 Merged /branches/removing_stm/runtime/parrot/library/JSON.pir:r35464-35502
33 33 $S0 = _json( s, 0 ) 34 34 say $S0 35 35 .end 36 .include 'library/JSON .pir'36 .include 'library/JSONWriter.pir' 37 37 CODE 38 38 "" 39 39 OUT … … 48 48 $S0 = _json( s, 0 ) 49 49 say $S0 50 50 .end 51 .include 'library/JSON .pir'51 .include 'library/JSONWriter.pir' 52 52 CODE 53 53 "abcdeABCDE01234$%^&*" 54 54 OUT … … 63 63 $S0 = _json( s, 0 ) 64 64 say $S0 65 65 .end 66 .include 'library/JSON .pir'66 .include 'library/JSONWriter.pir' 67 67 CODE 68 68 "abcde\\ABCDE\"01234\n$%^&*" 69 69 OUT … … 89 89 $S0 = _json( i, 0 ) 90 90 say $S0 91 91 .end 92 .include 'library/JSON .pir'92 .include 'library/JSONWriter.pir' 93 93 CODE 94 94 0 95 95 35 … … 116 116 $S0 = _json( n ) 117 117 say $S0 118 118 .end 119 .include 'library/JSON .pir'119 .include 'library/JSONWriter.pir' 120 120 CODE 121 121 0 122 122 2.5 … … 143 143 $S0 = _json( n, 1 ) 144 144 print $S0 145 145 .end 146 .include 'library/JSON .pir'146 .include 'library/JSONWriter.pir' 147 147 CODE 148 148 "abcde\\ABCDE\"01234\n$%^&*" 149 149 -42 … … 172 172 $S0 = _json( array, 0 ) 173 173 say $S0 174 174 .end 175 .include 'library/JSON .pir'175 .include 'library/JSONWriter.pir' 176 176 CODE 177 177 [0,1,2,3,4,5,6,7,8,9] 178 178 OUT … … 199 199 $S0 = _json( array, 1 ) 200 200 print $S0 201 201 .end 202 .include 'library/JSON .pir'202 .include 'library/JSONWriter.pir' 203 203 CODE 204 204 [ 205 205 0, … … 233 233 $S0 = _json( array, 1 ) 234 234 print $S0 235 235 .end 236 .include 'library/JSON .pir'236 .include 'library/JSONWriter.pir' 237 237 CODE 238 238 [ 239 239 35, … … 263 263 $S0 = _json( array, 1 ) 264 264 print $S0 265 265 .end 266 .include 'library/JSON .pir'266 .include 'library/JSONWriter.pir' 267 267 CODE 268 268 [ 269 269 0, … … 290 290 $S0 = _json( hash, 1 ) 291 291 print $S0 292 292 .end 293 .include 'library/JSON .pir'293 .include 'library/JSONWriter.pir' 294 294 CODE 295 295 { 296 296 "alpha" : 29, … … 315 315 $S0 = _json( hash, 0 ) 316 316 say $S0 317 317 .end 318 .include 'library/JSON .pir'318 .include 'library/JSONWriter.pir' 319 319 CODE 320 320 {"alpha":29,"beta":"B","delta":"DELTA","gamma":3.1} 321 321 OUT … … 352 352 $S0 = _json( world, 1 ) 353 353 print $S0 354 354 .end 355 .include 'library/JSON .pir'355 .include 'library/JSONWriter.pir' 356 356 CODE 357 357 { 358 358 "population" : 1234567890, … … 403 403 $S0 = _json( world, 0 ) 404 404 say $S0 405 405 .end 406 .include 'library/JSON .pir'406 .include 'library/JSONWriter.pir' 407 407 CODE 408 408 {"population":1234567890,"some_country":[[{"Perl":"Highway","Python":"Grove","Ruby":"Lane"},{}],[]]} 409 409 OUT … … 428 428 $S0 = _json( s, 1 ) 429 429 print $S0 430 430 .end 431 .include 'library/JSON .pir'431 .include 'library/JSONWriter.pir' 432 432 CODE 433 433 "" 434 434 "" … … 456 456 $S0 = _json( i, 1 ) 457 457 print $S0 458 458 .end 459 .include 'library/JSON .pir'459 .include 'library/JSONWriter.pir' 460 460 CODE 461 461 0 462 462 0 … … 484 484 $S0 = _json( b, 1 ) 485 485 print $S0 486 486 .end 487 .include 'library/JSON .pir'487 .include 'library/JSONWriter.pir' 488 488 CODE 489 489 false 490 490 false … … 510 510 $S0 = _json( n, 1 ) 511 511 print $S0 512 512 .end 513 .include 'library/JSON .pir'513 .include 'library/JSONWriter.pir' 514 514 CODE 515 515 null 516 516 null -
t/compilers/json/to_parrot.t
689 689 return pir_output_is( <<"END_PIR", $dumped, $reason, %args ); 690 690 691 691 .sub test :main 692 load_bytecode ' compilers/json/JSON.pbc'692 load_bytecode 'library/JSONReader.pbc' 693 693 load_bytecode 'library/dumper.pbc' 694 694 695 695 .local pmc JSON, result … … 710 710 return pir_error_output_like( <<"END_PIR", qr/not a valid JSON value/, $reason, %args ); 711 711 712 712 .sub test :main 713 load_bytecode ' compilers/json/JSON.pbc'713 load_bytecode 'library/JSONReader.pbc' 714 714 715 715 .local pmc JSON, result 716 716 JSON = compreg "JSON" -
t/library/mime_base64.t
24 24 load_bytecode 'MIME/Base64.pir' 25 25 load_bytecode 'PGE.pbc' 26 26 load_bytecode 'PGE/Util.pbc' 27 load_bytecode ' compilers/json/JSON.pbc'27 load_bytecode 'library/JSONReader.pbc' 28 28 29 29 .local pmc plan, is, ok 30 30 plan = get_hll_global [ 'Test'; 'More' ], 'plan'