MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / run

Method run

tools/mclocal.js:129–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127 }
128 }
129 run() {
130 var locals = this.inputPaths.map(path => {
131 var parts = this.splitPath(path);
132 return {
133 name: parts.name,
134 dictionary: JSON.parse(this.readFileString(path)),
135 };
136 });
137 var all = {}
138 locals.forEach(local => {
139 for (var key in local.dictionary)
140 all[key] = true;
141 });
142 var keys = Object.keys(all);
143 var length = keys.length;
144 if (length < 127)
145 length = 127;
146 var values = {};
147 var debug = new Array(length).fill();
148 keys.forEach((key, index) => {
149 values[key] = index;
150 debug[index] = key;
151 })
152 locals.forEach(local => {
153 var dictionary = local.dictionary;
154 var table = local.table = new Array(length).fill();
155 keys.forEach((key, index) => {
156 if (key in dictionary)
157 table[index] = dictionary[key];
158 else {
159 this.reportWarning(null, 0, "'" + local.name + "': missing '" + key + "'!");
160 table[index] = "";
161 }
162 });
163 });
164 var G = new Array(length).fill(0);
165 var H = new Array(length).fill();
166 this.build(length, keys, values, G, H);
167
168 var parts = { directory:this.outputPath, name:this.name, extension:".mhi" };
169 var file = new FILE(this.joinPath(parts), "wb");
170 this.write32(file, length);
171 for (var index of G)
172 this.write32(file, index);
173 if (this.debug) {
174 this.write32(file, length);
175 var offset = (1 + length) << 3;
176 for (var index of H) {
177 this.write32(file, offset);
178 var string = debug[index];
179 if (string)
180 offset += this.strlen(string) + 1;
181 }
182 for (var index of H) {
183 var string = debug[index];
184 if (string) {
185 file.writeString(string);
186 file.writeByte(0);

Callers

nothing calls this directly

Calls 9

mapMethod · 0.80
keysMethod · 0.80
parseMethod · 0.65
fillMethod · 0.65
closeMethod · 0.65
buildMethod · 0.45
write32Method · 0.45
writeStringMethod · 0.45
writeByteMethod · 0.45

Tested by

no test coverage detected