diff --git a/proto/intermediate.proto b/proto/intermediate.proto index ed1f889..ea08161 100644 --- a/proto/intermediate.proto +++ b/proto/intermediate.proto @@ -24,10 +24,9 @@ enum IRParameterCount { } message IRParameter { - string name = 1; - IRParameterType type = 2; - IRParameterPresence presence = 3; - IRParameterCount count = 4; + IRParameterType type = 1; + IRParameterPresence presence = 2; + IRParameterCount count = 3; } message IRProcessor { diff --git a/runners/nodejs/src/proto/intermediate.ts b/runners/nodejs/src/proto/intermediate.ts index 14e4e12..2788eeb 100644 --- a/runners/nodejs/src/proto/intermediate.ts +++ b/runners/nodejs/src/proto/intermediate.ts @@ -157,7 +157,6 @@ export function iRParameterCountToJSON(object: IRParameterCount): string { } export interface IRParameter { - name: string; type: IRParameterType; presence: IRParameterPresence; count: IRParameterCount; @@ -196,7 +195,7 @@ export interface IRStage_ArgumentsEntry { } function createBaseIRParameter(): IRParameter { - return { name: "", type: 0, presence: 0, count: 0 }; + return { type: 0, presence: 0, count: 0 }; } export const IRParameter = { @@ -204,17 +203,14 @@ export const IRParameter = { message: IRParameter, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - if (message.name !== "") { - writer.uint32(10).string(message.name); - } if (message.type !== 0) { - writer.uint32(16).int32(message.type); + writer.uint32(8).int32(message.type); } if (message.presence !== 0) { - writer.uint32(24).int32(message.presence); + writer.uint32(16).int32(message.presence); } if (message.count !== 0) { - writer.uint32(32).int32(message.count); + writer.uint32(24).int32(message.count); } return writer; }, @@ -228,31 +224,24 @@ export const IRParameter = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - if (tag !== 10) { + if (tag !== 8) { break; } - message.name = reader.string(); + message.type = reader.int32() as any; continue; case 2: if (tag !== 16) { break; } - message.type = reader.int32() as any; + message.presence = reader.int32() as any; continue; case 3: if (tag !== 24) { break; } - message.presence = reader.int32() as any; - continue; - case 4: - if (tag !== 32) { - break; - } - message.count = reader.int32() as any; continue; } @@ -266,7 +255,6 @@ export const IRParameter = { fromJSON(object: any): IRParameter { return { - name: isSet(object.name) ? globalThis.String(object.name) : "", type: isSet(object.type) ? iRParameterTypeFromJSON(object.type) : 0, presence: isSet(object.presence) ? iRParameterPresenceFromJSON(object.presence) @@ -277,9 +265,6 @@ export const IRParameter = { toJSON(message: IRParameter): unknown { const obj: any = {}; - if (message.name !== "") { - obj.name = message.name; - } if (message.type !== 0) { obj.type = iRParameterTypeToJSON(message.type); } @@ -299,7 +284,6 @@ export const IRParameter = { object: I, ): IRParameter { const message = createBaseIRParameter(); - message.name = object.name ?? ""; message.type = object.type ?? 0; message.presence = object.presence ?? 0; message.count = object.count ?? 0; diff --git a/runners/nodejs/src/runtime/runner.ts b/runners/nodejs/src/runtime/runner.ts index f0fa355..77a2e71 100644 --- a/runners/nodejs/src/runtime/runner.ts +++ b/runners/nodejs/src/runtime/runner.ts @@ -36,12 +36,12 @@ export class Runner { /** Parse the stage's arguments. */ const args: Map = new Map(); - Object.entries(stage.arguments).map(([key, arg]) => { + Object.entries(stage.arguments).map(([name, arg]) => { if (arg.parameter!.type == IRParameterType.READER) { const subject = new Subject(); const reader = new Reader(subject); this.readers.set(arg.value[0], subject); - args.set(arg.parameter!.name, reader); + args.set(name, reader); } else if (arg.parameter!.type == IRParameterType.WRITER) { const subject = new Subject(); subject.subscribe((data) => { @@ -51,7 +51,7 @@ export class Runner { }); }); const writer = new Writer(subject); - args.set(arg.parameter!.name, writer); + args.set(name, writer); } else { console.error( new Error(`Unsupported parameter type ${arg.parameter!.type}`), diff --git a/src/main/kotlin/parser/impl/RDFParser.kt b/src/main/kotlin/parser/impl/RDFParser.kt index d07aa20..7d78ba5 100644 --- a/src/main/kotlin/parser/impl/RDFParser.kt +++ b/src/main/kotlin/parser/impl/RDFParser.kt @@ -94,7 +94,7 @@ class RDFParser(file: File) : Parser() { else -> Log.shared.fatal("Unknown datatype: $datatype") } - val parameter = IRParameter(path, type, presence, count) + val parameter = IRParameter(type, presence, count) parameters[path] = parameter } diff --git a/src/main/kotlin/parser/impl/TomlParser.kt b/src/main/kotlin/parser/impl/TomlParser.kt index ba1de47..2e15ccd 100644 --- a/src/main/kotlin/parser/impl/TomlParser.kt +++ b/src/main/kotlin/parser/impl/TomlParser.kt @@ -13,7 +13,6 @@ import technology.idlab.parser.intermediate.IRStage import technology.idlab.util.Log private fun TomlTable.toIRParameter(): IRParameter { - val name = this.getString("name") ?: Log.shared.fatal("No name found for parameter.") val typeString = this.getString("type") ?: Log.shared.fatal("No type found for parameter.") val presenceString = this.getString("presence") ?: Log.shared.fatal("No presence found for parameter.") @@ -48,11 +47,11 @@ private fun TomlTable.toIRParameter(): IRParameter { else -> Log.shared.fatal("Unknown count: $countString") } - return IRParameter(name, type, presence, count) + return IRParameter(type, presence, count) } -private fun TomlTable.toIRArguments(parameters: Map): List { - val results = mutableListOf() +private fun TomlTable.toIRArguments(parameters: Map): Map { + val results = mutableMapOf() this.keySet().forEach { name -> if (this.isArray(name)) { @@ -64,10 +63,10 @@ private fun TomlTable.toIRArguments(parameters: Map): List< values.add(value) } - results.add(IRArgument(parameters[name]!!, values)) + results[name] = IRArgument(parameters[name]!!, values) } else { val value = this.get(name).toString() - results.add(IRArgument(parameters[name]!!, listOf(value))) + results[name] = IRArgument(parameters[name]!!, listOf(value)) } } @@ -94,8 +93,10 @@ private fun TomlTable.toIRProcessor(uri: String): IRProcessor { val parametersArray = this.getArray("parameters")!! val result = mutableMapOf() for (i in 0 until parametersArray.size()) { + val table = parametersArray.getTable(i) + val name = table.getString("name") ?: Log.shared.fatal("No name found for parameter.") val parameter = parametersArray.getTable(i).toIRParameter() - result[parameter.name] = parameter + result[name] = parameter } // Parse metadata. @@ -116,8 +117,8 @@ private fun TomlTable.toIRStage(processors: Map, uri: Strin val processor = processors[processorURI] ?: Log.shared.fatal("Unknown processor: $processorURI") // Parse arguments. - val arguments = this.getTable("arguments")?.toIRArguments(processor.parameters) ?: emptyList() - return IRStage(uri, processor, arguments.associateBy { it.parameter.name }) + val arguments = this.getTable("arguments")?.toIRArguments(processor.parameters) ?: emptyMap() + return IRStage(uri, processor, arguments) } class TomlParser(file: File) : Parser() { diff --git a/src/main/kotlin/parser/intermediate/IRParameter.kt b/src/main/kotlin/parser/intermediate/IRParameter.kt index 69727a8..f799312 100644 --- a/src/main/kotlin/parser/intermediate/IRParameter.kt +++ b/src/main/kotlin/parser/intermediate/IRParameter.kt @@ -1,8 +1,6 @@ package technology.idlab.parser.intermediate data class IRParameter( - // Argument name. - val name: String, // The type of the argument. val type: Type, // Whether the argument is required. diff --git a/src/main/kotlin/runner/impl/GRPCRunner.kt b/src/main/kotlin/runner/impl/GRPCRunner.kt index 37275d2..dc0b5d1 100644 --- a/src/main/kotlin/runner/impl/GRPCRunner.kt +++ b/src/main/kotlin/runner/impl/GRPCRunner.kt @@ -52,7 +52,6 @@ private fun IRParameter.Count.toGRPC(): GRPC.IRParameterCount { private fun IRParameter.toGRPC(): GRPC.IRParameter { val builder = GRPC.IRParameter.newBuilder() - builder.setName(name) builder.setType(type.toGRPC()) builder.setPresence(presence.toGRPC()) builder.setCount(count.toGRPC()) diff --git a/src/test/kotlin/processors/NodeTransparent.kt b/src/test/kotlin/processors/NodeTransparent.kt index dcc8ce7..3bf6df6 100644 --- a/src/test/kotlin/processors/NodeTransparent.kt +++ b/src/test/kotlin/processors/NodeTransparent.kt @@ -15,14 +15,12 @@ class NodeTransparent { mapOf( "input" to IRParameter( - "input", IRParameter.Type.READER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE, ), "output" to IRParameter( - "output", IRParameter.Type.WRITER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE, diff --git a/src/test/kotlin/processors/TappedReader.kt b/src/test/kotlin/processors/TappedReader.kt index b889606..85563bc 100644 --- a/src/test/kotlin/processors/TappedReader.kt +++ b/src/test/kotlin/processors/TappedReader.kt @@ -37,7 +37,6 @@ class TappedReader(args: Map) : Processor(args) { mapOf( "input" to IRParameter( - "input", IRParameter.Type.READER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE, diff --git a/src/test/kotlin/processors/TappedWriter.kt b/src/test/kotlin/processors/TappedWriter.kt index a6ac0e5..c99e0dc 100644 --- a/src/test/kotlin/processors/TappedWriter.kt +++ b/src/test/kotlin/processors/TappedWriter.kt @@ -37,7 +37,6 @@ class TappedWriter(args: Map) : Processor(args) { mapOf( "output" to IRParameter( - "output", IRParameter.Type.WRITER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE, diff --git a/src/test/kotlin/runner/RunnerTest.kt b/src/test/kotlin/runner/RunnerTest.kt index 06206b5..2b3c137 100644 --- a/src/test/kotlin/runner/RunnerTest.kt +++ b/src/test/kotlin/runner/RunnerTest.kt @@ -55,7 +55,6 @@ abstract class RunnerTest { private val paramInput = IRParameter( - "input", IRParameter.Type.READER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE, @@ -63,7 +62,6 @@ abstract class RunnerTest { private val paramOutput = IRParameter( - "output", IRParameter.Type.WRITER, IRParameter.Presence.REQUIRED, IRParameter.Count.SINGLE,