MCPcopy
hub / github.com/bbycroft/llm-viz / wiresFromLsState

Function wiresFromLsState

src/cpu/ImportExport.tsx:302–351  ·  view source on GitHub ↗
(layoutBase: IEditSnapshot, ls: ILSState, compLibrary: CompLibrary)

Source from the content-addressed store, hash-verified

300}
301
302export function wiresFromLsState(layoutBase: IEditSnapshot, ls: ILSState, compLibrary: CompLibrary): IEditSnapshot {
303
304 let wireIdx = 0;
305 let newWires: IWireGraph[] = ls.wires.map(w => ({
306 id: '' + wireIdx++,
307 nodes: w.nodes.map(n => ({
308 id: n.id,
309 pos: new Vec3(n.x, n.y),
310 edges: n.edges,
311 ref: n.ref,
312 })),
313 }));
314
315 let maxWireId = 0;
316 for (let w of newWires) {
317 maxWireId = Math.max(maxWireId, parseInt(w.id));
318 }
319
320 checkWires(newWires, 'wiresFromLsState');
321
322 let lsCompLookup = new Map<string, ILSComp>();
323 for (let c of ls.comps) {
324 lsCompLookup.set(c.id, c);
325 }
326
327 let comps: IComp[] = ls.comps.map(c => {
328 let comp = compLibrary.create(c.defId, c.args);
329
330 comp.id = c.id;
331 comp.pos = new Vec3(c.x, c.y);
332 comp.subSchematicId = c.subSchematicId;
333
334 return comp;
335 });
336
337 let maxCompId = 0;
338 for (let c of comps) {
339 maxCompId = Math.max(maxCompId, parseInt(c.id));
340 }
341
342 return assignImm(layoutBase, {
343 mainSchematic: assignImm(layoutBase.mainSchematic, {
344 nextWireId: maxWireId + 1,
345 nextCompId: maxCompId + 1,
346 parentCompDefId: ls.parentCompDefId,
347 wires: newWires,
348 comps: comps,
349 }),
350 });
351}
352
353export function schematicToLsState(layout: ISchematic): ILSState {
354 return {

Callers 1

Calls 3

checkWiresFunction · 0.90
assignImmFunction · 0.90
createMethod · 0.80

Tested by

no test coverage detected