| | | |
Offset 33911, 204 lines modified | Offset 33911, 197 lines modified |
| |
33911 | var·errors·=·{}; | 33911 | var·errors·=·{}; |
| |
33912 | var·codegen·=·{}; | 33912 | var·codegen·=·{}; |
| |
33913 | var·code$1·=·{}; | 33913 | var·code$1·=·{}; |
| |
33914 | var·hasRequiredCode$1; | |
| |
33915 | function·requireCode$1()·{ | |
33916 | ····if·(hasRequiredCode$1)·return·code$1; | |
33917 | ····hasRequiredCode$1·=·1; | |
33918 | ····(function(exports)·{ | 33914 | (function(exports)·{ |
33919 | ········Object.defineProperty(exports,·"__esModule",·{ | 33915 | ····Object.defineProperty(exports,·"__esModule",·{ |
33920 | ············value:·true | 33916 | ········value:·true |
33921 | ········}); | 33917 | ····}); |
33922 | ········exports.regexpCode·=·exports.getEsmExportName·=·exports.getProperty·=·exports.safeStringify·=·exports.stringify·=·exports.strConcat·=·exports.addCodeArg·=·exports.str·=·exports._·=·exports.nil·=·exports._Code·=·exports.Name·=·exports.IDENTIFIER·=·exports._CodeOrName·=·void·0; | 33918 | ····exports.regexpCode·=·exports.getEsmExportName·=·exports.getProperty·=·exports.safeStringify·=·exports.stringify·=·exports.strConcat·=·exports.addCodeArg·=·exports.str·=·exports._·=·exports.nil·=·exports._Code·=·exports.Name·=·exports.IDENTIFIER·=·exports._CodeOrName·=·void·0; |
33923 | ········class·_CodeOrName·{} | 33919 | ····class·_CodeOrName·{} |
33924 | ········exports._CodeOrName·=·_CodeOrName; | 33920 | ····exports._CodeOrName·=·_CodeOrName; |
33925 | ········exports.IDENTIFIER·=·/^[a-z$_][a-z$_0-9]*$/i; | 33921 | ····exports.IDENTIFIER·=·/^[a-z$_][a-z$_0-9]*$/i; |
33926 | ········class·Name·extends·_CodeOrName·{ | 33922 | ····class·Name·extends·_CodeOrName·{ |
33927 | ············constructor(s)·{ | 33923 | ········constructor(s)·{ |
33928 | ················super(); | 33924 | ············super(); |
33929 | ················if·(!exports.IDENTIFIER.test(s)) | 33925 | ············if·(!exports.IDENTIFIER.test(s)) |
33930 | ····················throw·new·Error("CodeGen:·name·must·be·a·valid·identifier"); | 33926 | ················throw·new·Error("CodeGen:·name·must·be·a·valid·identifier"); |
33931 | ················this.str·=·s; | 33927 | ············this.str·=·s; |
| 33928 | ········} |
| 33929 | ········toString()·{ |
| 33930 | ············return·this.str; |
| 33931 | ········} |
| 33932 | ········emptyStr()·{ |
| 33933 | ············return·false; |
| 33934 | ········} |
| 33935 | ········get·names()·{ |
| 33936 | ············return·{ |
| 33937 | ················[this.str]:·1 |
33932 | ············} | 33938 | ············}; |
| 33939 | ········} |
| 33940 | ····} |
| 33941 | ····exports.Name·=·Name; |
| 33942 | ····class·_Code·extends·_CodeOrName·{ |
| 33943 | ········constructor(code)·{ |
| 33944 | ············super(); |
| 33945 | ············this._items·=·typeof·code·===·"string"·?·[code]·:·code; |
| 33946 | ········} |
33933 | ············toString()·{ | 33947 | ········toString()·{ |
33934 | ················return·this.str; | 33948 | ············return·this.str; |
33935 | ············} | 33949 | ········} |
33936 | ············emptyStr()·{ | 33950 | ········emptyStr()·{ |
| 33951 | ············if·(this._items.length·>·1) |
33937 | ················return·false; | 33952 | ················return·false; |
| 33953 | ············const·item·=·this._items[0]; |
| 33954 | ············return·item·===·""·||·item·===·'""'; |
33938 | ············} | |
33939 | ············get·names()·{ | |
33940 | ················return·{ | |
33941 | ····················[this.str]:·1 | |
33942 | ················}; | |
33943 | ············} | |
33944 | ········} | 33955 | ········} |
33945 | ········exports.Name·=·Name; | |
33946 | ········class·_Code·extends·_CodeOrName·{ | |
33947 | ············constructor(code)·{ | |
33948 | ················super(); | |
33949 | ················this._items·=·typeof·code·===·"string"·?·[code]·:·code; | |
33950 | ············} | |
33951 | ············toString()·{ | |
33952 | ················return·this.str; | |
33953 | ············} | |
33954 | ············emptyStr()·{ | |
33955 | ················if·(this._items.length·>·1) | |
33956 | ····················return·false; | |
33957 | ················const·item·=·this._items[0]; | |
33958 | ················return·item·===·""·||·item·===·'""'; | |
33959 | ············} | |
33960 | ············get·str()·{ | 33956 | ········get·str()·{ |
33961 | ················var·_a; | 33957 | ············var·_a; |
33962 | ················return·((_a·=·this._str)·!==·null·&&·_a·!==·void·0·?·_a·:·(this._str·=·this._items.reduce((s,·c)·=>·`${s}${c}`,·""))); | 33958 | ············return·((_a·=·this._str)·!==·null·&&·_a·!==·void·0·?·_a·:·(this._str·=·this._items.reduce((s,·c)·=>·`${s}${c}`,·""))); |
33963 | ············} | |
33964 | ············get·names()·{ | |
33965 | ················var·_a; | |
33966 | ················return·((_a·=·this._names)·!==·null·&&·_a·!==·void·0·?·_a·:·(this._names·=·this._items.reduce((names,·c)·=>·{ | |
33967 | ····················if·(c·instanceof·Name) | |
33968 | ························names[c.str]·=·(names[c.str]·||·0)·+·1; | |
33969 | ····················return·names; | |
33970 | ················},·{}))); | |
33971 | ············} | |
33972 | ········} | 33959 | ········} |
| 33960 | ········get·names()·{ |
| 33961 | ············var·_a; |
| 33962 | ············return·((_a·=·this._names)·!==·null·&&·_a·!==·void·0·?·_a·:·(this._names·=·this._items.reduce((names,·c)·=>·{ |
| 33963 | ················if·(c·instanceof·Name) |
| 33964 | ····················names[c.str]·=·(names[c.str]·||·0)·+·1; |
| 33965 | ················return·names; |
| 33966 | ············},·{}))); |
| 33967 | ········} |
| 33968 | ····} |
33973 | ········exports._Code·=·_Code; | 33969 | ····exports._Code·=·_Code; |
33974 | ········exports.nil·=·new·_Code(""); | 33970 | ····exports.nil·=·new·_Code(""); |
| |
33975 | ········function·_(strs,·...args)·{ | 33971 | ····function·_(strs,·...args)·{ |
33976 | ············const·code·=·[strs[0]]; | 33972 | ········const·code·=·[strs[0]]; |
33977 | ············let·i·=·0; | 33973 | ········let·i·=·0; |
33978 | ············while·(i·<·args.length)·{ | 33974 | ········while·(i·<·args.length)·{ |
33979 | ················addCodeArg(code,·args[i]); | 33975 | ············addCodeArg(code,·args[i]); |
33980 | ················code.push(strs[++i]); | 33976 | ············code.push(strs[++i]); |
33981 | ············} | |
33982 | ············return·new·_Code(code); | |
33983 | ········} | 33977 | ········} |
| 33978 | ········return·new·_Code(code); |
| 33979 | ····} |
33984 | ········exports._·=·_; | 33980 | ····exports._·=·_; |
33985 | ········const·plus·=·new·_Code("+"); | 33981 | ····const·plus·=·new·_Code("+"); |
| |
33986 | ········function·str(strs,·...args)·{ | 33982 | ····function·str(strs,·...args)·{ |
33987 | ············const·expr·=·[safeStringify(strs[0])]; | 33983 | ········const·expr·=·[safeStringify(strs[0])]; |
33988 | ············let·i·=·0; | 33984 | ········let·i·=·0; |
33989 | ············while·(i·<·args.length)·{ | 33985 | ········while·(i·<·args.length)·{ |
33990 | ················expr.push(plus); | 33986 | ············expr.push(plus); |
33991 | ················addCodeArg(expr,·args[i]); | 33987 | ············addCodeArg(expr,·args[i]); |
33992 | ················expr.push(plus,·safeStringify(strs[++i])); | 33988 | ············expr.push(plus,·safeStringify(strs[++i])); |
33993 | ············} | |
33994 | ············optimize(expr); | |
33995 | ············return·new·_Code(expr); | |
33996 | ········} | 33989 | ········} |
| 33990 | ········optimize(expr); |
| 33991 | ········return·new·_Code(expr); |
Max diff block lines reached; 6814/14058 bytes (48.47%) of diff not shown.
|