| 88 | } |
| 89 | |
| 90 | private static _parseMacroDefines(source: string, outMacroList: MacroDefineList): void { |
| 91 | let match: RegExpExecArray | null; |
| 92 | this._macroRegex.lastIndex = 0; |
| 93 | |
| 94 | while ((match = this._macroRegex.exec(source)) !== null) { |
| 95 | const [, name, paramsGroup, paramsStr, valueRaw] = match; |
| 96 | const isFunction = !!paramsGroup && !!valueRaw; |
| 97 | const params = |
| 98 | isFunction && paramsStr |
| 99 | ? paramsStr |
| 100 | .split(",") |
| 101 | .map((p) => p.trim()) |
| 102 | .filter(Boolean) |
| 103 | : []; |
| 104 | const value = valueRaw ? valueRaw.trim() : ""; |
| 105 | |
| 106 | let valueType = MacroValueType.Other; |
| 107 | let functionCallName = ""; |
| 108 | |
| 109 | if (this._isNumber(value)) { |
| 110 | valueType = MacroValueType.Number; |
| 111 | } else if (this._symbolReg.test(value)) { |
| 112 | valueType = MacroValueType.Symbol; |
| 113 | } else { |
| 114 | const callMatch = this._funcCallReg.exec(value); |
| 115 | if (callMatch) { |
| 116 | valueType = MacroValueType.FunctionCall; |
| 117 | functionCallName = callMatch[1]; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | const info: MacroDefineInfo = { |
| 122 | isFunction, |
| 123 | name, |
| 124 | value, |
| 125 | valueType, |
| 126 | params, |
| 127 | functionCallName |
| 128 | }; |
| 129 | |
| 130 | const arr = outMacroList[name]; |
| 131 | if (arr) { |
| 132 | if (!this._isExist(arr, info)) arr.push(info); |
| 133 | } else { |
| 134 | outMacroList[name] = [info]; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | private static _mergeMacroDefineLists(from: MacroDefineList, to: MacroDefineList): void { |
| 140 | for (const macroName in from) { |