diff --git a/packages/xod-arduino/src/transpiler.js b/packages/xod-arduino/src/transpiler.js index 940a45b7..5b42a8be 100644 --- a/packages/xod-arduino/src/transpiler.js +++ b/packages/xod-arduino/src/transpiler.js @@ -594,8 +594,8 @@ const transformProjectWithImpls = def( R.map(XP.extractBoundInputsToConstNodes(path)), R.chain(XP.flatten(R.__, path)), R.map(XP.expandVariadicNodes(path)), - R.chain(XP.autoresolveTypes(path)), R.map(XP.jumperizePatchRecursively(path)), + R.chain(XP.autoresolveTypes(path)), R.unless( () => liveness !== LIVENESS.NONE, R.map(XP.removeDebugNodes(path)) diff --git a/packages/xod-project/src/Buses.re b/packages/xod-project/src/Buses.re index 2dd53e48..e06cae4e 100644 --- a/packages/xod-project/src/Buses.re +++ b/packages/xod-project/src/Buses.re @@ -12,7 +12,7 @@ let getMatchingBusNodes = patch => { let nodes = Patch.listNodes(patch); let toBusNodesByLabel = nodes - |. List.keep(n => Node.getType(n) == toBusPatchPath) + |. List.keep(n => Node.getType(n) |> PatchPath.isToBus) |. BeltHoles.List.groupByString(Node.getLabel) /* having multiple `to-bus` nodes with the same label is forbidden, so exclude them from type resolution */ @@ -22,7 +22,7 @@ let getMatchingBusNodes = patch => { []; /* short-curcuit for optimization */ } else { nodes - |. List.keep(n => Node.getType(n) == fromBusPatchPath) + |. List.keep(n => Node.getType(n) |> PatchPath.isFromBus) |. BeltHoles.List.groupByString(Node.getLabel) |. Map.String.keep((label, _) => Map.String.has(toBusNodesByLabel, label) @@ -120,14 +120,14 @@ let splitLinksToBuses: |> Link.getInputNodeId |> Patch.getNodeById(patch) |. Option.mapWithDefault(false, n => - Node.getType(n) == toBusPatchPath + Node.getType(n) |> PatchPath.isToBus ); let isOutputConnectedToBusNode = link |> Link.getOutputNodeId |> Patch.getNodeById(patch) |. Option.mapWithDefault(false, n => - Node.getType(n) == fromBusPatchPath + Node.getType(n) |> PatchPath.isFromBus ); ! isOutputConnectedToBusNode && ! isInputConnectedToBusNode; }); @@ -146,7 +146,7 @@ let splitLinksToBuses: |> Link.getInputNodeId |> Patch.getNodeById(patch) |. Option.flatMap(node => - Node.getType(node) == toBusPatchPath ? + Node.getType(node) |> PatchPath.isToBus ? Some(node) : None ) |. Option.map(node => (link, node)) diff --git a/packages/xod-project/src/internal/patchPathUtils.js b/packages/xod-project/src/internal/patchPathUtils.js index 000dc94d..d5aea6f7 100644 --- a/packages/xod-project/src/internal/patchPathUtils.js +++ b/packages/xod-project/src/internal/patchPathUtils.js @@ -124,10 +124,10 @@ export const isWatchPatchPath = R.test(/^xod\/(core|debug)\/watch$/); export const isJumperPatchPath = R.equals(CONST.JUMPER_PATCH_PATH); // :: String -> Boolean -export const isFromBusPatchPath = R.equals(CONST.FROM_BUS_PATH); +export const isFromBusPatchPath = R.startsWith(CONST.FROM_BUS_PATH); // :: String -> Boolean -export const isToBusPatchPath = R.equals(CONST.TO_BUS_PATH); +export const isToBusPatchPath = R.startsWith(CONST.TO_BUS_PATH); // :: String -> Boolean export const isBusPatchPath = R.either(isFromBusPatchPath, isToBusPatchPath); diff --git a/workspace/test/test-core/foo(number)/patch.xodp b/workspace/test/test-core/foo(number)/patch.xodp new file mode 100644 index 00000000..8a36c2b3 --- /dev/null +++ b/workspace/test/test-core/foo(number)/patch.xodp @@ -0,0 +1,112 @@ +{ + "comments": [ + { + "content": "for `test-buses-in-specializations`", + "id": "H1l3ONIgoH", + "position": { + "units": "slots", + "x": 4, + "y": 1 + }, + "size": { + "height": 1, + "units": "slots", + "width": 6 + } + } + ], + "links": [ + { + "id": "B1NU_VLlor", + "input": { + "nodeId": "BJZUd4LxiH", + "pinKey": "BJnQUR_BwyZ" + }, + "output": { + "nodeId": "ByLdE8giS", + "pinKey": "__out__" + } + }, + { + "id": "H1H8dVIgjH", + "input": { + "nodeId": "SkMUuEUxjS", + "pinKey": "__in__" + }, + "output": { + "nodeId": "HklLuELlsB", + "pinKey": "__out__" + } + }, + { + "id": "HJILO4IgiH", + "input": { + "nodeId": "SyXU_NLejH", + "pinKey": "__in__" + }, + "output": { + "nodeId": "BJZUd4LxiH", + "pinKey": "SyomIRurDJ-" + } + } + ], + "nodes": [ + { + "boundLiterals": { + "HkqmLAOrD1W": "10" + }, + "id": "BJZUd4LxiH", + "position": { + "units": "slots", + "x": 0, + "y": 1 + }, + "type": "xod/core/add" + }, + { + "id": "By2_EUgir", + "position": { + "units": "slots", + "x": 3, + "y": 1 + }, + "type": "xod/patch-nodes/utility" + }, + { + "id": "ByLdE8giS", + "position": { + "units": "slots", + "x": 0, + "y": 0 + }, + "type": "xod/patch-nodes/input-number" + }, + { + "id": "HklLuELlsB", + "position": { + "units": "slots", + "x": 0, + "y": 3 + }, + "type": "xod/patch-nodes/from-bus" + }, + { + "id": "SkMUuEUxjS", + "position": { + "units": "slots", + "x": 0, + "y": 4 + }, + "type": "xod/patch-nodes/output-number" + }, + { + "id": "SyXU_NLejH", + "position": { + "units": "slots", + "x": 0, + "y": 2 + }, + "type": "xod/patch-nodes/to-bus" + } + ] +} diff --git a/workspace/test/test-core/foo/patch.xodp b/workspace/test/test-core/foo/patch.xodp new file mode 100644 index 00000000..a1e99923 --- /dev/null +++ b/workspace/test/test-core/foo/patch.xodp @@ -0,0 +1,56 @@ +{ + "comments": [ + { + "content": "for `test-buses-in-specializations`", + "id": "SyPBNIgsH", + "position": { + "units": "slots", + "x": 3, + "y": 1 + }, + "size": { + "height": 1, + "units": "slots", + "width": 6 + } + } + ], + "nodes": [ + { + "id": "Bk-aVVUxor", + "position": { + "units": "slots", + "x": 0, + "y": 2 + }, + "type": "xod/patch-nodes/output-t1" + }, + { + "id": "HJe6NEIejB", + "position": { + "units": "slots", + "x": 0, + "y": 1 + }, + "type": "xod/patch-nodes/abstract" + }, + { + "id": "r1MBNLxjB", + "position": { + "units": "slots", + "x": 2, + "y": 1 + }, + "type": "xod/patch-nodes/utility" + }, + { + "id": "rypE48lsS", + "position": { + "units": "slots", + "x": 0, + "y": 0 + }, + "type": "xod/patch-nodes/input-t1" + } + ] +} diff --git a/workspace/test/test-core/test-buses-in-specializations/patch.test.tsv b/workspace/test/test-core/test-buses-in-specializations/patch.test.tsv new file mode 100644 index 00000000..4e079383 --- /dev/null +++ b/workspace/test/test-core/test-buses-in-specializations/patch.test.tsv @@ -0,0 +1,3 @@ +IN OUT +10 20 +100 110 diff --git a/workspace/test/test-core/test-buses-in-specializations/patch.xodp b/workspace/test/test-core/test-buses-in-specializations/patch.xodp new file mode 100644 index 00000000..ef44541c --- /dev/null +++ b/workspace/test/test-core/test-buses-in-specializations/patch.xodp @@ -0,0 +1,64 @@ +{ + "links": [ + { + "id": "SkcFV8lsH", + "input": { + "nodeId": "HyeIKEUeiS", + "pinKey": "__in__" + }, + "output": { + "nodeId": "SkWItNIxoH", + "pinKey": "Bk-aVVUxor" + } + }, + { + "id": "rJsFEIljB", + "input": { + "nodeId": "SkWItNIxoH", + "pinKey": "rypE48lsS" + }, + "output": { + "nodeId": "rJMLY4Leor", + "pinKey": "__out__" + } + } + ], + "nodes": [ + { + "id": "HyIKE8eoH", + "position": { + "units": "slots", + "x": 2, + "y": 1 + }, + "type": "xod/patch-nodes/tabtest" + }, + { + "id": "HyeIKEUeiS", + "position": { + "units": "slots", + "x": 0, + "y": 2 + }, + "type": "xod/patch-nodes/output-number" + }, + { + "id": "SkWItNIxoH", + "position": { + "units": "slots", + "x": 0, + "y": 1 + }, + "type": "@/foo" + }, + { + "id": "rJMLY4Leor", + "position": { + "units": "slots", + "x": 0, + "y": 0 + }, + "type": "xod/patch-nodes/input-number" + } + ] +}