Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
977290c7e4 | ||
|
|
ebbdb95278 | ||
|
|
9b586c7587 | ||
|
|
4b5ba6c8c6 | ||
|
|
67efb1b427 | ||
|
|
bc9c1ab61e | ||
|
|
9f037fa75e | ||
|
|
8681a78618 | ||
|
|
2d72d423b3 | ||
|
|
280964eafe | ||
|
|
d71c72de3c | ||
|
|
b1c21b8d4d | ||
|
|
e9b0005cf5 | ||
|
|
d0b6aa9882 | ||
|
|
0e877acfdf | ||
|
|
b670ee18df | ||
|
|
24807120bf | ||
|
|
33f7c0b67e | ||
|
|
c23b47f796 | ||
|
|
2871d8a710 | ||
|
|
3172b5de5d | ||
|
|
2c05303813 | ||
|
|
75dda10057 | ||
|
|
581f70c803 | ||
|
|
a00d2c33d8 | ||
|
|
27fc574e9f | ||
|
|
a3b1fcc79c | ||
|
|
491cb26c1f | ||
|
|
7c3d052714 | ||
|
|
4971d0c7f0 | ||
|
|
eb4922b1ec | ||
|
|
bb26183b44 | ||
|
|
4b066f7f1b | ||
|
|
3cd110a7c9 | ||
|
|
a7f9e035a4 | ||
|
|
146b9e6708 |
41
CHANGELOG.md
41
CHANGELOG.md
@@ -13,6 +13,47 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.7.13
|
||||
|
||||
* **Bug Fix**
|
||||
* Handle comments on use strict directives.
|
||||
* Fix assignment patterns with a left side pattern.
|
||||
* **Polish**
|
||||
* Special case `this` when doing expression memoisation.
|
||||
|
||||
## 4.7.12
|
||||
|
||||
* **Bug Fix**
|
||||
* Deprecate `playground.methodBinding`.
|
||||
|
||||
## 4.7.11
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix unicode regexes stripping their unicode flag before being passed on two `regexpu`.
|
||||
|
||||
## 4.7.10
|
||||
|
||||
* **Internal**
|
||||
* Deprecate `playground.methodBinding` and `playground.objectGetterMemoization`.
|
||||
* **Bug Fix**
|
||||
* Fix `inputSourceMap` option. Thanks [@Rich-Harris](https://github.com/Rich-Harris)!
|
||||
|
||||
## 4.7.9
|
||||
|
||||
* **Polish**
|
||||
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
|
||||
* Infer computed literal property names.
|
||||
* **Bug Fix**
|
||||
* Fix nested labeled for-ofs.
|
||||
* Fix block scoping `break` colliding with the parent switch case.
|
||||
* **Internal**
|
||||
* Upgrade `acorn-babel`.
|
||||
|
||||
## 4.7.8
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix computed classes not properly setting symbols.
|
||||
|
||||
## 4.7.7
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
380
bin/babel-node
380
bin/babel-node
@@ -36,16 +36,380 @@ babelArgs.forEach(function(arg){
|
||||
args.unshift("--expose-gc");
|
||||
break;
|
||||
|
||||
case "--gc-global":
|
||||
case "--use_strict":
|
||||
case "--es_staging":
|
||||
case "--harmony":
|
||||
case "--harmony-proxies":
|
||||
case "--harmony-collections":
|
||||
case "--harmony-generators":
|
||||
case "--no-deprecation":
|
||||
case "--harmony_shipping":
|
||||
case "--harmony_modules":
|
||||
case "--harmony_arrays":
|
||||
case "--harmony_array_includes":
|
||||
case "--harmony_regexps":
|
||||
case "--harmony_arrow_functions":
|
||||
case "--harmony_proxies":
|
||||
case "--harmony_sloppy":
|
||||
case "--harmony_unicode":
|
||||
case "--harmony_tostring":
|
||||
case "--harmony_numeric_literals":
|
||||
case "--harmony_strings":
|
||||
case "--harmony_scoping":
|
||||
case "--harmony_classes":
|
||||
case "--harmony_object_literals":
|
||||
case "--harmony_templates":
|
||||
case "--compiled_keyed_generic_loads":
|
||||
case "--pretenuring_call_new":
|
||||
case "--allocation_site_pretenuring":
|
||||
case "--trace_pretenuring":
|
||||
case "--trace_pretenuring_statistics":
|
||||
case "--track_fields":
|
||||
case "--track_double_fields":
|
||||
case "--track_heap_object_fields":
|
||||
case "--track_computed_fields":
|
||||
case "--track_field_types":
|
||||
case "--smi_binop":
|
||||
case "--vector_ics":
|
||||
case "--optimize_for_size":
|
||||
case "--unbox_double_arrays":
|
||||
case "--string_slices":
|
||||
case "--crankshaft":
|
||||
case "--hydrogen_filter":
|
||||
case "--use_gvn":
|
||||
case "--gvn_iterations":
|
||||
case "--use_canonicalizing":
|
||||
case "--use_inlining":
|
||||
case "--use_escape_analysis":
|
||||
case "--use_allocation_folding":
|
||||
case "--use_local_allocation_folding":
|
||||
case "--use_write_barrier_elimination":
|
||||
case "--max_inlining_levels":
|
||||
case "--max_inlined_source_size":
|
||||
case "--max_inlined_nodes":
|
||||
case "--max_inlined_nodes_cumulative":
|
||||
case "--loop_invariant_code_motion":
|
||||
case "--fast_math":
|
||||
case "--collect_megamorphic_maps_from_stub_cache":
|
||||
case "--hydrogen_stats":
|
||||
case "--trace_check_elimination":
|
||||
case "--trace_hydrogen":
|
||||
case "--trace_hydrogen_filter":
|
||||
case "--trace_hydrogen_stubs":
|
||||
case "--trace_hydrogen_file":
|
||||
case "--trace_phase":
|
||||
case "--trace_inlining":
|
||||
case "--trace_load_elimination":
|
||||
case "--trace_store_elimination":
|
||||
case "--trace_alloc":
|
||||
case "--trace_all_uses":
|
||||
case "--trace_range":
|
||||
case "--trace_gvn":
|
||||
case "--trace_representation":
|
||||
case "--trace_removable_simulates":
|
||||
case "--trace_escape_analysis":
|
||||
case "--trace_allocation_folding":
|
||||
case "--trace_track_allocation_sites":
|
||||
case "--trace_migration":
|
||||
case "--trace_generalization":
|
||||
case "--stress_pointer_maps":
|
||||
case "--stress_environments":
|
||||
case "--deopt_every_n_times":
|
||||
case "--deopt_every_n_garbage_collections":
|
||||
case "--print_deopt_stress":
|
||||
case "--trap_on_deopt":
|
||||
case "--trap_on_stub_deopt":
|
||||
case "--deoptimize_uncommon_cases":
|
||||
case "--polymorphic_inlining":
|
||||
case "--use_osr":
|
||||
case "--array_bounds_checks_elimination":
|
||||
case "--trace_bce":
|
||||
case "--array_bounds_checks_hoisting":
|
||||
case "--array_index_dehoisting":
|
||||
case "--analyze_environment_liveness":
|
||||
case "--load_elimination":
|
||||
case "--check_elimination":
|
||||
case "--store_elimination":
|
||||
case "--dead_code_elimination":
|
||||
case "--fold_constants":
|
||||
case "--trace_dead_code_elimination":
|
||||
case "--unreachable_code_elimination":
|
||||
case "--trace_osr":
|
||||
case "--stress_runs":
|
||||
case "--lookup_sample_by_shared":
|
||||
case "--cache_optimized_code":
|
||||
case "--flush_optimized_code_cache":
|
||||
case "--inline_construct":
|
||||
case "--inline_arguments":
|
||||
case "--inline_accessors":
|
||||
case "--escape_analysis_iterations":
|
||||
case "--optimize_for_in":
|
||||
case "--concurrent_recompilation":
|
||||
case "--job_based_recompilation":
|
||||
case "--trace_concurrent_recompilation":
|
||||
case "--concurrent_recompilation_queue_length":
|
||||
case "--concurrent_recompilation_delay":
|
||||
case "--block_concurrent_recompilation":
|
||||
case "--concurrent_osr":
|
||||
case "--omit_map_checks_for_leaf_maps":
|
||||
case "--turbo_filter":
|
||||
case "--trace_turbo":
|
||||
case "--trace_turbo_graph":
|
||||
case "--trace_turbo_cfg_file":
|
||||
case "--trace_turbo_types":
|
||||
case "--trace_turbo_scheduler":
|
||||
case "--trace_turbo_reduction":
|
||||
case "--trace_turbo_jt":
|
||||
case "--turbo_asm":
|
||||
case "--turbo_verify":
|
||||
case "--turbo_stats":
|
||||
case "--turbo_types":
|
||||
case "--turbo_source_positions":
|
||||
case "--context_specialization":
|
||||
case "--turbo_deoptimization":
|
||||
case "--turbo_inlining":
|
||||
case "--turbo_inlining_intrinsics":
|
||||
case "--trace_turbo_inlining":
|
||||
case "--loop_assignment_analysis":
|
||||
case "--turbo_profiling":
|
||||
case "--turbo_reuse_spill_slots":
|
||||
case "--turbo_delay_ssa_decon":
|
||||
case "--turbo_move_optimization":
|
||||
case "--turbo_jt":
|
||||
case "--typed_array_max_size_in_heap":
|
||||
case "--frame_count":
|
||||
case "--interrupt_budget":
|
||||
case "--type_info_threshold":
|
||||
case "--generic_ic_threshold":
|
||||
case "--self_opt_count":
|
||||
case "--trace_opt_verbose":
|
||||
case "--debug_code":
|
||||
case "--code_comments":
|
||||
case "--enable_sse3":
|
||||
case "--enable_sse4_1":
|
||||
case "--enable_sahf":
|
||||
case "--enable_avx":
|
||||
case "--enable_fma3":
|
||||
case "--enable_vfp3":
|
||||
case "--enable_armv7":
|
||||
case "--enable_armv8":
|
||||
case "--enable_neon":
|
||||
case "--enable_sudiv":
|
||||
case "--enable_mls":
|
||||
case "--enable_movw_movt":
|
||||
case "--enable_unaligned_accesses":
|
||||
case "--enable_32dregs":
|
||||
case "--enable_vldr_imm":
|
||||
case "--force_long_branches":
|
||||
case "--expose_natives_as":
|
||||
case "--expose_debug_as":
|
||||
case "--expose_free_buffer":
|
||||
case "--expose_gc":
|
||||
case "--expose_gc_as":
|
||||
case "--expose_externalize_string":
|
||||
case "--expose_trigger_failure":
|
||||
case "--stack_trace_limit":
|
||||
case "--builtins_in_stack_traces":
|
||||
case "--disable_native_files":
|
||||
case "--inline_new":
|
||||
case "--trace_codegen":
|
||||
case "--trace":
|
||||
case "--mask_constants_with_cookie":
|
||||
case "--lazy":
|
||||
case "--trace_opt":
|
||||
case "--trace_opt_stats":
|
||||
case "--opt":
|
||||
case "--always_opt":
|
||||
case "--always_osr":
|
||||
case "--prepare_always_opt":
|
||||
case "--trace_deopt":
|
||||
case "--trace_stub_failures":
|
||||
case "--serialize_toplevel":
|
||||
case "--serialize_inner":
|
||||
case "--trace_serializer":
|
||||
case "--min_preparse_length":
|
||||
case "--max_opt_count":
|
||||
case "--compilation_cache":
|
||||
case "--cache_prototype_transitions":
|
||||
case "--cpu_profiler_sampling_interval":
|
||||
case "--trace_debug_json":
|
||||
case "--trace_js_array_abuse":
|
||||
case "--trace_external_array_abuse":
|
||||
case "--trace_array_abuse":
|
||||
case "--enable_liveedit":
|
||||
case "--hard_abort":
|
||||
case "--stack_size":
|
||||
case "--max_stack_trace_source_length":
|
||||
case "--always_inline_smi_code":
|
||||
case "--min_semi_space_size":
|
||||
case "--target_semi_space_size":
|
||||
case "--max_semi_space_size":
|
||||
case "--semi_space_growth_factor":
|
||||
case "--experimental_new_space_growth_heuristic":
|
||||
case "--max_old_space_size":
|
||||
case "--initial_old_space_size":
|
||||
case "--max_executable_size":
|
||||
case "--gc_global":
|
||||
case "--gc_interval":
|
||||
case "--trace_gc":
|
||||
case "--trace_gc_nvp":
|
||||
case "--trace_gc_ignore_scavenger":
|
||||
case "--trace_idle_notification":
|
||||
case "--trace_idle_notification_verbose":
|
||||
case "--print_cumulative_gc_stat":
|
||||
case "--print_max_heap_committed":
|
||||
case "--trace_gc_verbose":
|
||||
case "--trace_fragmentation":
|
||||
case "--collect_maps":
|
||||
case "--weak_embedded_maps_in_optimized_code":
|
||||
case "--weak_embedded_objects_in_optimized_code":
|
||||
case "--flush_code":
|
||||
case "--flush_code_incrementally":
|
||||
case "--trace_code_flushing":
|
||||
case "--age_code":
|
||||
case "--incremental_marking":
|
||||
case "--incremental_marking_steps":
|
||||
case "--concurrent_sweeping":
|
||||
case "--trace_incremental_marking":
|
||||
case "--track_gc_object_stats":
|
||||
case "--heap_profiler_trace_objects":
|
||||
case "--use_idle_notification":
|
||||
case "--use_ic":
|
||||
case "--trace_ic":
|
||||
case "--native_code_counters":
|
||||
case "--always_compact":
|
||||
case "--never_compact":
|
||||
case "--compact_code_space":
|
||||
case "--incremental_code_compaction":
|
||||
case "--cleanup_code_caches_at_gc":
|
||||
case "--use_marking_progress_bar":
|
||||
case "--zap_code_space":
|
||||
case "--random_seed":
|
||||
case "--trace_weak_arrays":
|
||||
case "--track_prototype_users":
|
||||
case "--use_verbose_printer":
|
||||
case "--allow_natives_syntax":
|
||||
case "--trace_parse":
|
||||
case "--trace_sim":
|
||||
case "--debug_sim":
|
||||
case "--check_icache":
|
||||
case "--stop_sim_at":
|
||||
case "--sim_stack_alignment":
|
||||
case "--sim_stack_size":
|
||||
case "--log_regs_modified":
|
||||
case "--log_colour":
|
||||
case "--ignore_asm_unimplemented_break":
|
||||
case "--trace_sim_messages":
|
||||
case "--stack_trace_on_illegal":
|
||||
case "--abort_on_uncaught_exception":
|
||||
case "--randomize_hashes":
|
||||
case "--hash_seed":
|
||||
case "--profile_deserialization":
|
||||
case "--regexp_optimization":
|
||||
case "--testing_bool_flag":
|
||||
case "--testing_maybe_bool_flag":
|
||||
case "--testing_int_flag":
|
||||
case "--testing_float_flag":
|
||||
case "--testing_string_flag":
|
||||
case "--testing_prng_seed":
|
||||
case "--testing_serialization_file":
|
||||
case "--startup_blob":
|
||||
case "--profile_hydrogen_code_stub_compilation":
|
||||
case "--predictable":
|
||||
case "--help":
|
||||
case "--dump_counters":
|
||||
case "--debugger":
|
||||
case "--map_counters":
|
||||
case "--js_arguments":
|
||||
case "--gdbjit":
|
||||
case "--gdbjit_full":
|
||||
case "--gdbjit_dump":
|
||||
case "--gdbjit_dump_filter":
|
||||
case "--force_marking_deque_overflows":
|
||||
case "--stress_compaction":
|
||||
case "--log":
|
||||
case "--log_all":
|
||||
case "--log_api":
|
||||
case "--log_code":
|
||||
case "--log_gc":
|
||||
case "--log_handles":
|
||||
case "--log_snapshot_positions":
|
||||
case "--log_suspect":
|
||||
case "--prof":
|
||||
case "--throw-deprecation":
|
||||
case "--trace-deprecation":
|
||||
case "--use-strict":
|
||||
case "--prof_browser_mode":
|
||||
case "--log_regexp":
|
||||
case "--logfile":
|
||||
case "--logfile_per_isolate":
|
||||
case "--ll_prof":
|
||||
case "--perf_basic_prof":
|
||||
case "--perf_jit_prof":
|
||||
case "--gc_fake_mmap":
|
||||
case "--log_internal_timer_events":
|
||||
case "--log_timer_events":
|
||||
case "--log_instruction_stats":
|
||||
case "--log_instruction_file":
|
||||
case "--log_instruction_period":
|
||||
case "--redirect_code_traces":
|
||||
case "--redirect_code_traces_to":
|
||||
case "--hydrogen_track_positions":
|
||||
case "--trace_elements_transitions":
|
||||
case "--trace_creation_allocation_sites":
|
||||
case "--print_code_stubs":
|
||||
case "--test_secondary_stub_cache":
|
||||
case "--test_primary_stub_cache":
|
||||
case "--print_code":
|
||||
case "--print_opt_code":
|
||||
case "--print_unopt_code":
|
||||
case "--print_code_verbose":
|
||||
case "--print_builtin_code":
|
||||
case "--sodium":
|
||||
case "--print_all_code":
|
||||
case "--es5_readonly":
|
||||
case "--es52_globals":
|
||||
case "--harmony_typeof":
|
||||
case "--harmony_collections":
|
||||
case "--packed_arrays":
|
||||
case "--smi_only_arrays":
|
||||
case "--clever_optimizations":
|
||||
case "--use_range":
|
||||
case "--eliminate_dead_phis":
|
||||
case "--optimize_closures":
|
||||
case "--loop_weight":
|
||||
case "--opt_safe_uint32_operations":
|
||||
case "--parallel_recompilation":
|
||||
case "--trace_parallel_recompilation":
|
||||
case "--parallel_recompilation_queue_length":
|
||||
case "--experimental_profiler":
|
||||
case "--watch_ic_patching":
|
||||
case "--self_optimization":
|
||||
case "--direct_self_opt":
|
||||
case "--retry_self_opt":
|
||||
case "--count_based_interrupts":
|
||||
case "--interrupt_at_exit":
|
||||
case "--weighted_back_edges":
|
||||
case "--debug_code (generate extra code":
|
||||
case "--enable_sse2":
|
||||
case "--enable_cmov":
|
||||
case "--enable_rdtsc":
|
||||
case "--enable_vfp2":
|
||||
case "--enable_fpu":
|
||||
case "--stack_trace_on_abort":
|
||||
case "--always_full_compiler":
|
||||
case "--debugger_auto_break":
|
||||
case "--break_on_abort":
|
||||
case "--max_new_space_size":
|
||||
case "--trace_external_memory":
|
||||
case "--lazy_sweeping":
|
||||
case "--trace_exception":
|
||||
case "--preallocate_message_memory":
|
||||
case "--preemption":
|
||||
case "--extra_code":
|
||||
case "--remote_debugger":
|
||||
case "--debugger_agent":
|
||||
case "--debugger_port":
|
||||
case "--debug_compile_events":
|
||||
case "--debug_script_collected_events":
|
||||
case "--gdbjit":
|
||||
case "--log_runtime":
|
||||
case "--prof_auto":
|
||||
case "--prof_lazy":
|
||||
case "--sliding_state_window":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.7.8",
|
||||
"version": "4.7.13",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -36,7 +36,7 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-babel": "0.11.1-37",
|
||||
"acorn-babel": "0.11.1-38",
|
||||
"ast-types": "~0.7.0",
|
||||
"chalk": "^1.0.0",
|
||||
"chokidar": "^0.12.6",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.7.7",
|
||||
"version": "4.7.12",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
|
||||
@@ -139,7 +139,7 @@ export default class File {
|
||||
returnUsedHelpers: false,
|
||||
externalHelpers: false,
|
||||
auxilaryComment: "",
|
||||
inputSourceMap: false,
|
||||
inputSourceMap: null,
|
||||
experimental: false,
|
||||
reactCompat: false,
|
||||
playground: false,
|
||||
@@ -280,10 +280,12 @@ export default class File {
|
||||
parseInputSourceMap(code: string) {
|
||||
var opts = this.opts;
|
||||
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
if (opts.inputSourceMap !== false) {
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
||||
@@ -111,7 +111,7 @@ export function bare(node, parent, scope) {
|
||||
if (node.id) return node;
|
||||
|
||||
var id;
|
||||
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
|
||||
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
|
||||
// { foo() {} };
|
||||
id = parent.key;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
@@ -121,9 +121,16 @@ export function bare(node, parent, scope) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (!t.isIdentifier(id)) return node;
|
||||
var name;
|
||||
if (t.isLiteral(id)) {
|
||||
name = id.value;
|
||||
} else if (t.isIdentifier(id)) {
|
||||
name = id.name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = t.toIdentifier(id.name);
|
||||
name = t.toIdentifier(name);
|
||||
id = t.identifier(name);
|
||||
|
||||
var state = visit(node, name, scope);
|
||||
|
||||
@@ -7,7 +7,7 @@ export function is(node, flag) {
|
||||
|
||||
export function pullFlag(node, flag) {
|
||||
var flags = node.regex.flags.split("");
|
||||
if (node.regex.flags.indexOf("u") < 0) return;
|
||||
pull(flags, "u");
|
||||
if (node.regex.flags.indexOf(flag) < 0) return;
|
||||
pull(flags, flag);
|
||||
node.regex.flags = flags.join("");
|
||||
}
|
||||
|
||||
@@ -69,8 +69,9 @@ export function Loop(node, parent, scope, file) {
|
||||
t.ensureBlock(node);
|
||||
node.body._letDeclarators = [init];
|
||||
}
|
||||
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
|
||||
blockScoping.run();
|
||||
|
||||
var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
|
||||
return blockScoping.run();
|
||||
}
|
||||
|
||||
export function BlockStatement(block, parent, scope, file) {
|
||||
@@ -224,17 +225,22 @@ class BlockScoping {
|
||||
* Description
|
||||
*/
|
||||
|
||||
constructor(loopParent?: Object, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.loopParent = loopParent;
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
constructor(loopPath?: TraversalPath, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
|
||||
this.outsideLetReferences = object();
|
||||
this.hasLetReferences = false;
|
||||
this.letReferences = block._letReferences = object();
|
||||
this.body = [];
|
||||
|
||||
if (loopPath) {
|
||||
this.loopParent = loopPath.parent;
|
||||
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
|
||||
this.loop = loopPath.node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +265,10 @@ class BlockScoping {
|
||||
} else {
|
||||
this.remap();
|
||||
}
|
||||
|
||||
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
|
||||
return t.labeledStatement(this.loopLabel, this.loop);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,11 +307,11 @@ class BlockScoping {
|
||||
|
||||
//
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
if (loopParent) {
|
||||
traverseReplace(loopParent.right, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.test, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.update, loopParent, scope, remaps);
|
||||
var loop = this.loop;
|
||||
if (loop) {
|
||||
traverseReplace(loop.right, loop, scope, remaps);
|
||||
traverseReplace(loop.test, loop, scope, remaps);
|
||||
traverseReplace(loop.update, loop, scope, remaps);
|
||||
}
|
||||
|
||||
scope.traverse(this.block, replaceVisitor, remaps);
|
||||
@@ -317,7 +327,7 @@ class BlockScoping {
|
||||
var outsideRefs = this.outsideLetReferences;
|
||||
|
||||
// remap loop heads with colliding variables
|
||||
if (this.loopParent) {
|
||||
if (this.loop) {
|
||||
for (var name in outsideRefs) {
|
||||
var id = outsideRefs[name];
|
||||
|
||||
@@ -438,7 +448,7 @@ class BlockScoping {
|
||||
ignoreLabeless: false,
|
||||
innerLabels: [],
|
||||
hasReturn: false,
|
||||
isLoop: !!this.loopParent,
|
||||
isLoop: !!this.loop,
|
||||
map: {}
|
||||
};
|
||||
|
||||
@@ -504,7 +514,7 @@ class BlockScoping {
|
||||
t.variableDeclarator(ret, call)
|
||||
]));
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
var loop = this.loop;
|
||||
var retCheck;
|
||||
var has = this.has;
|
||||
var cases = [];
|
||||
@@ -517,9 +527,8 @@ class BlockScoping {
|
||||
}
|
||||
|
||||
if (has.hasBreakContinue) {
|
||||
if (!loopParent) {
|
||||
throw new Error("Has no loop parent but we're trying to reassign breaks " +
|
||||
"and continues, something is going wrong here.");
|
||||
if (!loop) {
|
||||
throw new Error("Aren't in a loop and we're trying to reassign breaks and continues, something is going wrong here.");
|
||||
}
|
||||
|
||||
for (var key in has.map) {
|
||||
@@ -537,6 +546,14 @@ class BlockScoping {
|
||||
single.consequent[0]
|
||||
)));
|
||||
} else {
|
||||
// #998
|
||||
for (var i = 0; i < cases.length; i++) {
|
||||
var caseConsequent = cases[i].consequent[0];
|
||||
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
|
||||
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
|
||||
}
|
||||
}
|
||||
|
||||
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -290,14 +290,21 @@ class DestructuringTransformer {
|
||||
|
||||
//
|
||||
|
||||
this.nodes.push(this.buildVariableAssignment(
|
||||
pattern.left,
|
||||
t.conditionalExpression(
|
||||
t.binaryExpression("===", tempValueRef, t.identifier("undefined")),
|
||||
pattern.right,
|
||||
tempValueRef
|
||||
)
|
||||
));
|
||||
var tempConditional = t.conditionalExpression(
|
||||
t.binaryExpression("===", tempValueRef, t.identifier("undefined")),
|
||||
pattern.right,
|
||||
tempValueRef
|
||||
);
|
||||
|
||||
var left = pattern.left;
|
||||
if (t.isPattern(left)) {
|
||||
this.nodes.push(t.expressionStatement(
|
||||
t.assignmentExpression("=", tempValueRef, tempConditional)
|
||||
));
|
||||
this.push(left, tempValueRef);
|
||||
} else {
|
||||
this.nodes.push(this.buildVariableAssignment(left, tempConditional));
|
||||
}
|
||||
}
|
||||
|
||||
pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) {
|
||||
|
||||
@@ -32,11 +32,8 @@ export function ForOfStatement(node, parent, scope, file) {
|
||||
// todo: find out why this is necessary? #538
|
||||
loop._scopeInfo = node._scopeInfo;
|
||||
|
||||
if (build.replaceParent) {
|
||||
this.parentPath.node = build.node;
|
||||
} else {
|
||||
return build.node;
|
||||
}
|
||||
if (build.replaceParent) this.parentPath.node = build.node;
|
||||
return build.node;
|
||||
}
|
||||
|
||||
var loose = function (node, parent, scope, file) {
|
||||
|
||||
@@ -7,6 +7,6 @@ export function check(node) {
|
||||
|
||||
export function Literal(node) {
|
||||
if (!regex.is(node, "u")) return;
|
||||
regex.pullFlag(node, "y");
|
||||
node.regex.pattern = rewritePattern(node.regex.pattern, node.regex.flags);
|
||||
regex.pullFlag(node, "u");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,17 @@ import * as t from "../../../types";
|
||||
|
||||
export function Program(program, parent, scope, file) {
|
||||
if (file.transformers.strict.canRun()) {
|
||||
program.body.unshift(t.expressionStatement(t.literal("use strict")));
|
||||
var directive = file.get("existingStrictDirective");
|
||||
|
||||
if (!directive) {
|
||||
directive = t.expressionStatement(t.literal("use strict"));
|
||||
var first = program.body[0];
|
||||
if (first) {
|
||||
directive.leadingComments = first.leadingComments;
|
||||
first.leadingComments = [];
|
||||
}
|
||||
}
|
||||
|
||||
program.body.unshift(directive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as messages from "../../../messages";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Program(program) {
|
||||
export function Program(program, parent, scope, file) {
|
||||
var first = program.body[0];
|
||||
if (t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" })) {
|
||||
program.body.shift();
|
||||
file.set("existingStrictDirective", program.body.shift());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import * as t from "../../../types";
|
||||
export var playground = true;
|
||||
|
||||
export function BindMemberExpression(node, parent, scope) {
|
||||
console.error("Method binding is deprecated and will be removed in 5.0.0");
|
||||
|
||||
var object = node.object;
|
||||
var prop = node.property;
|
||||
|
||||
@@ -25,6 +27,8 @@ export function BindMemberExpression(node, parent, scope) {
|
||||
}
|
||||
|
||||
export function BindFunctionExpression(node, parent, scope) {
|
||||
console.error("Method binding is deprecated and will be removed in 5.0.0");
|
||||
|
||||
var buildCall = function (args) {
|
||||
var param = scope.generateUidIdentifier("val");
|
||||
return t.functionExpression(null, [param], t.blockStatement([
|
||||
|
||||
@@ -20,6 +20,8 @@ export function MethodDefinition(node, parent, scope, file) {
|
||||
if (node.kind !== "memo") return;
|
||||
node.kind = "get";
|
||||
|
||||
console.error("Object getter memoization is deprecated and will be removed in 5.0.0");
|
||||
|
||||
var value = node.value;
|
||||
t.ensureBlock(value);
|
||||
|
||||
|
||||
@@ -174,6 +174,10 @@ export default class Scope {
|
||||
*/
|
||||
|
||||
generateTempBasedOnNode(node: Object): ?Object {
|
||||
if (t.isThisExpression(node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (t.isIdentifier(node) && this.hasBinding(node.name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
(function () {
|
||||
for (var i in nums) {
|
||||
_loop: for (var i in nums) {
|
||||
var _ret = (function (i) {
|
||||
fns.push(function () {
|
||||
return i;
|
||||
@@ -22,7 +22,7 @@
|
||||
continue;
|
||||
|
||||
case "break":
|
||||
break;
|
||||
break _loop;
|
||||
|
||||
default:
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// opt
|
||||
"use strict";
|
||||
|
||||
// opt
|
||||
var a = 1;
|
||||
var b = 2;
|
||||
var a = 1;
|
||||
|
||||
2
test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var z = {};
|
||||
var { x: { y } = {} } = z;
|
||||
6
test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/expected.js
vendored
Normal file
6
test/fixtures/transformation/es6-destructuring/assignment-expression-pattern/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var z = {};
|
||||
var _z$x = z.x;
|
||||
_z$x = _z$x === undefined ? {} : _z$x;
|
||||
var y = _z$x.y;
|
||||
5
test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js
vendored
Normal file
5
test/fixtures/transformation/es6-for-of/nested-label-for-of/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
b: for (let c of d()) {
|
||||
for (let e of f()) {
|
||||
continue b;
|
||||
}
|
||||
}
|
||||
48
test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js
vendored
Normal file
48
test/fixtures/transformation/es6-for-of/nested-label-for-of/expected.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
b: for (var _iterator = d()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var c = _step.value;
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = f()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var e = _step2.value;
|
||||
|
||||
continue b;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2["return"]) {
|
||||
_iterator2["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator["return"]) {
|
||||
_iterator["return"]();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var string = "foo💩bar";
|
||||
var match = string.match(/foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);
|
||||
var match = string.match(/foo((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))bar/);
|
||||
|
||||
6
test/fixtures/transformation/es6-spread/this-context/actual.js
vendored
Normal file
6
test/fixtures/transformation/es6-spread/this-context/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var obj = {
|
||||
foo: function foo() {
|
||||
this.bar(...arguments)
|
||||
this.blah(...arguments)
|
||||
}
|
||||
}
|
||||
8
test/fixtures/transformation/es6-spread/this-context/expected.js
vendored
Normal file
8
test/fixtures/transformation/es6-spread/this-context/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var obj = {
|
||||
foo: function foo() {
|
||||
this.bar.apply(this, arguments);
|
||||
this.blah.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
// we need to deopt `test` if it's reassigned as we can't be certain of it's
|
||||
// state, ie. it could have been rebound or dereferenced
|
||||
|
||||
"use strict";
|
||||
|
||||
function test(exit) {
|
||||
if (exit) {
|
||||
return this.x;
|
||||
|
||||
4
test/fixtures/transformation/strict/leading-comments-with-existing/actual.js
vendored
Normal file
4
test/fixtures/transformation/strict/leading-comments-with-existing/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// comments
|
||||
"use strict";
|
||||
|
||||
module.exports = {};
|
||||
4
test/fixtures/transformation/strict/leading-comments-with-existing/expected.js
vendored
Normal file
4
test/fixtures/transformation/strict/leading-comments-with-existing/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// comments
|
||||
"use strict";
|
||||
|
||||
module.exports = {};
|
||||
3
test/fixtures/transformation/strict/leading-comments/actual.js
vendored
Normal file
3
test/fixtures/transformation/strict/leading-comments/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// comments
|
||||
|
||||
module.exports = {};
|
||||
5
test/fixtures/transformation/strict/leading-comments/expected.js
vendored
Normal file
5
test/fixtures/transformation/strict/leading-comments/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// comments
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {};
|
||||
Reference in New Issue
Block a user