This commit is contained in:
Михаил Капелько
2023-12-28 18:19:44 +03:00
parent 480fc7d132
commit 56c897bb9e
3 changed files with 34 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
from generation.isNotKeyword import *
def pipeSource(name, entity, structure, fmtBusPipe, fmtBusPipeToggle):
props = entity.pipes[name]
if "vm" in props:
return "core.vm." + name
elif "$vm" in props:
return "core.vm.$" + name
else:
# Если это что-то неизвестное заранее, то ищем строку,
# отличную от известных ключевых слов для инструкции pipe.
default = "world"
src = next(filter(isNotKeyword, props), default)
# Прямое обращение к VM.
if src.startswith("vm."):
src = "core." + src
# Обращение к константе шины.
elif src.startswith("K."):
src = pipeSourceBus(
busKey = src
busValueType = structure.model.fields[name][0]
src = "Bus.events.compactMap { Bus.convertKeyValue(" + busKey + ", $0) }.map { (k: String, v: " + busValueType + ") in v }"
# Значение по умолчанию.
elif src == default:
return default + "." + name
return src