MCPcopy
hub / github.com/mishoo/UglifyJS / scan_declaration

Function scan_declaration

lib/compress.js:862–949  ·  view source on GitHub ↗
(tw, compressor, lhs, fixed, visit)

Source from the content-addressed store, hash-verified

860 }
861
862 function scan_declaration(tw, compressor, lhs, fixed, visit) {
863 var scanner = new TreeWalker(function(node) {
864 if (node instanceof AST_DefaultValue) {
865 reset_flags(node);
866 push(tw, true, true);
867 node.value.walk(tw);
868 pop(tw);
869 var save = fixed;
870 if (save) fixed = make_fixed_default(compressor, node, save);
871 node.name.walk(scanner);
872 fixed = save;
873 return true;
874 }
875 if (node instanceof AST_DestructuredArray) {
876 reset_flags(node);
877 var save = fixed;
878 node.elements.forEach(function(node, index) {
879 if (node instanceof AST_Hole) return reset_flags(node);
880 if (save) fixed = make_fixed(save, function(value) {
881 return make_node(AST_Sub, node, {
882 expression: value,
883 property: make_node(AST_Number, node, { value: index }),
884 });
885 });
886 node.walk(scanner);
887 });
888 if (node.rest) {
889 var fixed_node;
890 if (save) fixed = compressor.option("rests") && make_fixed(save, function(value) {
891 if (!(value instanceof AST_Array)) return node;
892 for (var i = 0, len = node.elements.length; i < len; i++) {
893 if (value.elements[i] instanceof AST_Spread) return node;
894 }
895 if (!fixed_node) fixed_node = make_node(AST_Array, node, {});
896 fixed_node.elements = value.elements.slice(len);
897 return fixed_node;
898 });
899 node.rest.walk(scanner);
900 }
901 fixed = save;
902 return true;
903 }
904 if (node instanceof AST_DestructuredObject) {
905 reset_flags(node);
906 var save = fixed;
907 node.properties.forEach(function(node) {
908 reset_flags(node);
909 if (node.key instanceof AST_Node) {
910 push(tw);
911 node.key.walk(tw);
912 pop(tw);
913 }
914 if (save) fixed = make_fixed(save, function(value) {
915 var key = node.key;
916 var type = AST_Sub;
917 if (typeof key == "string") {
918 if (is_identifier_string(key)) {
919 type = AST_Dot;

Callers 3

reduce_iifeFunction · 0.85
walk_assignFunction · 0.85
walk_defnFunction · 0.85

Calls 9

reset_flagsFunction · 0.85
pushFunction · 0.85
popFunction · 0.85
make_fixed_defaultFunction · 0.85
make_fixedFunction · 0.85
make_nodeFunction · 0.85
is_identifier_stringFunction · 0.85
make_node_from_constantFunction · 0.85
visitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…