libv8-sgonyea 3.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.gitmodules +3 -0
- data/Gemfile +4 -0
- data/README.md +76 -0
- data/Rakefile +113 -0
- data/ext/libv8/extconf.rb +28 -0
- data/lib/libv8.rb +15 -0
- data/lib/libv8/Makefile +30 -0
- data/lib/libv8/detect_cpu.rb +27 -0
- data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
- data/lib/libv8/v8/.gitignore +35 -0
- data/lib/libv8/v8/AUTHORS +44 -0
- data/lib/libv8/v8/ChangeLog +2839 -0
- data/lib/libv8/v8/LICENSE +52 -0
- data/lib/libv8/v8/LICENSE.strongtalk +29 -0
- data/lib/libv8/v8/LICENSE.v8 +26 -0
- data/lib/libv8/v8/LICENSE.valgrind +45 -0
- data/lib/libv8/v8/SConstruct +1478 -0
- data/lib/libv8/v8/build/README.txt +49 -0
- data/lib/libv8/v8/build/all.gyp +18 -0
- data/lib/libv8/v8/build/armu.gypi +32 -0
- data/lib/libv8/v8/build/common.gypi +144 -0
- data/lib/libv8/v8/build/gyp_v8 +145 -0
- data/lib/libv8/v8/include/v8-debug.h +395 -0
- data/lib/libv8/v8/include/v8-preparser.h +117 -0
- data/lib/libv8/v8/include/v8-profiler.h +505 -0
- data/lib/libv8/v8/include/v8-testing.h +104 -0
- data/lib/libv8/v8/include/v8.h +4124 -0
- data/lib/libv8/v8/include/v8stdint.h +53 -0
- data/lib/libv8/v8/preparser/SConscript +38 -0
- data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
- data/lib/libv8/v8/src/SConscript +368 -0
- data/lib/libv8/v8/src/accessors.cc +767 -0
- data/lib/libv8/v8/src/accessors.h +123 -0
- data/lib/libv8/v8/src/allocation-inl.h +49 -0
- data/lib/libv8/v8/src/allocation.cc +122 -0
- data/lib/libv8/v8/src/allocation.h +143 -0
- data/lib/libv8/v8/src/api.cc +5845 -0
- data/lib/libv8/v8/src/api.h +574 -0
- data/lib/libv8/v8/src/apinatives.js +110 -0
- data/lib/libv8/v8/src/apiutils.h +73 -0
- data/lib/libv8/v8/src/arguments.h +118 -0
- data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
- data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
- data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
- data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
- data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
- data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
- data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
- data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
- data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
- data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
- data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
- data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
- data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
- data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
- data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
- data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
- data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
- data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
- data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
- data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
- data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
- data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
- data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
- data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
- data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
- data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
- data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
- data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
- data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
- data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
- data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
- data/lib/libv8/v8/src/array.js +1366 -0
- data/lib/libv8/v8/src/assembler.cc +1207 -0
- data/lib/libv8/v8/src/assembler.h +858 -0
- data/lib/libv8/v8/src/ast-inl.h +112 -0
- data/lib/libv8/v8/src/ast.cc +1146 -0
- data/lib/libv8/v8/src/ast.h +2188 -0
- data/lib/libv8/v8/src/atomicops.h +167 -0
- data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
- data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
- data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
- data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
- data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
- data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
- data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
- data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
- data/lib/libv8/v8/src/bignum.cc +768 -0
- data/lib/libv8/v8/src/bignum.h +140 -0
- data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
- data/lib/libv8/v8/src/bootstrapper.h +188 -0
- data/lib/libv8/v8/src/builtins.cc +1707 -0
- data/lib/libv8/v8/src/builtins.h +371 -0
- data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
- data/lib/libv8/v8/src/cached-powers.cc +177 -0
- data/lib/libv8/v8/src/cached-powers.h +65 -0
- data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
- data/lib/libv8/v8/src/char-predicates.h +67 -0
- data/lib/libv8/v8/src/checks.cc +110 -0
- data/lib/libv8/v8/src/checks.h +296 -0
- data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
- data/lib/libv8/v8/src/circular-queue.cc +122 -0
- data/lib/libv8/v8/src/circular-queue.h +103 -0
- data/lib/libv8/v8/src/code-stubs.cc +267 -0
- data/lib/libv8/v8/src/code-stubs.h +1011 -0
- data/lib/libv8/v8/src/code.h +70 -0
- data/lib/libv8/v8/src/codegen.cc +231 -0
- data/lib/libv8/v8/src/codegen.h +84 -0
- data/lib/libv8/v8/src/compilation-cache.cc +540 -0
- data/lib/libv8/v8/src/compilation-cache.h +287 -0
- data/lib/libv8/v8/src/compiler.cc +786 -0
- data/lib/libv8/v8/src/compiler.h +312 -0
- data/lib/libv8/v8/src/contexts.cc +347 -0
- data/lib/libv8/v8/src/contexts.h +391 -0
- data/lib/libv8/v8/src/conversions-inl.h +106 -0
- data/lib/libv8/v8/src/conversions.cc +1131 -0
- data/lib/libv8/v8/src/conversions.h +135 -0
- data/lib/libv8/v8/src/counters.cc +93 -0
- data/lib/libv8/v8/src/counters.h +254 -0
- data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
- data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
- data/lib/libv8/v8/src/cpu-profiler.h +302 -0
- data/lib/libv8/v8/src/cpu.h +69 -0
- data/lib/libv8/v8/src/d8-debug.cc +367 -0
- data/lib/libv8/v8/src/d8-debug.h +158 -0
- data/lib/libv8/v8/src/d8-posix.cc +695 -0
- data/lib/libv8/v8/src/d8-readline.cc +130 -0
- data/lib/libv8/v8/src/d8-windows.cc +42 -0
- data/lib/libv8/v8/src/d8.cc +803 -0
- data/lib/libv8/v8/src/d8.gyp +91 -0
- data/lib/libv8/v8/src/d8.h +235 -0
- data/lib/libv8/v8/src/d8.js +2798 -0
- data/lib/libv8/v8/src/data-flow.cc +66 -0
- data/lib/libv8/v8/src/data-flow.h +205 -0
- data/lib/libv8/v8/src/date.js +1103 -0
- data/lib/libv8/v8/src/dateparser-inl.h +127 -0
- data/lib/libv8/v8/src/dateparser.cc +178 -0
- data/lib/libv8/v8/src/dateparser.h +266 -0
- data/lib/libv8/v8/src/debug-agent.cc +447 -0
- data/lib/libv8/v8/src/debug-agent.h +129 -0
- data/lib/libv8/v8/src/debug-debugger.js +2569 -0
- data/lib/libv8/v8/src/debug.cc +3165 -0
- data/lib/libv8/v8/src/debug.h +1057 -0
- data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
- data/lib/libv8/v8/src/deoptimizer.h +602 -0
- data/lib/libv8/v8/src/disasm.h +80 -0
- data/lib/libv8/v8/src/disassembler.cc +343 -0
- data/lib/libv8/v8/src/disassembler.h +58 -0
- data/lib/libv8/v8/src/diy-fp.cc +58 -0
- data/lib/libv8/v8/src/diy-fp.h +117 -0
- data/lib/libv8/v8/src/double.h +238 -0
- data/lib/libv8/v8/src/dtoa.cc +103 -0
- data/lib/libv8/v8/src/dtoa.h +85 -0
- data/lib/libv8/v8/src/execution.cc +849 -0
- data/lib/libv8/v8/src/execution.h +297 -0
- data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
- data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
- data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
- data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
- data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
- data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
- data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
- data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
- data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
- data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
- data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
- data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
- data/lib/libv8/v8/src/factory.cc +1222 -0
- data/lib/libv8/v8/src/factory.h +442 -0
- data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
- data/lib/libv8/v8/src/fast-dtoa.h +83 -0
- data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
- data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
- data/lib/libv8/v8/src/flag-definitions.h +560 -0
- data/lib/libv8/v8/src/flags.cc +551 -0
- data/lib/libv8/v8/src/flags.h +79 -0
- data/lib/libv8/v8/src/frames-inl.h +247 -0
- data/lib/libv8/v8/src/frames.cc +1243 -0
- data/lib/libv8/v8/src/frames.h +870 -0
- data/lib/libv8/v8/src/full-codegen.cc +1374 -0
- data/lib/libv8/v8/src/full-codegen.h +771 -0
- data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
- data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
- data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
- data/lib/libv8/v8/src/gdb-jit.h +143 -0
- data/lib/libv8/v8/src/global-handles.cc +665 -0
- data/lib/libv8/v8/src/global-handles.h +284 -0
- data/lib/libv8/v8/src/globals.h +325 -0
- data/lib/libv8/v8/src/handles-inl.h +177 -0
- data/lib/libv8/v8/src/handles.cc +987 -0
- data/lib/libv8/v8/src/handles.h +382 -0
- data/lib/libv8/v8/src/hashmap.cc +230 -0
- data/lib/libv8/v8/src/hashmap.h +123 -0
- data/lib/libv8/v8/src/heap-inl.h +704 -0
- data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
- data/lib/libv8/v8/src/heap-profiler.h +397 -0
- data/lib/libv8/v8/src/heap.cc +5930 -0
- data/lib/libv8/v8/src/heap.h +2268 -0
- data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
- data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
- data/lib/libv8/v8/src/hydrogen.cc +6239 -0
- data/lib/libv8/v8/src/hydrogen.h +1202 -0
- data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
- data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
- data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
- data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
- data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
- data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
- data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
- data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
- data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
- data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
- data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
- data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
- data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
- data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
- data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
- data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
- data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
- data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
- data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
- data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
- data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
- data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
- data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
- data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
- data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
- data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
- data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
- data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
- data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
- data/lib/libv8/v8/src/ic-inl.h +130 -0
- data/lib/libv8/v8/src/ic.cc +2577 -0
- data/lib/libv8/v8/src/ic.h +736 -0
- data/lib/libv8/v8/src/inspector.cc +63 -0
- data/lib/libv8/v8/src/inspector.h +62 -0
- data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
- data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
- data/lib/libv8/v8/src/isolate-inl.h +50 -0
- data/lib/libv8/v8/src/isolate.cc +1869 -0
- data/lib/libv8/v8/src/isolate.h +1382 -0
- data/lib/libv8/v8/src/json-parser.cc +504 -0
- data/lib/libv8/v8/src/json-parser.h +161 -0
- data/lib/libv8/v8/src/json.js +342 -0
- data/lib/libv8/v8/src/jsregexp.cc +5385 -0
- data/lib/libv8/v8/src/jsregexp.h +1492 -0
- data/lib/libv8/v8/src/list-inl.h +212 -0
- data/lib/libv8/v8/src/list.h +174 -0
- data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
- data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
- data/lib/libv8/v8/src/lithium-allocator.h +630 -0
- data/lib/libv8/v8/src/lithium.cc +190 -0
- data/lib/libv8/v8/src/lithium.h +597 -0
- data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
- data/lib/libv8/v8/src/liveedit.cc +1691 -0
- data/lib/libv8/v8/src/liveedit.h +180 -0
- data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
- data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
- data/lib/libv8/v8/src/liveobjectlist.h +322 -0
- data/lib/libv8/v8/src/log-inl.h +59 -0
- data/lib/libv8/v8/src/log-utils.cc +428 -0
- data/lib/libv8/v8/src/log-utils.h +231 -0
- data/lib/libv8/v8/src/log.cc +1993 -0
- data/lib/libv8/v8/src/log.h +476 -0
- data/lib/libv8/v8/src/macro-assembler.h +120 -0
- data/lib/libv8/v8/src/macros.py +178 -0
- data/lib/libv8/v8/src/mark-compact.cc +3143 -0
- data/lib/libv8/v8/src/mark-compact.h +506 -0
- data/lib/libv8/v8/src/math.js +264 -0
- data/lib/libv8/v8/src/messages.cc +179 -0
- data/lib/libv8/v8/src/messages.h +113 -0
- data/lib/libv8/v8/src/messages.js +1096 -0
- data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
- data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
- data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
- data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
- data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
- data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
- data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
- data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
- data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
- data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
- data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
- data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
- data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
- data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
- data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
- data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
- data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
- data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
- data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
- data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
- data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
- data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
- data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
- data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
- data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
- data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
- data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
- data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
- data/lib/libv8/v8/src/mksnapshot.cc +328 -0
- data/lib/libv8/v8/src/natives.h +64 -0
- data/lib/libv8/v8/src/objects-debug.cc +738 -0
- data/lib/libv8/v8/src/objects-inl.h +4323 -0
- data/lib/libv8/v8/src/objects-printer.cc +829 -0
- data/lib/libv8/v8/src/objects-visiting.cc +148 -0
- data/lib/libv8/v8/src/objects-visiting.h +424 -0
- data/lib/libv8/v8/src/objects.cc +10585 -0
- data/lib/libv8/v8/src/objects.h +6838 -0
- data/lib/libv8/v8/src/parser.cc +4997 -0
- data/lib/libv8/v8/src/parser.h +765 -0
- data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
- data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
- data/lib/libv8/v8/src/platform-linux.cc +1149 -0
- data/lib/libv8/v8/src/platform-macos.cc +830 -0
- data/lib/libv8/v8/src/platform-nullos.cc +479 -0
- data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
- data/lib/libv8/v8/src/platform-posix.cc +424 -0
- data/lib/libv8/v8/src/platform-solaris.cc +762 -0
- data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
- data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
- data/lib/libv8/v8/src/platform-tls.h +50 -0
- data/lib/libv8/v8/src/platform-win32.cc +2021 -0
- data/lib/libv8/v8/src/platform.h +667 -0
- data/lib/libv8/v8/src/preparse-data-format.h +62 -0
- data/lib/libv8/v8/src/preparse-data.cc +183 -0
- data/lib/libv8/v8/src/preparse-data.h +225 -0
- data/lib/libv8/v8/src/preparser-api.cc +220 -0
- data/lib/libv8/v8/src/preparser.cc +1450 -0
- data/lib/libv8/v8/src/preparser.h +493 -0
- data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
- data/lib/libv8/v8/src/prettyprinter.h +223 -0
- data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
- data/lib/libv8/v8/src/profile-generator.cc +3098 -0
- data/lib/libv8/v8/src/profile-generator.h +1126 -0
- data/lib/libv8/v8/src/property.cc +105 -0
- data/lib/libv8/v8/src/property.h +365 -0
- data/lib/libv8/v8/src/proxy.js +83 -0
- data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
- data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
- data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
- data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
- data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
- data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
- data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
- data/lib/libv8/v8/src/regexp-stack.cc +111 -0
- data/lib/libv8/v8/src/regexp-stack.h +147 -0
- data/lib/libv8/v8/src/regexp.js +483 -0
- data/lib/libv8/v8/src/rewriter.cc +360 -0
- data/lib/libv8/v8/src/rewriter.h +50 -0
- data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
- data/lib/libv8/v8/src/runtime-profiler.h +201 -0
- data/lib/libv8/v8/src/runtime.cc +12227 -0
- data/lib/libv8/v8/src/runtime.h +652 -0
- data/lib/libv8/v8/src/runtime.js +649 -0
- data/lib/libv8/v8/src/safepoint-table.cc +256 -0
- data/lib/libv8/v8/src/safepoint-table.h +270 -0
- data/lib/libv8/v8/src/scanner-base.cc +952 -0
- data/lib/libv8/v8/src/scanner-base.h +670 -0
- data/lib/libv8/v8/src/scanner.cc +345 -0
- data/lib/libv8/v8/src/scanner.h +146 -0
- data/lib/libv8/v8/src/scopeinfo.cc +646 -0
- data/lib/libv8/v8/src/scopeinfo.h +254 -0
- data/lib/libv8/v8/src/scopes.cc +1150 -0
- data/lib/libv8/v8/src/scopes.h +507 -0
- data/lib/libv8/v8/src/serialize.cc +1574 -0
- data/lib/libv8/v8/src/serialize.h +589 -0
- data/lib/libv8/v8/src/shell.h +55 -0
- data/lib/libv8/v8/src/simulator.h +43 -0
- data/lib/libv8/v8/src/small-pointer-list.h +163 -0
- data/lib/libv8/v8/src/smart-pointer.h +109 -0
- data/lib/libv8/v8/src/snapshot-common.cc +83 -0
- data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
- data/lib/libv8/v8/src/snapshot.h +91 -0
- data/lib/libv8/v8/src/spaces-inl.h +529 -0
- data/lib/libv8/v8/src/spaces.cc +3145 -0
- data/lib/libv8/v8/src/spaces.h +2369 -0
- data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
- data/lib/libv8/v8/src/splay-tree.h +205 -0
- data/lib/libv8/v8/src/string-search.cc +41 -0
- data/lib/libv8/v8/src/string-search.h +568 -0
- data/lib/libv8/v8/src/string-stream.cc +592 -0
- data/lib/libv8/v8/src/string-stream.h +191 -0
- data/lib/libv8/v8/src/string.js +994 -0
- data/lib/libv8/v8/src/strtod.cc +440 -0
- data/lib/libv8/v8/src/strtod.h +40 -0
- data/lib/libv8/v8/src/stub-cache.cc +1965 -0
- data/lib/libv8/v8/src/stub-cache.h +924 -0
- data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
- data/lib/libv8/v8/src/token.cc +63 -0
- data/lib/libv8/v8/src/token.h +288 -0
- data/lib/libv8/v8/src/type-info.cc +507 -0
- data/lib/libv8/v8/src/type-info.h +272 -0
- data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
- data/lib/libv8/v8/src/unbound-queue.h +69 -0
- data/lib/libv8/v8/src/unicode-inl.h +238 -0
- data/lib/libv8/v8/src/unicode.cc +1624 -0
- data/lib/libv8/v8/src/unicode.h +280 -0
- data/lib/libv8/v8/src/uri.js +408 -0
- data/lib/libv8/v8/src/utils-inl.h +48 -0
- data/lib/libv8/v8/src/utils.cc +371 -0
- data/lib/libv8/v8/src/utils.h +800 -0
- data/lib/libv8/v8/src/v8-counters.cc +62 -0
- data/lib/libv8/v8/src/v8-counters.h +314 -0
- data/lib/libv8/v8/src/v8.cc +213 -0
- data/lib/libv8/v8/src/v8.h +131 -0
- data/lib/libv8/v8/src/v8checks.h +64 -0
- data/lib/libv8/v8/src/v8dll-main.cc +44 -0
- data/lib/libv8/v8/src/v8globals.h +512 -0
- data/lib/libv8/v8/src/v8memory.h +82 -0
- data/lib/libv8/v8/src/v8natives.js +1310 -0
- data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
- data/lib/libv8/v8/src/v8threads.cc +464 -0
- data/lib/libv8/v8/src/v8threads.h +165 -0
- data/lib/libv8/v8/src/v8utils.h +319 -0
- data/lib/libv8/v8/src/variables.cc +114 -0
- data/lib/libv8/v8/src/variables.h +167 -0
- data/lib/libv8/v8/src/version.cc +116 -0
- data/lib/libv8/v8/src/version.h +68 -0
- data/lib/libv8/v8/src/vm-state-inl.h +138 -0
- data/lib/libv8/v8/src/vm-state.h +71 -0
- data/lib/libv8/v8/src/win32-headers.h +96 -0
- data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
- data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
- data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
- data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
- data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
- data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
- data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
- data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
- data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
- data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
- data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
- data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
- data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
- data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
- data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
- data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
- data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
- data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
- data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
- data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
- data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
- data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
- data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
- data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
- data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
- data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
- data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
- data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
- data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
- data/lib/libv8/v8/src/zone-inl.h +140 -0
- data/lib/libv8/v8/src/zone.cc +196 -0
- data/lib/libv8/v8/src/zone.h +240 -0
- data/lib/libv8/v8/tools/codemap.js +265 -0
- data/lib/libv8/v8/tools/consarray.js +93 -0
- data/lib/libv8/v8/tools/csvparser.js +78 -0
- data/lib/libv8/v8/tools/disasm.py +92 -0
- data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
- data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
- data/lib/libv8/v8/tools/gcmole/README +62 -0
- data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
- data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
- data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
- data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
- data/lib/libv8/v8/tools/grokdump.py +841 -0
- data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
- data/lib/libv8/v8/tools/js2c.py +364 -0
- data/lib/libv8/v8/tools/jsmin.py +280 -0
- data/lib/libv8/v8/tools/linux-tick-processor +35 -0
- data/lib/libv8/v8/tools/ll_prof.py +942 -0
- data/lib/libv8/v8/tools/logreader.js +185 -0
- data/lib/libv8/v8/tools/mac-nm +18 -0
- data/lib/libv8/v8/tools/mac-tick-processor +6 -0
- data/lib/libv8/v8/tools/oom_dump/README +31 -0
- data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
- data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
- data/lib/libv8/v8/tools/presubmit.py +305 -0
- data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
- data/lib/libv8/v8/tools/profile.js +751 -0
- data/lib/libv8/v8/tools/profile_view.js +219 -0
- data/lib/libv8/v8/tools/run-valgrind.py +77 -0
- data/lib/libv8/v8/tools/splaytree.js +316 -0
- data/lib/libv8/v8/tools/stats-viewer.py +468 -0
- data/lib/libv8/v8/tools/test.py +1510 -0
- data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
- data/lib/libv8/v8/tools/tickprocessor.js +877 -0
- data/lib/libv8/v8/tools/utils.py +96 -0
- data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
- data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
- data/lib/libv8/version.rb +5 -0
- data/libv8.gemspec +36 -0
- metadata +578 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
#ifndef V8_STRING_STREAM_H_
|
29
|
+
#define V8_STRING_STREAM_H_
|
30
|
+
|
31
|
+
namespace v8 {
|
32
|
+
namespace internal {
|
33
|
+
|
34
|
+
|
35
|
+
class StringAllocator {
|
36
|
+
public:
|
37
|
+
virtual ~StringAllocator() {}
|
38
|
+
// Allocate a number of bytes.
|
39
|
+
virtual char* allocate(unsigned bytes) = 0;
|
40
|
+
// Allocate a larger number of bytes and copy the old buffer to the new one.
|
41
|
+
// bytes is an input and output parameter passing the old size of the buffer
|
42
|
+
// and returning the new size. If allocation fails then we return the old
|
43
|
+
// buffer and do not increase the size.
|
44
|
+
virtual char* grow(unsigned* bytes) = 0;
|
45
|
+
};
|
46
|
+
|
47
|
+
|
48
|
+
// Normal allocator uses new[] and delete[].
|
49
|
+
class HeapStringAllocator: public StringAllocator {
|
50
|
+
public:
|
51
|
+
~HeapStringAllocator() { DeleteArray(space_); }
|
52
|
+
char* allocate(unsigned bytes);
|
53
|
+
char* grow(unsigned* bytes);
|
54
|
+
private:
|
55
|
+
char* space_;
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
// Allocator for use when no new c++ heap allocation is allowed.
|
60
|
+
// Given a preallocated buffer up front and does no allocation while
|
61
|
+
// building message.
|
62
|
+
class NoAllocationStringAllocator: public StringAllocator {
|
63
|
+
public:
|
64
|
+
NoAllocationStringAllocator(char* memory, unsigned size);
|
65
|
+
char* allocate(unsigned bytes) { return space_; }
|
66
|
+
char* grow(unsigned* bytes);
|
67
|
+
private:
|
68
|
+
unsigned size_;
|
69
|
+
char* space_;
|
70
|
+
};
|
71
|
+
|
72
|
+
|
73
|
+
class FmtElm {
|
74
|
+
public:
|
75
|
+
FmtElm(int value) : type_(INT) { // NOLINT
|
76
|
+
data_.u_int_ = value;
|
77
|
+
}
|
78
|
+
explicit FmtElm(double value) : type_(DOUBLE) {
|
79
|
+
data_.u_double_ = value;
|
80
|
+
}
|
81
|
+
FmtElm(const char* value) : type_(C_STR) { // NOLINT
|
82
|
+
data_.u_c_str_ = value;
|
83
|
+
}
|
84
|
+
FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { // NOLINT
|
85
|
+
data_.u_lc_str_ = &value;
|
86
|
+
}
|
87
|
+
FmtElm(Object* value) : type_(OBJ) { // NOLINT
|
88
|
+
data_.u_obj_ = value;
|
89
|
+
}
|
90
|
+
FmtElm(Handle<Object> value) : type_(HANDLE) { // NOLINT
|
91
|
+
data_.u_handle_ = value.location();
|
92
|
+
}
|
93
|
+
FmtElm(void* value) : type_(POINTER) { // NOLINT
|
94
|
+
data_.u_pointer_ = value;
|
95
|
+
}
|
96
|
+
private:
|
97
|
+
friend class StringStream;
|
98
|
+
enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE, POINTER };
|
99
|
+
Type type_;
|
100
|
+
union {
|
101
|
+
int u_int_;
|
102
|
+
double u_double_;
|
103
|
+
const char* u_c_str_;
|
104
|
+
const Vector<const uc16>* u_lc_str_;
|
105
|
+
Object* u_obj_;
|
106
|
+
Object** u_handle_;
|
107
|
+
void* u_pointer_;
|
108
|
+
} data_;
|
109
|
+
};
|
110
|
+
|
111
|
+
|
112
|
+
class StringStream {
|
113
|
+
public:
|
114
|
+
explicit StringStream(StringAllocator* allocator):
|
115
|
+
allocator_(allocator),
|
116
|
+
capacity_(kInitialCapacity),
|
117
|
+
length_(0),
|
118
|
+
buffer_(allocator_->allocate(kInitialCapacity)) {
|
119
|
+
buffer_[0] = 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
~StringStream() {
|
123
|
+
}
|
124
|
+
|
125
|
+
bool Put(char c);
|
126
|
+
bool Put(String* str);
|
127
|
+
bool Put(String* str, int start, int end);
|
128
|
+
void Add(Vector<const char> format, Vector<FmtElm> elms);
|
129
|
+
void Add(const char* format);
|
130
|
+
void Add(Vector<const char> format);
|
131
|
+
void Add(const char* format, FmtElm arg0);
|
132
|
+
void Add(const char* format, FmtElm arg0, FmtElm arg1);
|
133
|
+
void Add(const char* format, FmtElm arg0, FmtElm arg1, FmtElm arg2);
|
134
|
+
void Add(const char* format,
|
135
|
+
FmtElm arg0,
|
136
|
+
FmtElm arg1,
|
137
|
+
FmtElm arg2,
|
138
|
+
FmtElm arg3);
|
139
|
+
|
140
|
+
// Getting the message out.
|
141
|
+
void OutputToFile(FILE* out);
|
142
|
+
void OutputToStdOut() { OutputToFile(stdout); }
|
143
|
+
void Log();
|
144
|
+
Handle<String> ToString();
|
145
|
+
SmartPointer<const char> ToCString() const;
|
146
|
+
int length() const { return length_; }
|
147
|
+
|
148
|
+
// Object printing support.
|
149
|
+
void PrintName(Object* o);
|
150
|
+
void PrintFixedArray(FixedArray* array, unsigned int limit);
|
151
|
+
void PrintByteArray(ByteArray* ba);
|
152
|
+
void PrintUsingMap(JSObject* js_object);
|
153
|
+
void PrintPrototype(JSFunction* fun, Object* receiver);
|
154
|
+
void PrintSecurityTokenIfChanged(Object* function);
|
155
|
+
// NOTE: Returns the code in the output parameter.
|
156
|
+
void PrintFunction(Object* function, Object* receiver, Code** code);
|
157
|
+
|
158
|
+
// Reset the stream.
|
159
|
+
void Reset() {
|
160
|
+
length_ = 0;
|
161
|
+
buffer_[0] = 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
// Mentioned object cache support.
|
165
|
+
void PrintMentionedObjectCache();
|
166
|
+
static void ClearMentionedObjectCache();
|
167
|
+
#ifdef DEBUG
|
168
|
+
static bool IsMentionedObjectCacheClear();
|
169
|
+
#endif
|
170
|
+
|
171
|
+
|
172
|
+
static const int kInitialCapacity = 16;
|
173
|
+
|
174
|
+
private:
|
175
|
+
void PrintObject(Object* obj);
|
176
|
+
|
177
|
+
StringAllocator* allocator_;
|
178
|
+
unsigned capacity_;
|
179
|
+
unsigned length_; // does not include terminating 0-character
|
180
|
+
char* buffer_;
|
181
|
+
|
182
|
+
bool full() const { return (capacity_ - length_) == 1; }
|
183
|
+
int space() const { return capacity_ - length_; }
|
184
|
+
|
185
|
+
DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream);
|
186
|
+
};
|
187
|
+
|
188
|
+
|
189
|
+
} } // namespace v8::internal
|
190
|
+
|
191
|
+
#endif // V8_STRING_STREAM_H_
|
@@ -0,0 +1,994 @@
|
|
1
|
+
// Copyright 2006-2009 the V8 project authors. All rights reserved.
|
2
|
+
// Redistribution and use in source and binary forms, with or without
|
3
|
+
// modification, are permitted provided that the following conditions are
|
4
|
+
// met:
|
5
|
+
//
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
8
|
+
// * Redistributions in binary form must reproduce the above
|
9
|
+
// copyright notice, this list of conditions and the following
|
10
|
+
// disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
// * Neither the name of Google Inc. nor the names of its
|
13
|
+
// contributors may be used to endorse or promote products derived
|
14
|
+
// from this software without specific prior written permission.
|
15
|
+
//
|
16
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
|
29
|
+
// This file relies on the fact that the following declaration has been made
|
30
|
+
// in runtime.js:
|
31
|
+
// const $String = global.String;
|
32
|
+
// const $NaN = 0/0;
|
33
|
+
|
34
|
+
|
35
|
+
// Set the String function and constructor.
|
36
|
+
%SetCode($String, function(x) {
|
37
|
+
var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
|
38
|
+
if (%_IsConstructCall()) {
|
39
|
+
%_SetValueOf(this, value);
|
40
|
+
} else {
|
41
|
+
return value;
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
%FunctionSetPrototype($String, new $String());
|
46
|
+
|
47
|
+
// ECMA-262 section 15.5.4.2
|
48
|
+
function StringToString() {
|
49
|
+
if (!IS_STRING(this) && !IS_STRING_WRAPPER(this))
|
50
|
+
throw new $TypeError('String.prototype.toString is not generic');
|
51
|
+
return %_ValueOf(this);
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
// ECMA-262 section 15.5.4.3
|
56
|
+
function StringValueOf() {
|
57
|
+
if (!IS_STRING(this) && !IS_STRING_WRAPPER(this))
|
58
|
+
throw new $TypeError('String.prototype.valueOf is not generic');
|
59
|
+
return %_ValueOf(this);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
// ECMA-262, section 15.5.4.4
|
64
|
+
function StringCharAt(pos) {
|
65
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
66
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
67
|
+
["String.prototype.charAt"]);
|
68
|
+
}
|
69
|
+
var result = %_StringCharAt(this, pos);
|
70
|
+
if (%_IsSmi(result)) {
|
71
|
+
result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
|
72
|
+
}
|
73
|
+
return result;
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
// ECMA-262 section 15.5.4.5
|
78
|
+
function StringCharCodeAt(pos) {
|
79
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
80
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
81
|
+
["String.prototype.charCodeAt"]);
|
82
|
+
}
|
83
|
+
var result = %_StringCharCodeAt(this, pos);
|
84
|
+
if (!%_IsSmi(result)) {
|
85
|
+
result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
|
86
|
+
}
|
87
|
+
return result;
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
// ECMA-262, section 15.5.4.6
|
92
|
+
function StringConcat() {
|
93
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
94
|
+
throw MakeTypeError("called_on_null_or_undefined", ["String.prototype.concat"]);
|
95
|
+
}
|
96
|
+
var len = %_ArgumentsLength();
|
97
|
+
var this_as_string = TO_STRING_INLINE(this);
|
98
|
+
if (len === 1) {
|
99
|
+
return this_as_string + %_Arguments(0);
|
100
|
+
}
|
101
|
+
var parts = new InternalArray(len + 1);
|
102
|
+
parts[0] = this_as_string;
|
103
|
+
for (var i = 0; i < len; i++) {
|
104
|
+
var part = %_Arguments(i);
|
105
|
+
parts[i + 1] = TO_STRING_INLINE(part);
|
106
|
+
}
|
107
|
+
return %StringBuilderConcat(parts, len + 1, "");
|
108
|
+
}
|
109
|
+
|
110
|
+
// Match ES3 and Safari
|
111
|
+
%FunctionSetLength(StringConcat, 1);
|
112
|
+
|
113
|
+
|
114
|
+
// ECMA-262 section 15.5.4.7
|
115
|
+
function StringIndexOf(pattern /* position */) { // length == 1
|
116
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
117
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
118
|
+
["String.prototype.indexOf"]);
|
119
|
+
}
|
120
|
+
var subject = TO_STRING_INLINE(this);
|
121
|
+
pattern = TO_STRING_INLINE(pattern);
|
122
|
+
var index = 0;
|
123
|
+
if (%_ArgumentsLength() > 1) {
|
124
|
+
index = %_Arguments(1); // position
|
125
|
+
index = TO_INTEGER(index);
|
126
|
+
if (index < 0) index = 0;
|
127
|
+
if (index > subject.length) index = subject.length;
|
128
|
+
}
|
129
|
+
return %StringIndexOf(subject, pattern, index);
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
// ECMA-262 section 15.5.4.8
|
134
|
+
function StringLastIndexOf(pat /* position */) { // length == 1
|
135
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
136
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
137
|
+
["String.prototype.lastIndexOf"]);
|
138
|
+
}
|
139
|
+
var sub = TO_STRING_INLINE(this);
|
140
|
+
var subLength = sub.length;
|
141
|
+
var pat = TO_STRING_INLINE(pat);
|
142
|
+
var patLength = pat.length;
|
143
|
+
var index = subLength - patLength;
|
144
|
+
if (%_ArgumentsLength() > 1) {
|
145
|
+
var position = ToNumber(%_Arguments(1));
|
146
|
+
if (!NUMBER_IS_NAN(position)) {
|
147
|
+
position = TO_INTEGER(position);
|
148
|
+
if (position < 0) {
|
149
|
+
position = 0;
|
150
|
+
}
|
151
|
+
if (position + patLength < subLength) {
|
152
|
+
index = position
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
if (index < 0) {
|
157
|
+
return -1;
|
158
|
+
}
|
159
|
+
return %StringLastIndexOf(sub, pat, index);
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
// ECMA-262 section 15.5.4.9
|
164
|
+
//
|
165
|
+
// This function is implementation specific. For now, we do not
|
166
|
+
// do anything locale specific.
|
167
|
+
function StringLocaleCompare(other) {
|
168
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
169
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
170
|
+
["String.prototype.localeCompare"]);
|
171
|
+
}
|
172
|
+
if (%_ArgumentsLength() === 0) return 0;
|
173
|
+
return %StringLocaleCompare(TO_STRING_INLINE(this),
|
174
|
+
TO_STRING_INLINE(other));
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
// ECMA-262 section 15.5.4.10
|
179
|
+
function StringMatch(regexp) {
|
180
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
181
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
182
|
+
["String.prototype.match"]);
|
183
|
+
}
|
184
|
+
var subject = TO_STRING_INLINE(this);
|
185
|
+
if (IS_REGEXP(regexp)) {
|
186
|
+
if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
|
187
|
+
%_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
|
188
|
+
// lastMatchInfo is defined in regexp.js.
|
189
|
+
return %StringMatch(subject, regexp, lastMatchInfo);
|
190
|
+
}
|
191
|
+
// Non-regexp argument.
|
192
|
+
regexp = new $RegExp(regexp);
|
193
|
+
return RegExpExecNoTests(regexp, subject, 0);
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
// SubString is an internal function that returns the sub string of 'string'.
|
198
|
+
// If resulting string is of length 1, we use the one character cache
|
199
|
+
// otherwise we call the runtime system.
|
200
|
+
function SubString(string, start, end) {
|
201
|
+
// Use the one character string cache.
|
202
|
+
if (start + 1 == end) return %_StringCharAt(string, start);
|
203
|
+
return %_SubString(string, start, end);
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
// This has the same size as the lastMatchInfo array, and can be used for
|
208
|
+
// functions that expect that structure to be returned. It is used when the
|
209
|
+
// needle is a string rather than a regexp. In this case we can't update
|
210
|
+
// lastMatchArray without erroneously affecting the properties on the global
|
211
|
+
// RegExp object.
|
212
|
+
var reusableMatchInfo = [2, "", "", -1, -1];
|
213
|
+
|
214
|
+
|
215
|
+
// ECMA-262, section 15.5.4.11
|
216
|
+
function StringReplace(search, replace) {
|
217
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
218
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
219
|
+
["String.prototype.replace"]);
|
220
|
+
}
|
221
|
+
var subject = TO_STRING_INLINE(this);
|
222
|
+
|
223
|
+
// Delegate to one of the regular expression variants if necessary.
|
224
|
+
if (IS_REGEXP(search)) {
|
225
|
+
%_Log('regexp', 'regexp-replace,%0r,%1S', [search, subject]);
|
226
|
+
if (IS_FUNCTION(replace)) {
|
227
|
+
if (search.global) {
|
228
|
+
return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
|
229
|
+
} else {
|
230
|
+
return StringReplaceNonGlobalRegExpWithFunction(subject,
|
231
|
+
search,
|
232
|
+
replace);
|
233
|
+
}
|
234
|
+
} else {
|
235
|
+
return %StringReplaceRegExpWithString(subject,
|
236
|
+
search,
|
237
|
+
TO_STRING_INLINE(replace),
|
238
|
+
lastMatchInfo);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
// Convert the search argument to a string and search for it.
|
243
|
+
search = TO_STRING_INLINE(search);
|
244
|
+
var start = %StringIndexOf(subject, search, 0);
|
245
|
+
if (start < 0) return subject;
|
246
|
+
var end = start + search.length;
|
247
|
+
|
248
|
+
var builder = new ReplaceResultBuilder(subject);
|
249
|
+
// prefix
|
250
|
+
builder.addSpecialSlice(0, start);
|
251
|
+
|
252
|
+
// Compute the string to replace with.
|
253
|
+
if (IS_FUNCTION(replace)) {
|
254
|
+
builder.add(%_CallFunction(%GetGlobalReceiver(),
|
255
|
+
search,
|
256
|
+
start,
|
257
|
+
subject,
|
258
|
+
replace));
|
259
|
+
} else {
|
260
|
+
reusableMatchInfo[CAPTURE0] = start;
|
261
|
+
reusableMatchInfo[CAPTURE1] = end;
|
262
|
+
replace = TO_STRING_INLINE(replace);
|
263
|
+
ExpandReplacement(replace, subject, reusableMatchInfo, builder);
|
264
|
+
}
|
265
|
+
|
266
|
+
// suffix
|
267
|
+
builder.addSpecialSlice(end, subject.length);
|
268
|
+
|
269
|
+
return builder.generate();
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
// Expand the $-expressions in the string and return a new string with
|
274
|
+
// the result.
|
275
|
+
function ExpandReplacement(string, subject, matchInfo, builder) {
|
276
|
+
var length = string.length;
|
277
|
+
var builder_elements = builder.elements;
|
278
|
+
var next = %StringIndexOf(string, '$', 0);
|
279
|
+
if (next < 0) {
|
280
|
+
if (length > 0) builder_elements.push(string);
|
281
|
+
return;
|
282
|
+
}
|
283
|
+
|
284
|
+
// Compute the number of captures; see ECMA-262, 15.5.4.11, p. 102.
|
285
|
+
var m = NUMBER_OF_CAPTURES(matchInfo) >> 1; // Includes the match.
|
286
|
+
|
287
|
+
if (next > 0) builder_elements.push(SubString(string, 0, next));
|
288
|
+
|
289
|
+
while (true) {
|
290
|
+
var expansion = '$';
|
291
|
+
var position = next + 1;
|
292
|
+
if (position < length) {
|
293
|
+
var peek = %_StringCharCodeAt(string, position);
|
294
|
+
if (peek == 36) { // $$
|
295
|
+
++position;
|
296
|
+
builder_elements.push('$');
|
297
|
+
} else if (peek == 38) { // $& - match
|
298
|
+
++position;
|
299
|
+
builder.addSpecialSlice(matchInfo[CAPTURE0],
|
300
|
+
matchInfo[CAPTURE1]);
|
301
|
+
} else if (peek == 96) { // $` - prefix
|
302
|
+
++position;
|
303
|
+
builder.addSpecialSlice(0, matchInfo[CAPTURE0]);
|
304
|
+
} else if (peek == 39) { // $' - suffix
|
305
|
+
++position;
|
306
|
+
builder.addSpecialSlice(matchInfo[CAPTURE1], subject.length);
|
307
|
+
} else if (peek >= 48 && peek <= 57) { // $n, 0 <= n <= 9
|
308
|
+
++position;
|
309
|
+
var n = peek - 48;
|
310
|
+
if (position < length) {
|
311
|
+
peek = %_StringCharCodeAt(string, position);
|
312
|
+
// $nn, 01 <= nn <= 99
|
313
|
+
if (n != 0 && peek == 48 || peek >= 49 && peek <= 57) {
|
314
|
+
var nn = n * 10 + (peek - 48);
|
315
|
+
if (nn < m) {
|
316
|
+
// If the two digit capture reference is within range of
|
317
|
+
// the captures, we use it instead of the single digit
|
318
|
+
// one. Otherwise, we fall back to using the single
|
319
|
+
// digit reference. This matches the behavior of
|
320
|
+
// SpiderMonkey.
|
321
|
+
++position;
|
322
|
+
n = nn;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
if (0 < n && n < m) {
|
327
|
+
addCaptureString(builder, matchInfo, n);
|
328
|
+
} else {
|
329
|
+
// Because of the captures range check in the parsing of two
|
330
|
+
// digit capture references, we can only enter here when a
|
331
|
+
// single digit capture reference is outside the range of
|
332
|
+
// captures.
|
333
|
+
builder_elements.push('$');
|
334
|
+
--position;
|
335
|
+
}
|
336
|
+
} else {
|
337
|
+
builder_elements.push('$');
|
338
|
+
}
|
339
|
+
} else {
|
340
|
+
builder_elements.push('$');
|
341
|
+
}
|
342
|
+
|
343
|
+
// Go the the next $ in the string.
|
344
|
+
next = %StringIndexOf(string, '$', position);
|
345
|
+
|
346
|
+
// Return if there are no more $ characters in the string. If we
|
347
|
+
// haven't reached the end, we need to append the suffix.
|
348
|
+
if (next < 0) {
|
349
|
+
if (position < length) {
|
350
|
+
builder_elements.push(SubString(string, position, length));
|
351
|
+
}
|
352
|
+
return;
|
353
|
+
}
|
354
|
+
|
355
|
+
// Append substring between the previous and the next $ character.
|
356
|
+
if (next > position) {
|
357
|
+
builder_elements.push(SubString(string, position, next));
|
358
|
+
}
|
359
|
+
}
|
360
|
+
};
|
361
|
+
|
362
|
+
|
363
|
+
// Compute the string of a given regular expression capture.
|
364
|
+
function CaptureString(string, lastCaptureInfo, index) {
|
365
|
+
// Scale the index.
|
366
|
+
var scaled = index << 1;
|
367
|
+
// Compute start and end.
|
368
|
+
var start = lastCaptureInfo[CAPTURE(scaled)];
|
369
|
+
// If start isn't valid, return undefined.
|
370
|
+
if (start < 0) return;
|
371
|
+
var end = lastCaptureInfo[CAPTURE(scaled + 1)];
|
372
|
+
return SubString(string, start, end);
|
373
|
+
};
|
374
|
+
|
375
|
+
|
376
|
+
// Add the string of a given regular expression capture to the
|
377
|
+
// ReplaceResultBuilder
|
378
|
+
function addCaptureString(builder, matchInfo, index) {
|
379
|
+
// Scale the index.
|
380
|
+
var scaled = index << 1;
|
381
|
+
// Compute start and end.
|
382
|
+
var start = matchInfo[CAPTURE(scaled)];
|
383
|
+
if (start < 0) return;
|
384
|
+
var end = matchInfo[CAPTURE(scaled + 1)];
|
385
|
+
builder.addSpecialSlice(start, end);
|
386
|
+
};
|
387
|
+
|
388
|
+
// TODO(lrn): This array will survive indefinitely if replace is never
|
389
|
+
// called again. However, it will be empty, since the contents are cleared
|
390
|
+
// in the finally block.
|
391
|
+
var reusableReplaceArray = new InternalArray(16);
|
392
|
+
|
393
|
+
// Helper function for replacing regular expressions with the result of a
|
394
|
+
// function application in String.prototype.replace.
|
395
|
+
function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
|
396
|
+
var resultArray = reusableReplaceArray;
|
397
|
+
if (resultArray) {
|
398
|
+
reusableReplaceArray = null;
|
399
|
+
} else {
|
400
|
+
// Inside a nested replace (replace called from the replacement function
|
401
|
+
// of another replace) or we have failed to set the reusable array
|
402
|
+
// back due to an exception in a replacement function. Create a new
|
403
|
+
// array to use in the future, or until the original is written back.
|
404
|
+
resultArray = new InternalArray(16);
|
405
|
+
}
|
406
|
+
var res = %RegExpExecMultiple(regexp,
|
407
|
+
subject,
|
408
|
+
lastMatchInfo,
|
409
|
+
resultArray);
|
410
|
+
regexp.lastIndex = 0;
|
411
|
+
if (IS_NULL(res)) {
|
412
|
+
// No matches at all.
|
413
|
+
reusableReplaceArray = resultArray;
|
414
|
+
return subject;
|
415
|
+
}
|
416
|
+
var len = res.length;
|
417
|
+
var i = 0;
|
418
|
+
if (NUMBER_OF_CAPTURES(lastMatchInfo) == 2) {
|
419
|
+
var match_start = 0;
|
420
|
+
var override = new InternalArray(null, 0, subject);
|
421
|
+
var receiver = %GetGlobalReceiver();
|
422
|
+
while (i < len) {
|
423
|
+
var elem = res[i];
|
424
|
+
if (%_IsSmi(elem)) {
|
425
|
+
if (elem > 0) {
|
426
|
+
match_start = (elem >> 11) + (elem & 0x7ff);
|
427
|
+
} else {
|
428
|
+
match_start = res[++i] - elem;
|
429
|
+
}
|
430
|
+
} else {
|
431
|
+
override[0] = elem;
|
432
|
+
override[1] = match_start;
|
433
|
+
lastMatchInfoOverride = override;
|
434
|
+
var func_result =
|
435
|
+
%_CallFunction(receiver, elem, match_start, subject, replace);
|
436
|
+
res[i] = TO_STRING_INLINE(func_result);
|
437
|
+
match_start += elem.length;
|
438
|
+
}
|
439
|
+
i++;
|
440
|
+
}
|
441
|
+
} else {
|
442
|
+
while (i < len) {
|
443
|
+
var elem = res[i];
|
444
|
+
if (!%_IsSmi(elem)) {
|
445
|
+
// elem must be an Array.
|
446
|
+
// Use the apply argument as backing for global RegExp properties.
|
447
|
+
lastMatchInfoOverride = elem;
|
448
|
+
var func_result = replace.apply(null, elem);
|
449
|
+
res[i] = TO_STRING_INLINE(func_result);
|
450
|
+
}
|
451
|
+
i++;
|
452
|
+
}
|
453
|
+
}
|
454
|
+
var resultBuilder = new ReplaceResultBuilder(subject, res);
|
455
|
+
var result = resultBuilder.generate();
|
456
|
+
resultArray.length = 0;
|
457
|
+
reusableReplaceArray = resultArray;
|
458
|
+
return result;
|
459
|
+
}
|
460
|
+
|
461
|
+
|
462
|
+
function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
|
463
|
+
var matchInfo = DoRegExpExec(regexp, subject, 0);
|
464
|
+
if (IS_NULL(matchInfo)) return subject;
|
465
|
+
var result = new ReplaceResultBuilder(subject);
|
466
|
+
var index = matchInfo[CAPTURE0];
|
467
|
+
result.addSpecialSlice(0, index);
|
468
|
+
var endOfMatch = matchInfo[CAPTURE1];
|
469
|
+
// Compute the parameter list consisting of the match, captures, index,
|
470
|
+
// and subject for the replace function invocation.
|
471
|
+
// The number of captures plus one for the match.
|
472
|
+
var m = NUMBER_OF_CAPTURES(matchInfo) >> 1;
|
473
|
+
var replacement;
|
474
|
+
if (m == 1) {
|
475
|
+
// No captures, only the match, which is always valid.
|
476
|
+
var s = SubString(subject, index, endOfMatch);
|
477
|
+
// Don't call directly to avoid exposing the built-in global object.
|
478
|
+
replacement =
|
479
|
+
%_CallFunction(%GetGlobalReceiver(), s, index, subject, replace);
|
480
|
+
} else {
|
481
|
+
var parameters = new InternalArray(m + 2);
|
482
|
+
for (var j = 0; j < m; j++) {
|
483
|
+
parameters[j] = CaptureString(subject, matchInfo, j);
|
484
|
+
}
|
485
|
+
parameters[j] = index;
|
486
|
+
parameters[j + 1] = subject;
|
487
|
+
|
488
|
+
replacement = replace.apply(null, parameters);
|
489
|
+
}
|
490
|
+
|
491
|
+
result.add(replacement); // The add method converts to string if necessary.
|
492
|
+
// Can't use matchInfo any more from here, since the function could
|
493
|
+
// overwrite it.
|
494
|
+
result.addSpecialSlice(endOfMatch, subject.length);
|
495
|
+
return result.generate();
|
496
|
+
}
|
497
|
+
|
498
|
+
|
499
|
+
// ECMA-262 section 15.5.4.12
|
500
|
+
function StringSearch(re) {
|
501
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
502
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
503
|
+
["String.prototype.search"]);
|
504
|
+
}
|
505
|
+
var regexp;
|
506
|
+
if (IS_STRING(re)) {
|
507
|
+
regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re);
|
508
|
+
} else if (IS_REGEXP(re)) {
|
509
|
+
regexp = re;
|
510
|
+
} else {
|
511
|
+
regexp = new $RegExp(re);
|
512
|
+
}
|
513
|
+
var match = DoRegExpExec(regexp, TO_STRING_INLINE(this), 0);
|
514
|
+
if (match) {
|
515
|
+
return match[CAPTURE0];
|
516
|
+
}
|
517
|
+
return -1;
|
518
|
+
}
|
519
|
+
|
520
|
+
|
521
|
+
// ECMA-262 section 15.5.4.13
|
522
|
+
function StringSlice(start, end) {
|
523
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
524
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
525
|
+
["String.prototype.slice"]);
|
526
|
+
}
|
527
|
+
var s = TO_STRING_INLINE(this);
|
528
|
+
var s_len = s.length;
|
529
|
+
var start_i = TO_INTEGER(start);
|
530
|
+
var end_i = s_len;
|
531
|
+
if (end !== void 0)
|
532
|
+
end_i = TO_INTEGER(end);
|
533
|
+
|
534
|
+
if (start_i < 0) {
|
535
|
+
start_i += s_len;
|
536
|
+
if (start_i < 0)
|
537
|
+
start_i = 0;
|
538
|
+
} else {
|
539
|
+
if (start_i > s_len)
|
540
|
+
start_i = s_len;
|
541
|
+
}
|
542
|
+
|
543
|
+
if (end_i < 0) {
|
544
|
+
end_i += s_len;
|
545
|
+
if (end_i < 0)
|
546
|
+
end_i = 0;
|
547
|
+
} else {
|
548
|
+
if (end_i > s_len)
|
549
|
+
end_i = s_len;
|
550
|
+
}
|
551
|
+
|
552
|
+
var num_c = end_i - start_i;
|
553
|
+
if (num_c < 0)
|
554
|
+
num_c = 0;
|
555
|
+
|
556
|
+
return SubString(s, start_i, start_i + num_c);
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
// ECMA-262 section 15.5.4.14
|
561
|
+
function StringSplit(separator, limit) {
|
562
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
563
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
564
|
+
["String.prototype.split"]);
|
565
|
+
}
|
566
|
+
var subject = TO_STRING_INLINE(this);
|
567
|
+
limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
|
568
|
+
if (limit === 0) return [];
|
569
|
+
|
570
|
+
// ECMA-262 says that if separator is undefined, the result should
|
571
|
+
// be an array of size 1 containing the entire string. SpiderMonkey
|
572
|
+
// and KJS have this behavior only when no separator is given. If
|
573
|
+
// undefined is explicitly given, they convert it to a string and
|
574
|
+
// use that. We do as SpiderMonkey and KJS.
|
575
|
+
if (%_ArgumentsLength() === 0) {
|
576
|
+
return [subject];
|
577
|
+
}
|
578
|
+
|
579
|
+
var length = subject.length;
|
580
|
+
if (!IS_REGEXP(separator)) {
|
581
|
+
separator = TO_STRING_INLINE(separator);
|
582
|
+
var separator_length = separator.length;
|
583
|
+
|
584
|
+
// If the separator string is empty then return the elements in the subject.
|
585
|
+
if (separator_length === 0) return %StringToArray(subject, limit);
|
586
|
+
|
587
|
+
var result = %StringSplit(subject, separator, limit);
|
588
|
+
|
589
|
+
return result;
|
590
|
+
}
|
591
|
+
|
592
|
+
%_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
|
593
|
+
|
594
|
+
if (length === 0) {
|
595
|
+
if (DoRegExpExec(separator, subject, 0, 0) != null) {
|
596
|
+
return [];
|
597
|
+
}
|
598
|
+
return [subject];
|
599
|
+
}
|
600
|
+
|
601
|
+
var currentIndex = 0;
|
602
|
+
var startIndex = 0;
|
603
|
+
var startMatch = 0;
|
604
|
+
var result = [];
|
605
|
+
|
606
|
+
outer_loop:
|
607
|
+
while (true) {
|
608
|
+
|
609
|
+
if (startIndex === length) {
|
610
|
+
result.push(SubString(subject, currentIndex, length));
|
611
|
+
break;
|
612
|
+
}
|
613
|
+
|
614
|
+
var matchInfo = DoRegExpExec(separator, subject, startIndex);
|
615
|
+
if (matchInfo == null || length === (startMatch = matchInfo[CAPTURE0])) {
|
616
|
+
result.push(SubString(subject, currentIndex, length));
|
617
|
+
break;
|
618
|
+
}
|
619
|
+
var endIndex = matchInfo[CAPTURE1];
|
620
|
+
|
621
|
+
// We ignore a zero-length match at the currentIndex.
|
622
|
+
if (startIndex === endIndex && endIndex === currentIndex) {
|
623
|
+
startIndex++;
|
624
|
+
continue;
|
625
|
+
}
|
626
|
+
|
627
|
+
if (currentIndex + 1 == startMatch) {
|
628
|
+
result.push(%_StringCharAt(subject, currentIndex));
|
629
|
+
} else {
|
630
|
+
result.push(%_SubString(subject, currentIndex, startMatch));
|
631
|
+
}
|
632
|
+
|
633
|
+
if (result.length === limit) break;
|
634
|
+
|
635
|
+
var matchinfo_len = NUMBER_OF_CAPTURES(matchInfo) + REGEXP_FIRST_CAPTURE;
|
636
|
+
for (var i = REGEXP_FIRST_CAPTURE + 2; i < matchinfo_len; ) {
|
637
|
+
var start = matchInfo[i++];
|
638
|
+
var end = matchInfo[i++];
|
639
|
+
if (end != -1) {
|
640
|
+
if (start + 1 == end) {
|
641
|
+
result.push(%_StringCharAt(subject, start));
|
642
|
+
} else {
|
643
|
+
result.push(%_SubString(subject, start, end));
|
644
|
+
}
|
645
|
+
} else {
|
646
|
+
result.push(void 0);
|
647
|
+
}
|
648
|
+
if (result.length === limit) break outer_loop;
|
649
|
+
}
|
650
|
+
|
651
|
+
startIndex = currentIndex = endIndex;
|
652
|
+
}
|
653
|
+
return result;
|
654
|
+
}
|
655
|
+
|
656
|
+
|
657
|
+
// ECMA-262 section 15.5.4.15
|
658
|
+
function StringSubstring(start, end) {
|
659
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
660
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
661
|
+
["String.prototype.subString"]);
|
662
|
+
}
|
663
|
+
var s = TO_STRING_INLINE(this);
|
664
|
+
var s_len = s.length;
|
665
|
+
|
666
|
+
var start_i = TO_INTEGER(start);
|
667
|
+
if (start_i < 0) {
|
668
|
+
start_i = 0;
|
669
|
+
} else if (start_i > s_len) {
|
670
|
+
start_i = s_len;
|
671
|
+
}
|
672
|
+
|
673
|
+
var end_i = s_len;
|
674
|
+
if (!IS_UNDEFINED(end)) {
|
675
|
+
end_i = TO_INTEGER(end);
|
676
|
+
if (end_i > s_len) {
|
677
|
+
end_i = s_len;
|
678
|
+
} else {
|
679
|
+
if (end_i < 0) end_i = 0;
|
680
|
+
if (start_i > end_i) {
|
681
|
+
var tmp = end_i;
|
682
|
+
end_i = start_i;
|
683
|
+
start_i = tmp;
|
684
|
+
}
|
685
|
+
}
|
686
|
+
}
|
687
|
+
|
688
|
+
return (start_i + 1 == end_i
|
689
|
+
? %_StringCharAt(s, start_i)
|
690
|
+
: %_SubString(s, start_i, end_i));
|
691
|
+
}
|
692
|
+
|
693
|
+
|
694
|
+
// This is not a part of ECMA-262.
|
695
|
+
function StringSubstr(start, n) {
|
696
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
697
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
698
|
+
["String.prototype.substr"]);
|
699
|
+
}
|
700
|
+
var s = TO_STRING_INLINE(this);
|
701
|
+
var len;
|
702
|
+
|
703
|
+
// Correct n: If not given, set to string length; if explicitly
|
704
|
+
// set to undefined, zero, or negative, returns empty string.
|
705
|
+
if (n === void 0) {
|
706
|
+
len = s.length;
|
707
|
+
} else {
|
708
|
+
len = TO_INTEGER(n);
|
709
|
+
if (len <= 0) return '';
|
710
|
+
}
|
711
|
+
|
712
|
+
// Correct start: If not given (or undefined), set to zero; otherwise
|
713
|
+
// convert to integer and handle negative case.
|
714
|
+
if (start === void 0) {
|
715
|
+
start = 0;
|
716
|
+
} else {
|
717
|
+
start = TO_INTEGER(start);
|
718
|
+
// If positive, and greater than or equal to the string length,
|
719
|
+
// return empty string.
|
720
|
+
if (start >= s.length) return '';
|
721
|
+
// If negative and absolute value is larger than the string length,
|
722
|
+
// use zero.
|
723
|
+
if (start < 0) {
|
724
|
+
start += s.length;
|
725
|
+
if (start < 0) start = 0;
|
726
|
+
}
|
727
|
+
}
|
728
|
+
|
729
|
+
var end = start + len;
|
730
|
+
if (end > s.length) end = s.length;
|
731
|
+
|
732
|
+
return (start + 1 == end
|
733
|
+
? %_StringCharAt(s, start)
|
734
|
+
: %_SubString(s, start, end));
|
735
|
+
}
|
736
|
+
|
737
|
+
|
738
|
+
// ECMA-262, 15.5.4.16
|
739
|
+
function StringToLowerCase() {
|
740
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
741
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
742
|
+
["String.prototype.toLowerCase"]);
|
743
|
+
}
|
744
|
+
return %StringToLowerCase(TO_STRING_INLINE(this));
|
745
|
+
}
|
746
|
+
|
747
|
+
|
748
|
+
// ECMA-262, 15.5.4.17
|
749
|
+
function StringToLocaleLowerCase() {
|
750
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
751
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
752
|
+
["String.prototype.toLocaleLowerCase"]);
|
753
|
+
}
|
754
|
+
return %StringToLowerCase(TO_STRING_INLINE(this));
|
755
|
+
}
|
756
|
+
|
757
|
+
|
758
|
+
// ECMA-262, 15.5.4.18
|
759
|
+
function StringToUpperCase() {
|
760
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
761
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
762
|
+
["String.prototype.toUpperCase"]);
|
763
|
+
}
|
764
|
+
return %StringToUpperCase(TO_STRING_INLINE(this));
|
765
|
+
}
|
766
|
+
|
767
|
+
|
768
|
+
// ECMA-262, 15.5.4.19
|
769
|
+
function StringToLocaleUpperCase() {
|
770
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
771
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
772
|
+
["String.prototype.toLocaleUpperCase"]);
|
773
|
+
}
|
774
|
+
return %StringToUpperCase(TO_STRING_INLINE(this));
|
775
|
+
}
|
776
|
+
|
777
|
+
// ES5, 15.5.4.20
|
778
|
+
function StringTrim() {
|
779
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
780
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
781
|
+
["String.prototype.trim"]);
|
782
|
+
}
|
783
|
+
return %StringTrim(TO_STRING_INLINE(this), true, true);
|
784
|
+
}
|
785
|
+
|
786
|
+
function StringTrimLeft() {
|
787
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
788
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
789
|
+
["String.prototype.trimLeft"]);
|
790
|
+
}
|
791
|
+
return %StringTrim(TO_STRING_INLINE(this), true, false);
|
792
|
+
}
|
793
|
+
|
794
|
+
function StringTrimRight() {
|
795
|
+
if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
796
|
+
throw MakeTypeError("called_on_null_or_undefined",
|
797
|
+
["String.prototype.trimRight"]);
|
798
|
+
}
|
799
|
+
return %StringTrim(TO_STRING_INLINE(this), false, true);
|
800
|
+
}
|
801
|
+
|
802
|
+
var static_charcode_array = new InternalArray(4);
|
803
|
+
|
804
|
+
// ECMA-262, section 15.5.3.2
|
805
|
+
function StringFromCharCode(code) {
|
806
|
+
var n = %_ArgumentsLength();
|
807
|
+
if (n == 1) {
|
808
|
+
if (!%_IsSmi(code)) code = ToNumber(code);
|
809
|
+
return %_StringCharFromCode(code & 0xffff);
|
810
|
+
}
|
811
|
+
|
812
|
+
// NOTE: This is not super-efficient, but it is necessary because we
|
813
|
+
// want to avoid converting to numbers from within the virtual
|
814
|
+
// machine. Maybe we can find another way of doing this?
|
815
|
+
var codes = static_charcode_array;
|
816
|
+
for (var i = 0; i < n; i++) {
|
817
|
+
var code = %_Arguments(i);
|
818
|
+
if (!%_IsSmi(code)) code = ToNumber(code);
|
819
|
+
codes[i] = code;
|
820
|
+
}
|
821
|
+
codes.length = n;
|
822
|
+
return %StringFromCharCodeArray(codes);
|
823
|
+
}
|
824
|
+
|
825
|
+
|
826
|
+
// Helper function for very basic XSS protection.
|
827
|
+
function HtmlEscape(str) {
|
828
|
+
return TO_STRING_INLINE(str).replace(/</g, "<")
|
829
|
+
.replace(/>/g, ">")
|
830
|
+
.replace(/"/g, """)
|
831
|
+
.replace(/'/g, "'");
|
832
|
+
};
|
833
|
+
|
834
|
+
|
835
|
+
// Compatibility support for KJS.
|
836
|
+
// Tested by mozilla/js/tests/js1_5/Regress/regress-276103.js.
|
837
|
+
function StringLink(s) {
|
838
|
+
return "<a href=\"" + HtmlEscape(s) + "\">" + this + "</a>";
|
839
|
+
}
|
840
|
+
|
841
|
+
|
842
|
+
function StringAnchor(name) {
|
843
|
+
return "<a name=\"" + HtmlEscape(name) + "\">" + this + "</a>";
|
844
|
+
}
|
845
|
+
|
846
|
+
|
847
|
+
function StringFontcolor(color) {
|
848
|
+
return "<font color=\"" + HtmlEscape(color) + "\">" + this + "</font>";
|
849
|
+
}
|
850
|
+
|
851
|
+
|
852
|
+
function StringFontsize(size) {
|
853
|
+
return "<font size=\"" + HtmlEscape(size) + "\">" + this + "</font>";
|
854
|
+
}
|
855
|
+
|
856
|
+
|
857
|
+
function StringBig() {
|
858
|
+
return "<big>" + this + "</big>";
|
859
|
+
}
|
860
|
+
|
861
|
+
|
862
|
+
function StringBlink() {
|
863
|
+
return "<blink>" + this + "</blink>";
|
864
|
+
}
|
865
|
+
|
866
|
+
|
867
|
+
function StringBold() {
|
868
|
+
return "<b>" + this + "</b>";
|
869
|
+
}
|
870
|
+
|
871
|
+
|
872
|
+
function StringFixed() {
|
873
|
+
return "<tt>" + this + "</tt>";
|
874
|
+
}
|
875
|
+
|
876
|
+
|
877
|
+
function StringItalics() {
|
878
|
+
return "<i>" + this + "</i>";
|
879
|
+
}
|
880
|
+
|
881
|
+
|
882
|
+
function StringSmall() {
|
883
|
+
return "<small>" + this + "</small>";
|
884
|
+
}
|
885
|
+
|
886
|
+
|
887
|
+
function StringStrike() {
|
888
|
+
return "<strike>" + this + "</strike>";
|
889
|
+
}
|
890
|
+
|
891
|
+
|
892
|
+
function StringSub() {
|
893
|
+
return "<sub>" + this + "</sub>";
|
894
|
+
}
|
895
|
+
|
896
|
+
|
897
|
+
function StringSup() {
|
898
|
+
return "<sup>" + this + "</sup>";
|
899
|
+
}
|
900
|
+
|
901
|
+
|
902
|
+
// ReplaceResultBuilder support.
|
903
|
+
function ReplaceResultBuilder(str) {
|
904
|
+
if (%_ArgumentsLength() > 1) {
|
905
|
+
this.elements = %_Arguments(1);
|
906
|
+
} else {
|
907
|
+
this.elements = new InternalArray();
|
908
|
+
}
|
909
|
+
this.special_string = str;
|
910
|
+
}
|
911
|
+
|
912
|
+
|
913
|
+
ReplaceResultBuilder.prototype.add = function(str) {
|
914
|
+
str = TO_STRING_INLINE(str);
|
915
|
+
if (str.length > 0) this.elements.push(str);
|
916
|
+
}
|
917
|
+
|
918
|
+
|
919
|
+
ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) {
|
920
|
+
var len = end - start;
|
921
|
+
if (start < 0 || len <= 0) return;
|
922
|
+
if (start < 0x80000 && len < 0x800) {
|
923
|
+
this.elements.push((start << 11) | len);
|
924
|
+
} else {
|
925
|
+
// 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength,
|
926
|
+
// so -len is a smi.
|
927
|
+
var elements = this.elements;
|
928
|
+
elements.push(-len);
|
929
|
+
elements.push(start);
|
930
|
+
}
|
931
|
+
}
|
932
|
+
|
933
|
+
|
934
|
+
ReplaceResultBuilder.prototype.generate = function() {
|
935
|
+
var elements = this.elements;
|
936
|
+
return %StringBuilderConcat(elements, elements.length, this.special_string);
|
937
|
+
}
|
938
|
+
|
939
|
+
|
940
|
+
// -------------------------------------------------------------------
|
941
|
+
|
942
|
+
function SetupString() {
|
943
|
+
// Setup the constructor property on the String prototype object.
|
944
|
+
%SetProperty($String.prototype, "constructor", $String, DONT_ENUM);
|
945
|
+
|
946
|
+
|
947
|
+
// Setup the non-enumerable functions on the String object.
|
948
|
+
InstallFunctions($String, DONT_ENUM, $Array(
|
949
|
+
"fromCharCode", StringFromCharCode
|
950
|
+
));
|
951
|
+
|
952
|
+
|
953
|
+
// Setup the non-enumerable functions on the String prototype object.
|
954
|
+
InstallFunctionsOnHiddenPrototype($String.prototype, DONT_ENUM, $Array(
|
955
|
+
"valueOf", StringValueOf,
|
956
|
+
"toString", StringToString,
|
957
|
+
"charAt", StringCharAt,
|
958
|
+
"charCodeAt", StringCharCodeAt,
|
959
|
+
"concat", StringConcat,
|
960
|
+
"indexOf", StringIndexOf,
|
961
|
+
"lastIndexOf", StringLastIndexOf,
|
962
|
+
"localeCompare", StringLocaleCompare,
|
963
|
+
"match", StringMatch,
|
964
|
+
"replace", StringReplace,
|
965
|
+
"search", StringSearch,
|
966
|
+
"slice", StringSlice,
|
967
|
+
"split", StringSplit,
|
968
|
+
"substring", StringSubstring,
|
969
|
+
"substr", StringSubstr,
|
970
|
+
"toLowerCase", StringToLowerCase,
|
971
|
+
"toLocaleLowerCase", StringToLocaleLowerCase,
|
972
|
+
"toUpperCase", StringToUpperCase,
|
973
|
+
"toLocaleUpperCase", StringToLocaleUpperCase,
|
974
|
+
"trim", StringTrim,
|
975
|
+
"trimLeft", StringTrimLeft,
|
976
|
+
"trimRight", StringTrimRight,
|
977
|
+
"link", StringLink,
|
978
|
+
"anchor", StringAnchor,
|
979
|
+
"fontcolor", StringFontcolor,
|
980
|
+
"fontsize", StringFontsize,
|
981
|
+
"big", StringBig,
|
982
|
+
"blink", StringBlink,
|
983
|
+
"bold", StringBold,
|
984
|
+
"fixed", StringFixed,
|
985
|
+
"italics", StringItalics,
|
986
|
+
"small", StringSmall,
|
987
|
+
"strike", StringStrike,
|
988
|
+
"sub", StringSub,
|
989
|
+
"sup", StringSup
|
990
|
+
));
|
991
|
+
}
|
992
|
+
|
993
|
+
|
994
|
+
SetupString();
|