Compare commits
No commits in common. "e2e05060417e4fe55148d167015d35a0aac2c6ff" and "bf029929a71a9ef90395c14be7193a3c0b293f4c" have entirely different histories.
e2e0506041
...
bf029929a7
|
@ -7,7 +7,4 @@
|
||||||
/dataSources/
|
/dataSources/
|
||||||
/dataSources.local.xml
|
/dataSources.local.xml
|
||||||
/cmake-build-debug/**
|
/cmake-build-debug/**
|
||||||
/.idea/**
|
/.idea/**
|
||||||
|
|
||||||
**.pro.user
|
|
||||||
**.pro.user.*
|
|
|
@ -1 +0,0 @@
|
||||||
{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
|
|
|
@ -1,6 +0,0 @@
|
||||||
make --dry-run --always-make --keep-going --print-directory
|
|
||||||
make: Entering directory '/home/bbr/SchemeEditor'
|
|
||||||
make: Leaving directory '/home/bbr/SchemeEditor'
|
|
||||||
|
|
||||||
make: *** No targets specified and no makefile found. Stop.
|
|
||||||
|
|
|
@ -1,288 +0,0 @@
|
||||||
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
|
|
||||||
make: *** No rule to make target 'all'. Stop.
|
|
||||||
|
|
||||||
# GNU Make 4.3
|
|
||||||
# Built for x86_64-pc-linux-gnu
|
|
||||||
# Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
|
||||||
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
||||||
# This is free software: you are free to change and redistribute it.
|
|
||||||
# There is NO WARRANTY, to the extent permitted by law.
|
|
||||||
|
|
||||||
# Make data base, printed on Sun Apr 24 22:18:48 2022
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
# environment
|
|
||||||
GDK_BACKEND = x11
|
|
||||||
# environment
|
|
||||||
LC_ALL = C
|
|
||||||
# environment
|
|
||||||
NO_AT_BRIDGE = 1
|
|
||||||
# environment
|
|
||||||
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-378bef37-635c-4f71-808d-af9f8b80a929.sock
|
|
||||||
# environment
|
|
||||||
LC_NAME = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
LC_NUMERIC = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
VSCODE_CWD = /home/bbr
|
|
||||||
# environment
|
|
||||||
LC_ADDRESS = hr_HR.UTF-8
|
|
||||||
# default
|
|
||||||
MAKE_COMMAND := make
|
|
||||||
# environment
|
|
||||||
GTK3_MODULES = xapp-gtk3-module
|
|
||||||
# automatic
|
|
||||||
@D = $(patsubst %/,%,$(dir $@))
|
|
||||||
# environment
|
|
||||||
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
|
|
||||||
# default
|
|
||||||
.VARIABLES :=
|
|
||||||
# environment
|
|
||||||
PWD = /home/bbr/SchemeEditor
|
|
||||||
# automatic
|
|
||||||
%D = $(patsubst %/,%,$(dir $%))
|
|
||||||
# environment
|
|
||||||
MAIL = /var/spool/mail/bbr
|
|
||||||
# environment
|
|
||||||
XDG_DATA_DIRS = /usr/local/share:/usr/share:/var/lib/snapd/desktop
|
|
||||||
# automatic
|
|
||||||
^D = $(patsubst %/,%,$(dir $^))
|
|
||||||
# environment
|
|
||||||
VSCODE_LOG_STACK = false
|
|
||||||
# automatic
|
|
||||||
%F = $(notdir $%)
|
|
||||||
# environment
|
|
||||||
VSCODE_CODE_CACHE_PATH = /home/bbr/.config/Code - OSS/CachedData/e18005f0f1b33c29e81d732535d8c0e47cafb0b5
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session0
|
|
||||||
# environment
|
|
||||||
LANG = C
|
|
||||||
# environment
|
|
||||||
XAUTHORITY = /home/bbr/.Xauthority
|
|
||||||
# default
|
|
||||||
.LOADED :=
|
|
||||||
# default
|
|
||||||
.INCLUDE_DIRS = /usr/include /usr/local/include /usr/include
|
|
||||||
# makefile
|
|
||||||
MAKEFLAGS = pqrR
|
|
||||||
# makefile
|
|
||||||
CURDIR := /home/bbr/SchemeEditor
|
|
||||||
# environment
|
|
||||||
VSCODE_PIPE_LOGGING = true
|
|
||||||
# environment
|
|
||||||
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = true
|
|
||||||
# automatic
|
|
||||||
*D = $(patsubst %/,%,$(dir $*))
|
|
||||||
# environment
|
|
||||||
MFLAGS = -pqrR
|
|
||||||
# environment
|
|
||||||
SSH_AUTH_SOCK = /run/user/1000/keyring/ssh
|
|
||||||
# default
|
|
||||||
.SHELLFLAGS := -c
|
|
||||||
# automatic
|
|
||||||
+D = $(patsubst %/,%,$(dir $+))
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_DESKTOP = budgie-desktop
|
|
||||||
# makefile
|
|
||||||
MAKEFILE_LIST :=
|
|
||||||
# automatic
|
|
||||||
@F = $(notdir $@)
|
|
||||||
# environment
|
|
||||||
VSCODE_VERBOSE_LOGGING = true
|
|
||||||
# environment
|
|
||||||
VSCODE_PID = 1877190
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_TYPE = x11
|
|
||||||
# automatic
|
|
||||||
?D = $(patsubst %/,%,$(dir $?))
|
|
||||||
# environment
|
|
||||||
SESSION_MANAGER = local/bbr:@/tmp/.ICE-unix/1465,unix/bbr:/tmp/.ICE-unix/1465
|
|
||||||
# automatic
|
|
||||||
*F = $(notdir $*)
|
|
||||||
# environment
|
|
||||||
QT_QPA_PLATFORMTHEME = qt5ct
|
|
||||||
# environment
|
|
||||||
CHROME_DESKTOP = code-oss.desktop
|
|
||||||
# environment
|
|
||||||
DBUS_SESSION_BUS_ADDRESS = unix:path=/run/user/1000/bus
|
|
||||||
# automatic
|
|
||||||
<D = $(patsubst %/,%,$(dir $<))
|
|
||||||
# environment
|
|
||||||
VSCODE_NLS_CONFIG = {"locale":"en-gb","availableLanguages":{},"_languagePackSupport":true}
|
|
||||||
# default
|
|
||||||
MAKE_HOST := x86_64-pc-linux-gnu
|
|
||||||
# makefile
|
|
||||||
SHELL = /bin/sh
|
|
||||||
# default
|
|
||||||
MAKECMDGOALS := all
|
|
||||||
# environment
|
|
||||||
DOTNET_BUNDLE_EXTRACT_BASE_DIR = /home/bbr/.cache/dotnet_bundle_extract
|
|
||||||
# environment
|
|
||||||
SHLVL = 0
|
|
||||||
# environment
|
|
||||||
MAKELEVEL := 0
|
|
||||||
# default
|
|
||||||
MAKE = $(MAKE_COMMAND)
|
|
||||||
# environment
|
|
||||||
PATH = /home/bbr/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/home/bbr/.dotnet/tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
|
|
||||||
# default
|
|
||||||
MAKEFILES :=
|
|
||||||
# environment
|
|
||||||
LC_MONETARY = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
MOTD_SHOWN = pam
|
|
||||||
# automatic
|
|
||||||
^F = $(notdir $^)
|
|
||||||
# environment
|
|
||||||
LC_TIME = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
GRADLE_HOME = /usr/share/java/gradle
|
|
||||||
# environment
|
|
||||||
VSCODE_LOG_NATIVE = false
|
|
||||||
# environment
|
|
||||||
LC_TELEPHONE = hr_HR.UTF-8
|
|
||||||
# automatic
|
|
||||||
?F = $(notdir $?)
|
|
||||||
# environment
|
|
||||||
XDG_CURRENT_DESKTOP = Budgie:GNOME
|
|
||||||
# automatic
|
|
||||||
+F = $(notdir $+)
|
|
||||||
# environment
|
|
||||||
XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0
|
|
||||||
# environment
|
|
||||||
DESKTOP_SESSION = budgie-desktop
|
|
||||||
# environment
|
|
||||||
ORIGINAL_XDG_CURRENT_DESKTOP = Budgie:GNOME
|
|
||||||
# 'override' directive
|
|
||||||
GNUMAKEFLAGS :=
|
|
||||||
# environment
|
|
||||||
LOGNAME = bbr
|
|
||||||
# environment
|
|
||||||
GIO_LAUNCHED_DESKTOP_FILE = /usr/share/applications/code-oss.desktop
|
|
||||||
# makefile
|
|
||||||
.DEFAULT_GOAL :=
|
|
||||||
# environment
|
|
||||||
EDITOR = /usr/bin/nano
|
|
||||||
# environment
|
|
||||||
DISPLAY = :0
|
|
||||||
# environment
|
|
||||||
GTK_MODULES = canberra-gtk-module
|
|
||||||
# environment
|
|
||||||
USER = bbr
|
|
||||||
# default
|
|
||||||
MAKE_VERSION := 4.3
|
|
||||||
# environment
|
|
||||||
LC_MEASUREMENT = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
GIO_LAUNCHED_DESKTOP_FILE_PID = 1877159
|
|
||||||
# environment
|
|
||||||
_ = /usr/bin/make
|
|
||||||
# environment
|
|
||||||
LC_PAPER = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
XDG_RUNTIME_DIR = /run/user/1000
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_CLASS = user
|
|
||||||
# environment
|
|
||||||
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
|
|
||||||
# environment
|
|
||||||
GTK2_RC_FILES = /home/bbr/.gtkrc-2.0
|
|
||||||
# environment
|
|
||||||
HOME = /home/bbr
|
|
||||||
# environment
|
|
||||||
ELECTRON_RUN_AS_NODE = 1
|
|
||||||
# environment
|
|
||||||
VSCODE_IPC_HOOK = /run/user/1000/vscode-bb99a93f-1.66.0-main.sock
|
|
||||||
# default
|
|
||||||
.RECIPEPREFIX :=
|
|
||||||
# automatic
|
|
||||||
<F = $(notdir $<)
|
|
||||||
# default
|
|
||||||
SUFFIXES :=
|
|
||||||
# environment
|
|
||||||
VSCODE_CLI = 1
|
|
||||||
# environment
|
|
||||||
ELECTRON_NO_ATTACH_CONSOLE = 1
|
|
||||||
# environment
|
|
||||||
XDG_GREETER_DATA_DIR = /var/lib/lightdm-data/bbr
|
|
||||||
# default
|
|
||||||
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell nocomment grouped-target extra-prereqs archives jobserver output-sync check-symlink guile load
|
|
||||||
# environment
|
|
||||||
XDG_MENU_PREFIX = gnome-
|
|
||||||
# environment
|
|
||||||
DOTNET_ROOT = /usr/share/dotnet
|
|
||||||
# environment
|
|
||||||
GDMSESSION = budgie-desktop
|
|
||||||
# environment
|
|
||||||
LC_IDENTIFICATION = hr_HR.UTF-8
|
|
||||||
# variable set hash-table stats:
|
|
||||||
# Load=102/1024=10%, Rehash=0, Collisions=5/129=4%
|
|
||||||
|
|
||||||
# Pattern-specific Variable Values
|
|
||||||
|
|
||||||
# No pattern-specific variable values.
|
|
||||||
|
|
||||||
# Directories
|
|
||||||
|
|
||||||
# . (device 66306, inode 9380506): 17 files, no impossibilities.
|
|
||||||
|
|
||||||
# 17 files, no impossibilities in 1 directories.
|
|
||||||
|
|
||||||
# Implicit Rules
|
|
||||||
|
|
||||||
# No implicit rules.
|
|
||||||
|
|
||||||
# Files
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
Makefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
.DEFAULT:
|
|
||||||
# Implicit rule search has not been done.
|
|
||||||
# Modification time never checked.
|
|
||||||
# File has not been updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
all:
|
|
||||||
# Command line target.
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has not been updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
makefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
GNUmakefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# files hash-table stats:
|
|
||||||
# Load=6/1024=1%, Rehash=0, Collisions=0/15=0%
|
|
||||||
# VPATH Search Paths
|
|
||||||
|
|
||||||
# No 'vpath' search paths.
|
|
||||||
|
|
||||||
# No general ('VPATH' variable) search path.
|
|
||||||
|
|
||||||
# strcache buffers: 1 (0) / strings = 25 / storage = 264 B / avg = 10 B
|
|
||||||
# current buf: size = 8162 B / used = 264 B / count = 25 / avg = 10 B
|
|
||||||
|
|
||||||
# strcache performance: lookups = 28 / hit rate = 10%
|
|
||||||
# hash-table stats:
|
|
||||||
# Load=25/8192=0%, Rehash=0, Collisions=0/28=0%
|
|
||||||
# Finished Make data base on Sun Apr 24 22:18:48 2022
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ add_executable(SchemeEditor
|
||||||
comdel/domain/schemacreator.cpp
|
comdel/domain/schemacreator.cpp
|
||||||
comdel/parser/comdelparser.cpp
|
comdel/parser/comdelparser.cpp
|
||||||
comdel/parser/token.cpp
|
comdel/parser/token.cpp
|
||||||
comdel/parser/sourceerror.cpp
|
comdel/parser/parser_util.cpp
|
||||||
|
comdel/parser/sourceerror.cpp
|
||||||
comdel/parser/parsecontext.cpp
|
comdel/parser/parsecontext.cpp
|
||||||
comdel/parser/tokenstype.cpp
|
comdel/parser/tokenstype.cpp
|
||||||
comdel/parser/astnode.cpp
|
comdel/parser/astnode.cpp
|
||||||
|
@ -38,5 +39,5 @@ add_executable(SchemeEditor
|
||||||
comdel/parser/comdellexer.cpp
|
comdel/parser/comdellexer.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
comdel/domain/comdelvalidator.cpp comdel/domain/comdelvalidator.h comdel/display/attribute_dialog.cpp comdel/display/attribute_dialog.h comdel/display/name_dialog.cpp comdel/display/name_dialog.h comdel/domain/comdel_generator.cpp comdel/domain/comdel_generator.h)
|
comdel/domain/comdelvalidator.cpp comdel/domain/comdelvalidator.h)
|
||||||
target_link_libraries(SchemeEditor Qt5::Core Qt5::Gui Qt5::Widgets)
|
target_link_libraries(SchemeEditor Qt5::Core Qt5::Gui Qt5::Widgets)
|
||||||
|
|
|
@ -38,9 +38,6 @@ SOURCES += \
|
||||||
comdel/parser/sourceerror.cpp \
|
comdel/parser/sourceerror.cpp \
|
||||||
comdel/parser/token.cpp \
|
comdel/parser/token.cpp \
|
||||||
comdel/parser/tokenstype.cpp \
|
comdel/parser/tokenstype.cpp \
|
||||||
comdel/display/dialogmanager.cpp \
|
|
||||||
comdel/display/attribute_dialog.cpp \
|
|
||||||
comdel/display/name_dialog.cpp \
|
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
|
|
||||||
|
@ -77,9 +74,6 @@ HEADERS += \
|
||||||
comdel/parser/sourceerror.h \
|
comdel/parser/sourceerror.h \
|
||||||
comdel/parser/token.h \
|
comdel/parser/token.h \
|
||||||
comdel/parser/tokenstype.h \
|
comdel/parser/tokenstype.h \
|
||||||
comdel/display/dialogmanager.h \
|
|
||||||
comdel/display/attribute_dialog.h \
|
|
||||||
comdel/display/name_dialog.h \
|
|
||||||
mainwindow.h
|
mainwindow.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 7.0.0, 2022-04-12T22:39:08. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{1f5ef7b0-cf08-4d4a-b37d-18ed0b7a2084}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="qlonglong">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||||
|
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||||
|
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||||
|
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||||
|
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||||
|
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.BuildSystem</value>
|
||||||
|
<valuemap type="QVariantMap" key="ClangTools">
|
||||||
|
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||||
|
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||||
|
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||||
|
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.2 clang 64bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.2 clang 64bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5152.clang_64_kit</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Release</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
<value type="int" key="QtQuickCompiler">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||||
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Profile</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Profile</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
<value type="int" key="QtQuickCompiler">0</value>
|
||||||
|
<value type="int" key="SeparateDebugInfo">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/s2ismac/Desktop/comdel/schema_editor/SchemeEditor.pro</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/Users/s2ismac/Desktop/comdel/schema_editor/SchemeEditor.pro</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/Users/s2ismac/Desktop/comdel/build-SchemeEditor-Desktop_Qt_5_15_2_clang_64bit-Debug/SchemeEditor.app/Contents/MacOS</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="qlonglong">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
|
@ -0,0 +1,268 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 6.0.2, 2022-04-09T20:03:04. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{391729b0-9fcc-4b56-ba51-7d7ee685fc97}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="qlonglong">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||||
|
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||||
|
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||||
|
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||||
|
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||||
|
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.BuildSystem</value>
|
||||||
|
<valuemap type="QVariantMap" key="ClangTools">
|
||||||
|
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||||
|
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||||
|
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||||
|
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
|
||||||
|
<value type="bool" key="UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{8ccd2350-ba56-4630-b9a6-4b0b4b193aaf}</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/bbr/build-SchemeEditor-Desktop-Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/bbr/build-SchemeEditor-Desktop-Debug</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/bbr/build-SchemeEditor-Desktop-Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/bbr/build-SchemeEditor-Desktop-Release</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
<value type="int" key="QtQuickCompiler">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||||
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/bbr/build-SchemeEditor-Desktop-Profile</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/bbr/build-SchemeEditor-Desktop-Profile</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||||
|
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||||
|
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||||
|
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||||
|
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||||
|
<value type="int" key="QtQuickCompiler">0</value>
|
||||||
|
<value type="int" key="SeparateDebugInfo">0</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/bbr/SchemeEditor/SchemeEditor.pro</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/home/bbr/SchemeEditor/SchemeEditor.pro</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/bbr/build-SchemeEditor-Desktop-Debug</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="qlonglong">1</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
|
@ -1,66 +0,0 @@
|
||||||
//
|
|
||||||
// Created by bbr on 18. 04. 2022..
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "attribute_dialog.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
namespace display {
|
|
||||||
|
|
||||||
void AttributeDialog::onUpdate() {
|
|
||||||
auto oldValue = attributeValue->value;
|
|
||||||
|
|
||||||
attributeValue->value = value;
|
|
||||||
domain::ComdelValidator validator(domain::getSupportedValidators());
|
|
||||||
|
|
||||||
domain::ValidationContext context;
|
|
||||||
|
|
||||||
for (auto &addressSpace: MainWindow::getLibrary()->getAddressSpaces()) {
|
|
||||||
context.addressSpaces.insert(std::make_pair(addressSpace.getName(), addressSpace));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto validationErrors = validator.validateAttribute(attributeValue, context);
|
|
||||||
if(validationErrors.empty()) {
|
|
||||||
accept();
|
|
||||||
} else {
|
|
||||||
bool canAccept = true;
|
|
||||||
|
|
||||||
std::vector<domain::ValidationError> errors;
|
|
||||||
std::vector<domain::ValidationError> warnings;
|
|
||||||
for(auto& err: validationErrors) {
|
|
||||||
if(err.type == domain::Action::ERROR) {
|
|
||||||
errors.push_back(err);
|
|
||||||
} else {
|
|
||||||
warnings.push_back(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!errors.empty()) {
|
|
||||||
canAccept = false;
|
|
||||||
auto errorDialog = new ErrorDialog(errors);
|
|
||||||
errorDialog->exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto& warning: warnings) {
|
|
||||||
auto warningDialog = new WarningDialog(warning);
|
|
||||||
int response = warningDialog->exec();
|
|
||||||
if(response == QDialog::Rejected) {
|
|
||||||
canAccept = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(canAccept) {
|
|
||||||
accept();
|
|
||||||
} else {
|
|
||||||
attributeValue->value = oldValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MemoryDialog::onUpdate() {
|
|
||||||
attributeValue->value = value;
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,268 +0,0 @@
|
||||||
#ifndef ATTRIBUTE_DIALOG_H
|
|
||||||
#define ATTRIBUTE_DIALOG_H
|
|
||||||
|
|
||||||
#include <QIntValidator>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <utility>
|
|
||||||
#include <comdel/domain/instanceattribute.h>
|
|
||||||
|
|
||||||
#include <comdel/domain/value.h>
|
|
||||||
#include "comdel/domain/comdelvalidator.h"
|
|
||||||
|
|
||||||
namespace display {
|
|
||||||
|
|
||||||
class AttributeDialog: public QDialog {
|
|
||||||
domain::Value value;
|
|
||||||
|
|
||||||
long long int parseInt(std::string expression) {
|
|
||||||
try {
|
|
||||||
if (expression.size() > 2) {
|
|
||||||
if (expression.substr(0, 2) == "0x") {
|
|
||||||
return std::stoll(expression, 0, 16);
|
|
||||||
} else if (expression.substr(0, 2) == "0b") {
|
|
||||||
return std::stoll(expression, 0, 2);
|
|
||||||
} else {
|
|
||||||
return std::stoll(expression, 0, 10);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return std::stoll(expression, 0, 10);
|
|
||||||
}
|
|
||||||
} catch (std::exception &e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
domain::InstanceAttribute* attributeValue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AttributeDialog(domain::InstanceAttribute *attribute) {
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
attributeValue = attribute;
|
|
||||||
|
|
||||||
this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName()));
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
this->setLayout(layout);
|
|
||||||
auto popup = *attribute->attribute.getPopup();
|
|
||||||
|
|
||||||
layout->addWidget(new QLabel(popup.getTitle().c_str()));
|
|
||||||
layout->addWidget(new QLabel(popup.getText().c_str()));
|
|
||||||
|
|
||||||
auto type = attribute->attribute.getDefault().getType();
|
|
||||||
value = attribute->value;
|
|
||||||
|
|
||||||
if(attribute->attribute.getPopup()->isEnumerated()) {
|
|
||||||
auto* combo = new QComboBox(this);
|
|
||||||
auto enumeration = attribute->attribute.getPopup()->getEnumeration();
|
|
||||||
for(auto entry: enumeration) {
|
|
||||||
combo->addItem(QString::fromStdString(entry.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(combo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AttributeDialog::onEnumerationChanged);
|
|
||||||
layout->addWidget(combo);
|
|
||||||
|
|
||||||
for(int i=0; i<enumeration.size(); i++) {
|
|
||||||
if(attributeValue->value.equals(enumeration[i].getValue())) {
|
|
||||||
combo->setCurrentIndex(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(!(type == domain::Value::ValueType::WIRE_REFERENCE || type == domain::Value::ValueType::BOOL)) {
|
|
||||||
|
|
||||||
auto edit = new QLineEdit(this);
|
|
||||||
connect(edit, &QLineEdit::textChanged, this, &AttributeDialog::onTextChanged);
|
|
||||||
layout->addWidget(edit);
|
|
||||||
|
|
||||||
switch (attribute->attribute.getDefault().getType()) {
|
|
||||||
case domain::Value::ValueType::INT:
|
|
||||||
edit->setValidator(new QIntValidator(-10000000, 10000000, edit));
|
|
||||||
edit->insert(std::to_string(attribute->value.asInt()).c_str());
|
|
||||||
break;
|
|
||||||
case domain::Value::ValueType::STRING:
|
|
||||||
edit->insert(attribute->value.asString().c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(type == domain::Value::ValueType::BOOL) {
|
|
||||||
auto *group = new QGroupBox(this);
|
|
||||||
|
|
||||||
auto *radioLayout = new QHBoxLayout(group);
|
|
||||||
group->setLayout(radioLayout);
|
|
||||||
|
|
||||||
auto isTrue = new QRadioButton("true", group);
|
|
||||||
connect(isTrue, &QRadioButton::clicked, [this]() {
|
|
||||||
this->value = domain::Value::fromBool(true);
|
|
||||||
});
|
|
||||||
auto isFalse = new QRadioButton("false", group);
|
|
||||||
connect(isFalse, &QRadioButton::clicked, [this]() {
|
|
||||||
this->value = domain::Value::fromBool(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(attribute->value.asBool()) {
|
|
||||||
isTrue->setChecked(true);
|
|
||||||
} else {
|
|
||||||
isFalse->setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
radioLayout->addWidget(isTrue);
|
|
||||||
radioLayout->addWidget(isFalse);
|
|
||||||
layout->addWidget(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto button = new QPushButton("Ažuriraj");
|
|
||||||
connect(button, &QPushButton::clicked, this, &AttributeDialog::onUpdate);
|
|
||||||
|
|
||||||
layout->addWidget(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void onTextChanged(const QString& string) {
|
|
||||||
switch (value.getType()) {
|
|
||||||
case domain::Value::STRING:
|
|
||||||
value.setString(string.toStdString());
|
|
||||||
break;
|
|
||||||
case domain::Value::INT:
|
|
||||||
value = domain::Value::fromInt(parseInt(string.toStdString()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void onEnumerationChanged(int index) {
|
|
||||||
value = attributeValue->attribute.getPopup()->getEnumeration()[index].getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onUpdate();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class MemoryDialog: public QDialog {
|
|
||||||
domain::Value value;
|
|
||||||
|
|
||||||
domain::InstanceAttribute* attributeValue;
|
|
||||||
std::vector<std::string> memoryInstances;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MemoryDialog(domain::InstanceAttribute *attribute, std::vector<std::shared_ptr<domain::ComponentInstance>> instances) {
|
|
||||||
memoryInstances = std::vector<std::string>();
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
attributeValue = attribute;
|
|
||||||
|
|
||||||
this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName()));
|
|
||||||
|
|
||||||
for(auto& instance: instances) {
|
|
||||||
if(instance->component.getType() == domain::Component::MEMORY) {
|
|
||||||
memoryInstances.push_back(instance->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
this->setLayout(layout);
|
|
||||||
auto popup = *attribute->attribute.getPopup();
|
|
||||||
|
|
||||||
layout->addWidget(new QLabel(popup.getTitle().c_str()));
|
|
||||||
layout->addWidget(new QLabel(popup.getText().c_str()));
|
|
||||||
|
|
||||||
value = attribute->value;
|
|
||||||
|
|
||||||
auto* combo = new QComboBox(this);
|
|
||||||
for(auto& entry: memoryInstances) {
|
|
||||||
combo->addItem(QString::fromStdString(entry));
|
|
||||||
}
|
|
||||||
combo->addItem("null");
|
|
||||||
|
|
||||||
connect(combo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MemoryDialog::onMemoryChanged);
|
|
||||||
layout->addWidget(combo);
|
|
||||||
|
|
||||||
combo->setCurrentIndex(memoryInstances.size());
|
|
||||||
for(int i=0; i<memoryInstances.size(); i++) {
|
|
||||||
if(attributeValue->value.asMemoryReference().has_value() && attributeValue->value.asMemoryReference() == memoryInstances[i]) {
|
|
||||||
combo->setCurrentIndex(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto button = new QPushButton("Ažuriraj");
|
|
||||||
connect(button, &QPushButton::clicked, this, &MemoryDialog::onUpdate);
|
|
||||||
|
|
||||||
layout->addWidget(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
void onMemoryChanged(int index) {
|
|
||||||
if(index == memoryInstances.size()) {
|
|
||||||
value = domain::Value::fromMemoryReference(std::nullopt);
|
|
||||||
} else {
|
|
||||||
value = domain::Value::fromMemoryReference(memoryInstances[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void onUpdate();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ErrorDialog: public QDialog {
|
|
||||||
|
|
||||||
public:
|
|
||||||
ErrorDialog(std::vector<domain::ValidationError> errors) {
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
this->setWindowTitle("Greške");
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
this->setLayout(layout);
|
|
||||||
|
|
||||||
for(auto& err: errors) {
|
|
||||||
layout->addWidget(new QLabel(QString::fromStdString(err.message), this));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class WarningDialog: public QDialog {
|
|
||||||
|
|
||||||
public:
|
|
||||||
WarningDialog(domain::ValidationError error) {
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
this->setWindowTitle("Upozorenje");
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
|
||||||
this->setLayout(layout);
|
|
||||||
|
|
||||||
layout->addWidget(new QLabel(QString::fromStdString(error.message), this));
|
|
||||||
|
|
||||||
auto buttonLayout = new QHBoxLayout(this);
|
|
||||||
|
|
||||||
auto okButton = new QPushButton("U redu", this);
|
|
||||||
auto cancelButton = new QPushButton("Odustani", this);
|
|
||||||
|
|
||||||
connect(okButton, &QPushButton::clicked, [this]() { accept(); });
|
|
||||||
connect(cancelButton, &QPushButton::clicked, [this]() { reject(); });
|
|
||||||
|
|
||||||
buttonLayout->addWidget(okButton);
|
|
||||||
buttonLayout->addWidget(cancelButton);
|
|
||||||
|
|
||||||
layout->addItem(buttonLayout);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //ATTRIBUTE_DIALOG_H
|
|
|
@ -1,49 +1,80 @@
|
||||||
#include "component_display.h"
|
#include "component_display.h"
|
||||||
#include "attribute_dialog.h"
|
|
||||||
#include "name_dialog.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QGraphicsSceneContextMenuEvent>
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
ComponentWrapper *ComponentWrapper::ofWire(domain::WireInstance *wire) {
|
||||||
QMenu menu;
|
auto component = new ComponentWrapper();
|
||||||
menu.addAction("Izmjeni ime", [this](){
|
component->wireInstance = wire;
|
||||||
auto dialog = new NameDialog(this->instance.get());
|
component->redraw();
|
||||||
dialog->exec();
|
return component;
|
||||||
});
|
}
|
||||||
menu.addSeparator();
|
ComponentWrapper *ComponentWrapper::ofComponent(domain::ComponentInstance *instance) {
|
||||||
for(int i=0; i<this->instance->attributes.size(); i++) {
|
auto component = new ComponentWrapper();
|
||||||
auto* attr = &this->instance->attributes[i];
|
component->componentInstance = instance;
|
||||||
bool enabled = attr->attribute.getPopup().has_value();
|
component->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
component->componentItem = new ComponentItem(instance, component);
|
||||||
|
|
||||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
for(auto& pin: instance->component.getPins()) {
|
||||||
[attr]() {
|
component->pinItems.push_back(new PinItem(pin, component));
|
||||||
if(attr->value.getType() == domain::Value::MEMORY_REFERENCE) {
|
}
|
||||||
auto dialog = new MemoryDialog(attr, MainWindow::getSchema()->componentInstances);
|
|
||||||
dialog->exec();
|
component->redraw();
|
||||||
} else {
|
return component;
|
||||||
auto dialog = new AttributeDialog(attr);
|
}
|
||||||
dialog->exec();
|
ComponentWrapper *ComponentWrapper::ofBus(domain::BusInstance *instance) {
|
||||||
}
|
auto component = new ComponentWrapper();
|
||||||
});
|
component->busInstance = instance;
|
||||||
action->setEnabled(enabled);
|
component->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
component->redraw();
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
void ComponentWrapper::redraw() {
|
||||||
|
if(componentInstance) {
|
||||||
|
componentItem->redraw();
|
||||||
|
for(auto pinItem: pinItems) {
|
||||||
|
pinItem->redraw();
|
||||||
|
}
|
||||||
|
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(componentInstance->name)));
|
||||||
|
}
|
||||||
|
if(busInstance && busInstance->bus.getDisplay()) {
|
||||||
|
busInstance->bus.getDisplay()->render(this);
|
||||||
|
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(busInstance->name)));
|
||||||
|
}
|
||||||
|
if(wireInstance) {
|
||||||
|
wireInstance->display.render(this);
|
||||||
|
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(wireInstance->name)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentItem::ComponentItem(domain::ComponentInstance *instance, QGraphicsItem *parent): componentInstance(instance) {
|
||||||
|
setParentItem(parent);
|
||||||
|
redraw();
|
||||||
|
setToolTip(QString::fromStdString(this->componentInstance->component.getTooltip()));
|
||||||
|
}
|
||||||
|
void ComponentItem::redraw() {
|
||||||
|
componentInstance->component.getDisplay().render(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComponentItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||||
|
QMenu menu;
|
||||||
|
menu.addAction("Izmjeni ime");
|
||||||
|
menu.addSeparator();
|
||||||
|
for(auto attr: componentInstance->attributes) {
|
||||||
|
menu.addAction(QString::fromStdString("Izmjeni " + attr->name));
|
||||||
}
|
}
|
||||||
menu.exec(event->screenPos());
|
menu.exec(event->screenPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PinItem::PinItem(domain::Pin pin, QGraphicsItem *parent): pin(pin) {
|
||||||
void Bus::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
setParentItem(parent);
|
||||||
QMenu menu;
|
redraw();
|
||||||
menu.addAction("Izmjeni ime", [this](){
|
setToolTip(QString::fromStdString(pin.getTooltip()));
|
||||||
auto dialog = new NameDialog(this->busInstance.get());
|
}
|
||||||
dialog->exec();
|
void PinItem::redraw() {
|
||||||
});
|
pin.getDisplay().render(this);
|
||||||
menu.exec(event->screenPos());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace display
|
} // namespace display
|
||||||
|
|
|
@ -8,71 +8,46 @@
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
class Pin: public QGraphicsItemGroup
|
class ComponentItem: public QGraphicsItemGroup
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
ComponentItem(domain::ComponentInstance *instance, QGraphicsItem *parent);
|
||||||
|
void redraw();
|
||||||
|
private:
|
||||||
|
domain::ComponentInstance *componentInstance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PinItem: public QGraphicsItemGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PinItem(domain::Pin pin, QGraphicsItem *parent);
|
||||||
|
void redraw();
|
||||||
private:
|
private:
|
||||||
domain::Pin pin;
|
domain::Pin pin;
|
||||||
public:
|
|
||||||
Pin(domain::Pin pin): pin(pin) {
|
|
||||||
pin.getDisplay().render(this);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Component: public QGraphicsItemGroup
|
class ComponentWrapper: public QGraphicsItemGroup
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static ComponentWrapper *ofComponent(domain::ComponentInstance *instance);
|
||||||
|
static ComponentWrapper *ofBus(domain::BusInstance *instance);
|
||||||
|
static ComponentWrapper *ofWire(domain::WireInstance *wire);
|
||||||
|
|
||||||
|
ComponentWrapper() {
|
||||||
|
this->setHandlesChildEvents(false);
|
||||||
|
}
|
||||||
|
void redraw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<domain::ComponentInstance> instance;
|
domain::ComponentInstance *componentInstance = nullptr;
|
||||||
public:
|
domain::BusInstance *busInstance = nullptr;
|
||||||
Component(const std::shared_ptr<domain::ComponentInstance>& instance): instance(instance) {
|
domain::WireInstance *wireInstance = nullptr;
|
||||||
instance->component.getDisplay().render(this);
|
|
||||||
}
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Bus: public QGraphicsItemGroup
|
ComponentItem *componentItem;
|
||||||
{
|
std::vector<PinItem*> pinItems;
|
||||||
std::shared_ptr<domain::BusInstance> busInstance;
|
|
||||||
public:
|
|
||||||
Bus(const std::shared_ptr<domain::BusInstance>& instance): busInstance(instance) {
|
|
||||||
instance->bus.getDisplay()->render(this);
|
|
||||||
}
|
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ComponentGroup: public QGraphicsItemGroup
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::shared_ptr<domain::ComponentInstance> componentInstance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ComponentGroup(const std::shared_ptr<domain::ComponentInstance>& instance): componentInstance(instance) {
|
|
||||||
setFlag(ItemIsMovable, true);
|
|
||||||
setHandlesChildEvents(false);
|
|
||||||
|
|
||||||
addToGroup(new display::Component(instance));
|
|
||||||
|
|
||||||
for(auto &pin: instance->component.getPins()) {
|
|
||||||
addToGroup(new display::Pin(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
setPos(instance->position.first, instance->position.second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class BusGroup: public QGraphicsItemGroup
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::shared_ptr<domain::BusInstance> busInstance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit BusGroup(const std::shared_ptr<domain::BusInstance>& instance): busInstance(instance) {
|
|
||||||
setFlag(ItemIsMovable, true);
|
|
||||||
setHandlesChildEvents(false);
|
|
||||||
|
|
||||||
addToGroup(new display::Bus(instance));
|
|
||||||
|
|
||||||
setPos(instance->position.first, instance->position.second);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace display
|
} // namespace display
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
//
|
|
||||||
// Created by bbr on 18. 04. 2022..
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "name_dialog.h"
|
|
|
@ -1,64 +0,0 @@
|
||||||
#ifndef NAME_DIALOG_H
|
|
||||||
#define NAME_DIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
#include <comdel/domain/instance.h>
|
|
||||||
|
|
||||||
namespace display {
|
|
||||||
|
|
||||||
class NameDialog: public QDialog {
|
|
||||||
|
|
||||||
QLineEdit *edit = nullptr;
|
|
||||||
domain::ComponentInstance *componentInstance = nullptr;
|
|
||||||
domain::BusInstance *busInstance = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
NameDialog(domain::ComponentInstance *instance): componentInstance(instance) {
|
|
||||||
auto *layout = new QVBoxLayout(this);
|
|
||||||
layout->addWidget(new QLabel("Izmjeni ime", this));
|
|
||||||
|
|
||||||
edit = new QLineEdit(this);
|
|
||||||
edit->insert(instance->name.c_str());
|
|
||||||
layout->addWidget(edit);
|
|
||||||
this->setWindowTitle("Izmjeni ime");
|
|
||||||
auto *button = new QPushButton("Ažuriraj", this);
|
|
||||||
connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange);
|
|
||||||
layout->addWidget(button);
|
|
||||||
this->setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
NameDialog(domain::BusInstance *instance): busInstance(instance) {
|
|
||||||
auto *layout = new QVBoxLayout(this);
|
|
||||||
layout->addWidget(new QLabel("Izmjeni ime", this));
|
|
||||||
|
|
||||||
edit = new QLineEdit(this);
|
|
||||||
edit->insert(instance->name.c_str());
|
|
||||||
layout->addWidget(edit);
|
|
||||||
this->setWindowTitle("Izmjeni ime");
|
|
||||||
auto *button = new QPushButton("Ažuriraj", this);
|
|
||||||
connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange);
|
|
||||||
layout->addWidget(button);
|
|
||||||
this->setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void onNameChange() {
|
|
||||||
if(componentInstance != nullptr) {
|
|
||||||
componentInstance->name = this->edit->text().toStdString();
|
|
||||||
} else if(busInstance != nullptr) {
|
|
||||||
busInstance->name = this->edit->text().toStdString();
|
|
||||||
}
|
|
||||||
this->close();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif //NAME_DIALOG_H
|
|
|
@ -9,18 +9,30 @@ Schema::Schema()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Schema::setSchema(domain::Schema* _schema)
|
void Schema::setSchema(std::optional<domain::Schema> schema)
|
||||||
{
|
{
|
||||||
scene.clear();
|
scene.clear();
|
||||||
this->schema = _schema;
|
this->schema = schema;
|
||||||
if(schema != nullptr) {
|
if(schema.has_value()) {
|
||||||
for(auto &instance: schema->componentInstances) {
|
for(auto &instance: schema->instances) {
|
||||||
scene.addItem(new display::ComponentGroup(instance));
|
ComponentWrapper *group = nullptr;
|
||||||
}
|
auto component = dynamic_cast<domain::ComponentInstance*>(instance);
|
||||||
for(auto &instance: schema->busInstances) {
|
if(component) {
|
||||||
if(instance->bus.getDisplay().has_value()) {
|
group = ComponentWrapper::ofComponent(component);
|
||||||
scene.addItem(new display::BusGroup(instance));
|
|
||||||
}
|
}
|
||||||
|
auto bus = dynamic_cast<domain::BusInstance*>(instance);
|
||||||
|
if(bus) {
|
||||||
|
group = ComponentWrapper::ofBus(bus);
|
||||||
|
}
|
||||||
|
if(group != nullptr) {
|
||||||
|
group->setPos(instance->position.first, instance->position.second);
|
||||||
|
scene.addItem(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto &wire: schema->wires) {
|
||||||
|
auto group = ComponentWrapper::ofWire(wire);
|
||||||
|
group->setPos(wire->position.first, wire->position.second);
|
||||||
|
scene.addItem(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ class Schema: public QGraphicsView
|
||||||
public:
|
public:
|
||||||
Schema();
|
Schema();
|
||||||
|
|
||||||
void setSchema(domain::Schema* schema);
|
void setSchema(std::optional<domain::Schema> schema);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
|
|
||||||
domain::Schema* schema;
|
std::optional<domain::Schema> schema;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace display
|
} // namespace display
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <algorithm>
|
|
||||||
#include "addressspace.h"
|
#include "addressspace.h"
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
@ -10,10 +9,10 @@ AddressSpace::AddressSpace(std::string name, long long start, long long end):
|
||||||
std::string AddressSpace::getName() {
|
std::string AddressSpace::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
long long AddressSpace::getStart() const {
|
long long AddressSpace::getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
long long AddressSpace::getEnd() const {
|
long long AddressSpace::getEnd() {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ public:
|
||||||
AddressSpace(std::string name, long long start, long long end);
|
AddressSpace(std::string name, long long start, long long end);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
long long getStart() const;
|
long long getStart();
|
||||||
long long getEnd() const;
|
long long getEnd();
|
||||||
|
|
||||||
bool contains(long long int address);
|
bool contains(long long int address);
|
||||||
bool contains(long long int start, long long int end);
|
bool contains(long long int start, long long int end);
|
||||||
|
|
|
@ -6,7 +6,7 @@ Enumeration::Enumeration(std::string name, Value value)
|
||||||
: name(name), value(value)
|
: name(name), value(value)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string& Enumeration::getName() {
|
std::string Enumeration::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
Value Enumeration::getValue() {
|
Value Enumeration::getValue() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef DOMAIN_ATTRIBUTE_H
|
#ifndef DOMAIN_ATTRIBUTE_H
|
||||||
#define DOMAIN_ATTRIBUTE_H
|
#define DOMAIN_ATTRIBUTE_H
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
|
@ -15,7 +14,7 @@ class Enumeration {
|
||||||
public:
|
public:
|
||||||
Enumeration(std::string name, Value value);
|
Enumeration(std::string name, Value value);
|
||||||
|
|
||||||
std::string& getName();
|
std::string getName();
|
||||||
Value getValue();
|
Value getValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,11 +45,6 @@ public:
|
||||||
bool isEnumerated();
|
bool isEnumerated();
|
||||||
std::vector<Enumeration> &getEnumeration();
|
std::vector<Enumeration> &getEnumeration();
|
||||||
|
|
||||||
void setEnumeration(std::vector<Enumeration> enums) {
|
|
||||||
enumerated = true;
|
|
||||||
enumeration = std::move(enums);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Attribute
|
class Attribute
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
Wire::Wire(std::string name, WireType type, int width, bool hidden, bool hasTerminate, Value terminateWith)
|
Wire::Wire(std::string name, WireType type, int width, bool hidden, bool hasTermination, long long ifUnterminated)
|
||||||
: name(name), type(type), width(width), hidden(hidden), hasTerminate(hasTerminate), terminateWith(terminateWith)
|
: name(name), type(type), width(width), hidden(hidden), hasTermination(hasTermination), ifUnterminated(ifUnterminated)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string Wire::getName() {
|
std::string Wire::getName() {
|
||||||
|
@ -15,17 +15,18 @@ int Wire::getWidth() {
|
||||||
bool Wire::isHidden() {
|
bool Wire::isHidden() {
|
||||||
return hidden;
|
return hidden;
|
||||||
}
|
}
|
||||||
|
bool Wire::getHasTermination() {
|
||||||
bool Wire::hasTerminateWith() {
|
return hasTermination;
|
||||||
return hasTerminate;
|
|
||||||
}
|
}
|
||||||
Value Wire::getTerminateWith() {
|
long long Wire::getIfUnterminated() {
|
||||||
return terminateWith;
|
return ifUnterminated;
|
||||||
}
|
}
|
||||||
Wire::WireType Wire::getType() {
|
Wire::WireType Wire::getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bus::Bus(std::string name, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires, std::optional<Display> display)
|
Bus::Bus(std::string name, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires, std::optional<Display> display)
|
||||||
: name(name), tooltip(tooltip), type(type), count(count), wires(wires), display(display)
|
: name(name), tooltip(tooltip), type(type), count(count), wires(wires), display(display)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define DOMAIN_BUS_H
|
#define DOMAIN_BUS_H
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "value.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -27,17 +26,17 @@ private:
|
||||||
WireType type;
|
WireType type;
|
||||||
int width;
|
int width;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
bool hasTerminate;
|
bool hasTermination;
|
||||||
Value terminateWith;
|
long long ifUnterminated;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Wire(std::string name, WireType type, int width, bool hidden, bool hasTerminate, Value terminateWith);
|
Wire(std::string name, WireType type, int width, bool hidden, bool hasTermination, long long ifUnterminated);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
int getWidth();
|
int getWidth();
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
bool hasTerminateWith();
|
bool getHasTermination();
|
||||||
Value getTerminateWith();
|
long long getIfUnterminated();
|
||||||
WireType getType();
|
WireType getType();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ public:
|
||||||
enum BusType {
|
enum BusType {
|
||||||
AUTOMATIC,
|
AUTOMATIC,
|
||||||
REGULAR,
|
REGULAR,
|
||||||
SINGLE_AUTOMATIC
|
AUTOMATIC_SINGLE
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
|
@ -1,339 +0,0 @@
|
||||||
//
|
|
||||||
// Created by bbr on 08.05.22..
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
#include "comdel_generator.h"
|
|
||||||
|
|
||||||
namespace domain {
|
|
||||||
|
|
||||||
void generateSchemaFile(std::string& librarySource, Schema *schema, std::ostream &buffer) {
|
|
||||||
buffer << "@source " << librarySource << std::endl << std::endl;
|
|
||||||
|
|
||||||
buffer << "@schema {" << std::endl;
|
|
||||||
|
|
||||||
for(auto &componentInstance: schema->componentInstances) {
|
|
||||||
buffer << "\t" << "@instance " << componentInstance->name << " " << componentInstance->component.getName() << " {" << std::endl;
|
|
||||||
buffer << "\t\t" << "@position (" << componentInstance->position.first << ", " << componentInstance->position.second << ")" << std::endl;
|
|
||||||
|
|
||||||
for(auto &attribute: componentInstance->attributes) {
|
|
||||||
buffer << "\t\t" << "@attribute " << attribute.name << " " << attribute.value.stringify() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\t}" << std::endl << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &busInstance: schema->busInstances) {
|
|
||||||
buffer << "\t" << "@instance " << busInstance->name << " " << busInstance->bus.getName() << " {" << std::endl;
|
|
||||||
buffer << "\t\t" << "@position (" << busInstance->position.first << ", " << busInstance->position.second << ")" << std::endl;
|
|
||||||
buffer << "\t\t" << "@size " << busInstance->size << std::endl;
|
|
||||||
buffer << "\t}" << std::endl << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &conn: schema->connections) {
|
|
||||||
auto busConn = dynamic_cast<domain::BusConnectionInstance*>(conn.get());
|
|
||||||
if(busConn) {
|
|
||||||
buffer << "\t" << "@connection (" << busConn->instance->name << "." << busConn->connection.getComponent().pin << ", " << busConn->bus->name << ") {" << std::endl;
|
|
||||||
|
|
||||||
for(auto attribute: busConn->attributes) {
|
|
||||||
buffer << "\t\t" << "@attribute " << attribute.name << " " << attribute.value.stringify() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\t" << "}" << std::endl;
|
|
||||||
}
|
|
||||||
auto dirConn = dynamic_cast<domain::DirectConnectionInstance*>(conn.get());
|
|
||||||
if(dirConn) {
|
|
||||||
buffer << "\t" << "@connection (" << dirConn->instance->name << "." << dirConn->connection.getComponent().pin << ", "
|
|
||||||
<< dirConn->bus->name << ", "
|
|
||||||
<< dirConn->secondInstance->name << "." << dirConn->connection.getSecondComponent()->pin
|
|
||||||
<< ") {" << std::endl;
|
|
||||||
|
|
||||||
for(auto attribute: dirConn->attributes) {
|
|
||||||
buffer << "\t\t" << "@attribute " << attribute.name << " " << attribute.value.stringify() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\t" << "}" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "}" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<std::string> createImports(Schema *schema);
|
|
||||||
|
|
||||||
std::map<string, string> generateWires(Schema *schema, ostream &ostream);
|
|
||||||
|
|
||||||
void generateSubComponents(Schema *schema, map <string, string> &wires, ostream &buffer);
|
|
||||||
|
|
||||||
void generateDisplay(Schema *schema, ostream &buffer);
|
|
||||||
|
|
||||||
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer) {
|
|
||||||
buffer << library.getHeader() << std::endl;
|
|
||||||
|
|
||||||
std::set<std::string> imports = createImports(schema);
|
|
||||||
|
|
||||||
for(auto& import: imports) {
|
|
||||||
buffer << "#include \"" << library.getComponentDirectory() << "\\" << import << "\"" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\n\n" << std::endl;
|
|
||||||
|
|
||||||
buffer << "component System" << std::endl << "{" << std::endl;
|
|
||||||
|
|
||||||
if(library.getComponentHeader().has_value()) {
|
|
||||||
buffer << library.getComponentHeader().value() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wires = generateWires(schema, buffer);
|
|
||||||
|
|
||||||
generateSubComponents(schema, wires, buffer);
|
|
||||||
|
|
||||||
generateDisplay(schema, buffer);
|
|
||||||
|
|
||||||
buffer << "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateBus(BusInstance *bus, ostream &buffer);
|
|
||||||
|
|
||||||
void generateDisplay(Schema *schema, ostream &buffer) {
|
|
||||||
buffer << "\n\tdisplay {\n";
|
|
||||||
|
|
||||||
for(auto &component: schema->componentInstances) {
|
|
||||||
buffer << "\t\tcomponent { x: " << component->position.first << "; y: " << component->position.second << "; ref: \"" << component->name << "\"; }" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &bus: schema->busInstances) {
|
|
||||||
generateBus(bus.get(), buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\t}\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateBus(BusInstance *bus, ostream &buffer) {
|
|
||||||
buffer << "\n";
|
|
||||||
buffer << "\t\t// " << bus->name << " bus\n\n";
|
|
||||||
|
|
||||||
if(bus->bus.getDisplay().has_value()) {
|
|
||||||
bus->bus.getDisplay()->comdel(buffer, bus->position.first, bus->position.second, bus->size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateWire(std::string &name, Wire& wire, ostream &buffer);
|
|
||||||
|
|
||||||
std::map<string, string> generateWires(Schema *schema, ostream &buffer) {
|
|
||||||
std::set<string> usedNames;
|
|
||||||
std::map<string, string> usedMappings;
|
|
||||||
for(auto &bus: schema->busInstances) {
|
|
||||||
buffer << "\t//" << bus->name << std::endl;
|
|
||||||
for(auto& wire: bus->bus.getWires()) {
|
|
||||||
std::string name = wire.getName();
|
|
||||||
if(usedNames.count(wire.getName()) > 0) {
|
|
||||||
name = bus->name + "__" + wire.getName();
|
|
||||||
}
|
|
||||||
if(wire.isHidden()) {
|
|
||||||
name = "--" + name;
|
|
||||||
}
|
|
||||||
usedNames.insert(name);
|
|
||||||
usedMappings.insert(std::make_pair(bus->name + "." + wire.getName(), name));
|
|
||||||
|
|
||||||
generateWire(name, wire, buffer);
|
|
||||||
}
|
|
||||||
buffer << std::endl << std::endl;
|
|
||||||
}
|
|
||||||
return usedMappings;
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateWire(std::string &name, Wire& wire, ostream &buffer) {
|
|
||||||
buffer << "\t";
|
|
||||||
switch (wire.getType()) {
|
|
||||||
case Wire::R_WIRE:
|
|
||||||
buffer << "r_wire";
|
|
||||||
break;
|
|
||||||
case Wire::WIRED_AND:
|
|
||||||
buffer << "wired_and";
|
|
||||||
break;
|
|
||||||
case Wire::WIRED_OR:
|
|
||||||
buffer << "wired_or";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
buffer << "wire";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wire.getWidth() != 1) {
|
|
||||||
buffer << "<" << wire.getWidth() << ">";
|
|
||||||
}
|
|
||||||
buffer << " " << name << ";" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<std::string> createImports(Schema *schema) {
|
|
||||||
std::set<std::string> importSet;
|
|
||||||
for(auto &component: schema->componentInstances) {
|
|
||||||
importSet.insert(component->component.getSource());
|
|
||||||
}
|
|
||||||
return importSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateAutomaticPin(DirectConnectionInstance *connection, string name, string pin, map<string, string> wireNames, stringstream &buffer);
|
|
||||||
|
|
||||||
void generateSingleAutomaticPin(DirectConnectionInstance *instance, string name, string pin,
|
|
||||||
map <string, string> &wireNames,
|
|
||||||
stringstream &buffer);
|
|
||||||
|
|
||||||
void generateComponent(Schema *schema, map <string, string> &wires, ostream &buffer,
|
|
||||||
shared_ptr <ComponentInstance> &component);
|
|
||||||
|
|
||||||
void generateSubComponents(Schema *schema, map<string, string> &wires, ostream &buffer) {
|
|
||||||
|
|
||||||
buffer << "\t// components --------------------------------------------" << std::endl;
|
|
||||||
|
|
||||||
for(auto& component: schema->componentInstances) {
|
|
||||||
if(component->component.getType() == Component::MEMORY) {
|
|
||||||
generateComponent(schema, wires, buffer, component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(auto& component: schema->componentInstances) {
|
|
||||||
if(component->component.getType() != Component::MEMORY) {
|
|
||||||
generateComponent(schema, wires, buffer, component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateComponent(Schema *schema, map <string, string> &wires, ostream &buffer,
|
|
||||||
shared_ptr <ComponentInstance> &component) {
|
|
||||||
buffer << "\tsubcomponent " << component->component.getName() << " " << component->name;
|
|
||||||
|
|
||||||
std::optional<InstanceAttribute> memory;
|
|
||||||
|
|
||||||
std::vector<InstanceAttribute> attributes;
|
|
||||||
for(auto& attr: component->attributes) {
|
|
||||||
if(attr.name != "_memory") {
|
|
||||||
attributes.push_back(attr);
|
|
||||||
} else if(attr.name == "_memory" && attr.value.asMemoryReference().has_value()) {
|
|
||||||
memory = attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!attributes.empty()) {
|
|
||||||
buffer << "<";
|
|
||||||
buffer << attributes[0].value.stringify();
|
|
||||||
for(int i=1; i<attributes.size(); i++) {
|
|
||||||
buffer << ", " << attributes[i].value.stringify();
|
|
||||||
}
|
|
||||||
buffer << ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
stringstream tempOutput;
|
|
||||||
|
|
||||||
for(auto &pin: component->component.getPins()) {
|
|
||||||
if(schema->hasConnection(component->name, pin.getName())) {
|
|
||||||
auto conn = schema->getConnection(component->name, pin.getName());
|
|
||||||
auto busConn = dynamic_cast<BusConnectionInstance*>(conn);
|
|
||||||
if(busConn != nullptr) {
|
|
||||||
for(auto wire: busConn->connection.getWires()) {
|
|
||||||
if(wire.isType(Value::ATTRIBUTE_REFERENCE)) {
|
|
||||||
auto attribute = busConn->getAttribute(wire.asReference());
|
|
||||||
if(wire.isType(Value::WIRE_REFERENCE)) {
|
|
||||||
tempOutput << wires[busConn->bus->name + "." + attribute.value.asReference()] << ", ";
|
|
||||||
} else if(wire.isType(Value::NIL)) {
|
|
||||||
tempOutput << "*, ";
|
|
||||||
} else {
|
|
||||||
tempOutput << attribute.value.stringify() << ", ";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(wire.isType(Value::WIRE_REFERENCE)) {
|
|
||||||
tempOutput << wires[busConn->bus->name + "." + wire.asReference()] << ", ";
|
|
||||||
} else if(wire.isType(Value::NIL)) {
|
|
||||||
tempOutput << "*, ";
|
|
||||||
} else {
|
|
||||||
tempOutput << wire.stringify() << ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto dirConn = dynamic_cast<DirectConnectionInstance*>(conn);
|
|
||||||
if(dirConn != nullptr) {
|
|
||||||
if(dirConn->bus->bus.getType() == Bus::AUTOMATIC) {
|
|
||||||
generateAutomaticPin(dirConn, component->name, pin.getName(), wires, tempOutput);
|
|
||||||
} else {
|
|
||||||
generateSingleAutomaticPin(dirConn, component->name, pin.getName(), wires, tempOutput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// if no connection exists than defaults must exist
|
|
||||||
for(auto& wire: *pin.getWires()) {
|
|
||||||
tempOutput << wire.stringify() << ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wireList = tempOutput.str();
|
|
||||||
wireList.pop_back();
|
|
||||||
wireList.pop_back(); // remove last COMMA(", ")
|
|
||||||
|
|
||||||
buffer << "(" << wireList << ")";
|
|
||||||
|
|
||||||
if(memory.has_value()) {
|
|
||||||
buffer << " uses " << *memory->value.asMemoryReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << ";" << std::endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateSingleAutomaticPin(DirectConnectionInstance *connection, string name, string pin, map <string, string> &wireNames, stringstream &buffer) {
|
|
||||||
std::vector<Value> wires;
|
|
||||||
std::string selected;
|
|
||||||
std::vector<Value> defaults;
|
|
||||||
if(connection->instance->name == name && connection->connection.getComponent().pin == pin) {
|
|
||||||
wires = connection->connection.getWires();
|
|
||||||
selected = connection->attributes[0].value.asReference();
|
|
||||||
defaults = *connection->instance->component.getPin(pin).getWires();
|
|
||||||
} else {
|
|
||||||
wires = *connection->connection.getSecondWires();
|
|
||||||
selected = connection->attributes[1].value.asReference();
|
|
||||||
defaults = *connection->secondInstance->component.getPin(pin).getWires();
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<wires.size(); i++) {
|
|
||||||
if(wires[i].isType(Value::STRING)) {
|
|
||||||
if(wires[i].asString() == selected) {
|
|
||||||
buffer << wireNames[connection->bus->name + "." + connection->bus->bus.getWires()[0].getName()] << ", ";
|
|
||||||
} else {
|
|
||||||
buffer << defaults[i].stringify();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buffer << wires[i].stringify() << ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateAutomaticPin(DirectConnectionInstance *connection, string name, string pin, map<string, string> wireNames, stringstream &buffer) {
|
|
||||||
std::vector<Value> wires;
|
|
||||||
if(connection->instance->name == name && connection->connection.getComponent().pin == pin) {
|
|
||||||
wires = connection->connection.getWires();
|
|
||||||
} else {
|
|
||||||
wires = *connection->connection.getSecondWires();
|
|
||||||
}
|
|
||||||
for(auto& wire: wires) {
|
|
||||||
if(wire.isType(Value::ATTRIBUTE_REFERENCE)) {
|
|
||||||
auto attribute = connection->getAttribute(wire.asReference());
|
|
||||||
if(wire.isType(Value::WIRE_REFERENCE)) {
|
|
||||||
buffer << wireNames[connection->bus->name + "." + attribute.value.asReference()] << ", ";
|
|
||||||
} else if(wire.isType(Value::NIL)) {
|
|
||||||
buffer << "*, ";
|
|
||||||
} else {
|
|
||||||
buffer << attribute.value.stringify() << ", ";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(wire.isType(Value::WIRE_REFERENCE)) {
|
|
||||||
buffer << wireNames[connection->bus->name + "." + wire.asReference()] << ", ";
|
|
||||||
} else if(wire.isType(Value::NIL)) {
|
|
||||||
buffer << "*, ";
|
|
||||||
} else {
|
|
||||||
buffer << wire.stringify() << ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // domain
|
|
|
@ -1,16 +0,0 @@
|
||||||
#ifndef COMDEL_GENERATOR_H
|
|
||||||
#define COMDEL_GENERATOR_H
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include "schema.h"
|
|
||||||
#include "library.h"
|
|
||||||
|
|
||||||
namespace domain {
|
|
||||||
|
|
||||||
void generateSchemaFile(std::string& librarySource, Schema *schema, std::ostream &buffer);
|
|
||||||
|
|
||||||
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer);
|
|
||||||
|
|
||||||
} // domain
|
|
||||||
|
|
||||||
#endif //COMDEL_GENERATOR_H
|
|
|
@ -8,21 +8,24 @@ std::vector<ValidationError> ComdelValidator::validateSchema(Schema &schema, Val
|
||||||
context.instance = nullptr;
|
context.instance = nullptr;
|
||||||
context.attribute = nullptr;
|
context.attribute = nullptr;
|
||||||
|
|
||||||
for(auto &instance: schema.componentInstances) {
|
for(auto &inst: schema.instances) {
|
||||||
auto result = validateComponent(instance.get(), context);
|
auto *instance = dynamic_cast<ComponentInstance*>(inst);
|
||||||
errors.insert(errors.end(), result.begin(), result.end());
|
if(instance) {
|
||||||
|
auto result = validateComponent(instance, context);
|
||||||
|
errors.insert(errors.end(), result.begin(), result.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ValidationError> ComdelValidator::validateComponent(ComponentInstance* instance, ValidationContext context) {
|
std::vector<ValidationError> ComdelValidator::validateComponent(ComponentInstance *instance, ValidationContext context) {
|
||||||
std::vector<ValidationError> errors;
|
std::vector<ValidationError> errors;
|
||||||
|
|
||||||
context.instance = instance;
|
context.instance = instance;
|
||||||
context.attributes.clear();
|
context.attributes.clear();
|
||||||
|
|
||||||
for(auto &attribute: instance->attributes) {
|
for(auto &attribute: instance->attributes) {
|
||||||
context.attributes[attribute.name] = attribute.value;
|
context.attributes[attribute->name] = attribute->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto &rule: instance->component.getRules()) {
|
for(auto &rule: instance->component.getRules()) {
|
||||||
|
@ -33,7 +36,7 @@ std::vector<ValidationError> ComdelValidator::validateComponent(ComponentInstanc
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto &attribute: instance->attributes) {
|
for(auto &attribute: instance->attributes) {
|
||||||
auto result = validateAttribute(&attribute, context);
|
auto result = validateAttribute(attribute, context);
|
||||||
errors.insert(errors.end(), result.begin(), result.end());
|
errors.insert(errors.end(), result.begin(), result.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ std::optional<ValidationError> ComdelValidator::validateRule(Rule rule, Validati
|
||||||
RuleContext ruleContext;
|
RuleContext ruleContext;
|
||||||
ruleContext.addressSpaces = context.addressSpaces;
|
ruleContext.addressSpaces = context.addressSpaces;
|
||||||
ruleContext.attributes = context.attributes;
|
ruleContext.attributes = context.attributes;
|
||||||
ruleContext.function = validators;
|
ruleContext.function = callbacks;
|
||||||
auto action = rule.evaluate(ruleContext);
|
auto action = rule.evaluate(ruleContext);
|
||||||
if (action) {
|
if (action) {
|
||||||
std::string message = this->populateMessage(action->getMessage(), context);
|
std::string message = this->populateMessage(action->getMessage(), context);
|
||||||
|
|
|
@ -8,14 +8,14 @@ namespace domain {
|
||||||
|
|
||||||
struct ValidationError
|
struct ValidationError
|
||||||
{
|
{
|
||||||
ComponentInstance *instance;
|
Instance *instance;
|
||||||
InstanceAttribute *attribute;
|
InstanceAttribute *attribute;
|
||||||
Action::ActionType type;
|
Action::ActionType type;
|
||||||
std::string message;
|
std::string message;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ValidationContext {
|
struct ValidationContext {
|
||||||
ComponentInstance *instance;
|
Instance *instance;
|
||||||
InstanceAttribute *attribute;
|
InstanceAttribute *attribute;
|
||||||
std::map<std::string, AddressSpace> addressSpaces;
|
std::map<std::string, AddressSpace> addressSpaces;
|
||||||
std::map<std::string, Value> attributes;
|
std::map<std::string, Value> attributes;
|
||||||
|
@ -29,19 +29,14 @@ public:
|
||||||
std::vector<ValidationError> validateAttribute(InstanceAttribute *attribute, ValidationContext context);
|
std::vector<ValidationError> validateAttribute(InstanceAttribute *attribute, ValidationContext context);
|
||||||
std::optional<ValidationError> validateRule(Rule rule, ValidationContext context);
|
std::optional<ValidationError> validateRule(Rule rule, ValidationContext context);
|
||||||
|
|
||||||
ComdelValidator(std::vector<FunctionValidator*> validators) {
|
ComdelValidator(std::map<std::string, FunctionCallback> callbacks): callbacks(callbacks) {}
|
||||||
for(auto* validator: validators) {
|
|
||||||
validator->clear();
|
|
||||||
this->validators.insert(std::make_pair(validator->getName(), validator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, FunctionValidator*> validators;
|
std::map<std::string, FunctionCallback> callbacks;
|
||||||
|
|
||||||
std::string populateMessage(string message, ValidationContext context);
|
std::string populateMessage(string basicString, ValidationContext context);
|
||||||
|
|
||||||
string replacePlaceholder(string message, const string name, Value value);
|
string replacePlaceholder(string basicString, const string basicString1, Value value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,13 +67,7 @@ Attribute Component::getAttribute(std::string attribute) {
|
||||||
}
|
}
|
||||||
bool Component::hasAttribute(std::string name, Value::ValueType type) {
|
bool Component::hasAttribute(std::string name, Value::ValueType type) {
|
||||||
for(uint i=0; i<attributes.size(); i++) {
|
for(uint i=0; i<attributes.size(); i++) {
|
||||||
if(attributes[i].getName() == name && attributes[i].getDefault().getType() == type) {
|
if(attributes[i].getName() == name && attributes[i].getDefault().getType() == type) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(attributes[i].getName() == name && (type == Value::NIL && (attributes[i].getDefault().getType() == Value::MEMORY_REFERENCE || attributes[i].getDefault().getType() == Value::WIRE_REFERENCE))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(attributes[i].getName() == name && (type == Value::UNDEFINED && (attributes[i].getDefault().getType() == Value::MEMORY_REFERENCE || attributes[i].getDefault().getType() == Value::WIRE_REFERENCE))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,16 @@
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
|
|
||||||
ConnectionInstance::ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute> attributes, Connection connection)
|
ConnectionInstance::ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, WireInstance *wire, Connection connection)
|
||||||
: instance(instance), attributes(attributes), connection(connection)
|
: instance(instance), attributes(attributes), connection(connection), wire(wire)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InstanceAttribute ConnectionInstance::getAttribute(string attribute) {
|
BusConnectionInstance::BusConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, BusInstance *bus, WireInstance *wire, Connection connection)
|
||||||
for(auto& attr: attributes) {
|
: ConnectionInstance(instance, attributes, wire, connection), bus(bus)
|
||||||
if(attr.name == attribute) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BusConnectionInstance::BusConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute> attributes, BusInstance *bus, Connection connection)
|
|
||||||
: ConnectionInstance(instance, attributes, connection), bus(bus)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DirectConnectionInstance::DirectConnectionInstance(ComponentInstance *instance, ComponentInstance *secondInstance, std::vector<InstanceAttribute> attributes, BusInstance *bus, Connection connection)
|
DirectConnectionInstance::DirectConnectionInstance(ComponentInstance *instance, ComponentInstance *secondInstance, std::vector<InstanceAttribute*> attributes, BusInstance *bus, WireInstance *wire, Connection connection)
|
||||||
: ConnectionInstance(instance, attributes, connection), secondInstance(secondInstance), bus(bus)
|
: ConnectionInstance(instance, attributes, wire, connection), secondInstance(secondInstance), bus(bus)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -14,14 +14,11 @@ class ConnectionInstance
|
||||||
public:
|
public:
|
||||||
ComponentInstance *instance;
|
ComponentInstance *instance;
|
||||||
Connection connection;
|
Connection connection;
|
||||||
|
WireInstance *wire;
|
||||||
|
|
||||||
virtual ~ConnectionInstance() = default;
|
std::vector<InstanceAttribute*> attributes;
|
||||||
|
|
||||||
std::vector<InstanceAttribute> attributes;
|
ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, WireInstance *wire, Connection connection);
|
||||||
|
|
||||||
ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute> attributes, Connection connection);
|
|
||||||
|
|
||||||
InstanceAttribute getAttribute(string attribute);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +27,7 @@ class BusConnectionInstance: public ConnectionInstance
|
||||||
public:
|
public:
|
||||||
BusInstance *bus;
|
BusInstance *bus;
|
||||||
|
|
||||||
BusConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute> attributes, BusInstance *bus, Connection connection);
|
BusConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, BusInstance *bus, WireInstance *wire, Connection connection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +37,7 @@ public:
|
||||||
BusInstance *bus;
|
BusInstance *bus;
|
||||||
ComponentInstance *secondInstance;
|
ComponentInstance *secondInstance;
|
||||||
|
|
||||||
DirectConnectionInstance(ComponentInstance *instance, ComponentInstance *secondsInstance, std::vector<InstanceAttribute> attributes, BusInstance *bus, Connection connection);
|
DirectConnectionInstance(ComponentInstance *instance, ComponentInstance *secondsInstance, std::vector<InstanceAttribute*> attributes, BusInstance *bus, WireInstance *wire, Connection connection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
@ -19,14 +17,6 @@ public:
|
||||||
void render(QGraphicsItemGroup *group) {
|
void render(QGraphicsItemGroup *group) {
|
||||||
group->addToGroup(new QGraphicsRectItem(x,y,w,h));
|
group->addToGroup(new QGraphicsRectItem(x,y,w,h));
|
||||||
}
|
}
|
||||||
|
|
||||||
void comdel(std::ostream &buffer, int x, int y, int size) {
|
|
||||||
buffer << "\t\trectangle {\n";
|
|
||||||
buffer << "\t\t\tx: " << (this->x + x) << "; y: " << (this->y + y) << ";\n";
|
|
||||||
buffer << "\t\t\tw: " << w << "; h: " << h << ";\n";
|
|
||||||
buffer << "\t\t}\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Line {
|
class Line {
|
||||||
|
@ -38,13 +28,6 @@ public:
|
||||||
void render(QGraphicsItemGroup *group) {
|
void render(QGraphicsItemGroup *group) {
|
||||||
group->addToGroup(new QGraphicsLineItem(x1, y1, x2, y2));
|
group->addToGroup(new QGraphicsLineItem(x1, y1, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void comdel(std::ostream &buffer, int x, int y, int size) {
|
|
||||||
buffer << "\t\tline {\n";
|
|
||||||
buffer << "\t\t\tx1: " << (x1 + x) << "; y1: " << (y1 + y) << ";\n";
|
|
||||||
buffer << "\t\t\tx2: " << (x2 + x) << "; y2: " << (y2 + y) << ";\n";
|
|
||||||
buffer << "\t\t}\n\n";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Orientation {
|
enum Orientation {
|
||||||
|
@ -82,11 +65,6 @@ public:
|
||||||
std::optional<Rect> rect = std::nullopt;
|
std::optional<Rect> rect = std::nullopt;
|
||||||
std::optional<Line> line = std::nullopt;
|
std::optional<Line> line = std::nullopt;
|
||||||
std::optional<Pin> pin = std::nullopt;
|
std::optional<Pin> pin = std::nullopt;
|
||||||
|
|
||||||
void comdel(std::ostream &buffer, int x, int y, int size) {
|
|
||||||
if(rect) rect->comdel(buffer, x, y, size);
|
|
||||||
if(line) line->comdel(buffer, x, y, size);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,12 +81,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void comdel(std::ostream &buffer, int x, int y, int size) {
|
|
||||||
for(auto &item: items) {
|
|
||||||
item.comdel(buffer, x, y, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ui::Item> items;
|
std::vector<ui::Item> items;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,138 +1,45 @@
|
||||||
#include <map>
|
|
||||||
#include "functionsignature.h"
|
#include "functionsignature.h"
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
class DivisibleValidator: public FunctionValidator {
|
FunctionSignature add(std::string name, std::vector<Value::ValueType> types, FunctionCallback callback) {
|
||||||
public:
|
return {name, types, callback};
|
||||||
DivisibleValidator(): FunctionValidator("divisible", {Value::INT, Value::INT}) {}
|
}
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
std::vector<FunctionSignature> getSupportedFunctions() {
|
||||||
if(validateSignature(values)) {
|
std::vector<FunctionSignature> s;
|
||||||
long long first = values[0].asInt();
|
s.push_back(add("divisible", std::vector<Value::ValueType>{Value::INT, Value::INT},[](std::vector<Value> values) {
|
||||||
long long second = values[1].asInt();
|
long long first = values[0].asInt();
|
||||||
return (first % second) == 0;
|
long long second = values[1].asInt();
|
||||||
}
|
return (first % second) == 0;
|
||||||
return false;
|
}));
|
||||||
}
|
s.push_back(add("less_then", std::vector<Value::ValueType>{Value::INT, Value::INT}, [](std::vector<Value> values) {
|
||||||
void clear() override {}
|
long long first = values[0].asInt();
|
||||||
};
|
long long second = values[1].asInt();
|
||||||
|
return first < second;
|
||||||
|
}));
|
||||||
|
s.push_back(add("greater_then", std::vector<Value::ValueType>{Value::INT, Value::INT}, [](std::vector<Value> values) {
|
||||||
|
long long first = values[0].asInt();
|
||||||
|
long long second = values[1].asInt();
|
||||||
|
return first > second;
|
||||||
|
}));
|
||||||
|
s.push_back(add("contains_address", std::vector<Value::ValueType>{Value::ADDRESS_SPACE, Value::INT}, [](std::vector<Value> values) {
|
||||||
|
AddressSpace space = values[0].asAddressSpace();
|
||||||
|
long long address = values[1].asInt();
|
||||||
|
return space.contains(address);
|
||||||
|
}));
|
||||||
|
s.push_back(add("contains", std::vector<Value::ValueType>{Value::ADDRESS_SPACE, Value::INT, Value::INT}, [](std::vector<Value> values) {
|
||||||
|
AddressSpace space = values[0].asAddressSpace();
|
||||||
|
long long start = values[1].asInt();
|
||||||
|
long long size = values[1].asInt();
|
||||||
|
return space.contains(start, start + size);
|
||||||
|
}));
|
||||||
|
s.push_back(add("unique", std::vector<Value::ValueType>{Value::ADDRESS_SPACE, Value::INT, Value::INT}, [](std::vector<Value> values) {
|
||||||
|
return true;
|
||||||
|
}));
|
||||||
|
|
||||||
class LessThenValidator: public FunctionValidator {
|
return s;
|
||||||
public:
|
|
||||||
LessThenValidator(): FunctionValidator("less_then", {Value::INT, Value::INT}) {}
|
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
|
||||||
if(validateSignature(values)) {
|
|
||||||
long long first = values[0].asInt();
|
|
||||||
long long second = values[1].asInt();
|
|
||||||
return first < second;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear() override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GreaterThenValidator: public FunctionValidator {
|
|
||||||
public:
|
|
||||||
GreaterThenValidator(): FunctionValidator("greater_then", {Value::INT, Value::INT}) {}
|
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
|
||||||
if(validateSignature(values)) {
|
|
||||||
long long first = values[0].asInt();
|
|
||||||
long long second = values[1].asInt();
|
|
||||||
return first > second;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear() override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ContainsAddressValidator: public FunctionValidator {
|
|
||||||
public:
|
|
||||||
ContainsAddressValidator(): FunctionValidator("contains_address", {Value::ADDRESS_SPACE, Value::INT}) {}
|
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
|
||||||
if(validateSignature(values)) {
|
|
||||||
AddressSpace space = values[0].asAddressSpace();
|
|
||||||
long long address = values[1].asInt();
|
|
||||||
return space.contains(address);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear() override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ContainsValidator: public FunctionValidator {
|
|
||||||
public:
|
|
||||||
ContainsValidator(): FunctionValidator("contains", {Value::ADDRESS_SPACE, Value::INT, Value::INT}) {}
|
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
|
||||||
if(validateSignature(values)) {
|
|
||||||
AddressSpace space = values[0].asAddressSpace();
|
|
||||||
long long start = values[1].asInt();
|
|
||||||
long long size = values[1].asInt();
|
|
||||||
return space.contains(start, start + size);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear() override {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UniqueValidator: public FunctionValidator {
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<std::string, std::vector<std::pair<long long int, long long int>>> spaces;
|
|
||||||
|
|
||||||
bool overlaps(long long int start1, long long int end1, long long int start2, long long int end2) {
|
|
||||||
return std::max((long long int)0, std::min(end1, end2) - std::max(start1, start2)) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
UniqueValidator(): FunctionValidator("unique", {Value::ADDRESS_SPACE, Value::INT, Value::INT}) {}
|
|
||||||
|
|
||||||
bool validate(std::vector<Value> values) override {
|
|
||||||
if(validateSignature(values)) {
|
|
||||||
std::string space = values[0].asAddressSpace().getName();
|
|
||||||
long long int start = values[1].asInt();
|
|
||||||
long long int end = start + values[2].asInt();
|
|
||||||
if(spaces.count(space) == 0) {
|
|
||||||
spaces.insert(std::make_pair(space, std::vector<std::pair<long long int, long long int>>{}));
|
|
||||||
}
|
|
||||||
for(auto& s: spaces[space]) {
|
|
||||||
if(overlaps(s.first, s.second, start, end)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spaces[space].push_back(std::make_pair(start, end));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear() override {
|
|
||||||
spaces.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<FunctionValidator*> getSupportedValidators() {
|
|
||||||
std::vector<FunctionValidator*> validators;
|
|
||||||
|
|
||||||
validators.push_back(new DivisibleValidator());
|
|
||||||
validators.push_back(new LessThenValidator());
|
|
||||||
validators.push_back(new GreaterThenValidator());
|
|
||||||
validators.push_back(new ContainsAddressValidator());
|
|
||||||
validators.push_back(new ContainsValidator());
|
|
||||||
validators.push_back(new UniqueValidator());
|
|
||||||
|
|
||||||
return validators;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef DOMAIN_FUNCTION_VALIDATOR_H
|
#ifndef DOMAIN_FUNCTION_SIGNATURE_H
|
||||||
#define DOMAIN_FUNCTION_VALIDATOR_H
|
#define DOMAIN_FUNCTION_SIGNATURE_H
|
||||||
|
|
||||||
#include<functional>
|
#include<functional>
|
||||||
#include<vector>
|
#include<vector>
|
||||||
|
@ -8,46 +8,18 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
class FunctionValidator {
|
typedef std::function<bool (std::vector<Value>)> FunctionCallback;
|
||||||
private:
|
|
||||||
|
struct FunctionSignature {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<Value::ValueType> signature;
|
std::vector<Value::ValueType> params;
|
||||||
|
FunctionCallback callback;
|
||||||
|
|
||||||
protected:
|
FunctionSignature(std::string name, std::vector<Value::ValueType> params, FunctionCallback callback): name(name), params(params), callback(callback) {}
|
||||||
FunctionValidator(std::string name, std::vector<Value::ValueType> signature) {
|
|
||||||
this->name = name;
|
|
||||||
this->signature = signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
std::string getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Value::ValueType> getSignature() {
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validateSignature(std::vector<Value> signature) {
|
|
||||||
if(this->signature.size() != signature.size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<this->signature.size(); i++) {
|
|
||||||
if(this->signature[i] != signature[i].getType()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool validate(std::vector<Value> values) = 0;
|
|
||||||
virtual void clear() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<FunctionValidator*> getSupportedValidators();
|
std::vector<FunctionSignature> getSupportedFunctions();
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
||||||
#endif // DOMAIN_FUNCTION_VALIDATOR_H
|
#endif // DOMAIN_FUNCTIONSIGNATURE_H
|
||||||
|
|
|
@ -2,11 +2,15 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
BusInstance::BusInstance(std::string name, std::pair<int, int> position, Bus bus, int size)
|
|
||||||
: name(name), position(position), bus(bus), size(size)
|
Instance::Instance(std::string name, std::vector<InstanceAttribute*> attributes, std::pair<int, int> position)
|
||||||
|
: name(name), attributes(attributes), position(position)
|
||||||
{}
|
{}
|
||||||
ComponentInstance::ComponentInstance(std::string name, std::vector<InstanceAttribute> attributes, std::pair<int, int> position, Component component)
|
BusInstance::BusInstance(std::string name, std::pair<int, int> position, Bus bus, int size)
|
||||||
: name(name), attributes(std::move(attributes)), position(position), component(component)
|
: Instance(name, vector<InstanceAttribute*>(), position), bus(bus), size(size)
|
||||||
|
{}
|
||||||
|
ComponentInstance::ComponentInstance(std::string name, std::vector<InstanceAttribute*> attributes, std::pair<int, int> position, Component component)
|
||||||
|
: Instance(name, attributes, position), component(component)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,32 +12,41 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
class BusInstance
|
class Instance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::vector<InstanceAttribute*> attributes;
|
||||||
std::pair<int, int> position;
|
std::pair<int, int> position;
|
||||||
|
|
||||||
|
virtual ~Instance() {};
|
||||||
|
|
||||||
|
Instance(std::string name, std::vector<InstanceAttribute*> attributes, std::pair<int, int> position);
|
||||||
|
};
|
||||||
|
|
||||||
|
class BusInstance: public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
Bus bus;
|
Bus bus;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
BusInstance(std::string name, std::pair<int, int> position, Bus bus, int size);
|
BusInstance(std::string name, std::pair<int, int> position, Bus bus, int size);
|
||||||
|
|
||||||
virtual ~BusInstance() = default;
|
virtual ~BusInstance() {
|
||||||
|
Instance::~Instance();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ComponentInstance
|
class ComponentInstance: public Instance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string name;
|
|
||||||
std::vector<InstanceAttribute> attributes;
|
|
||||||
std::pair<int, int> position;
|
|
||||||
|
|
||||||
Component component;
|
Component component;
|
||||||
|
|
||||||
ComponentInstance(std::string name, std::vector<InstanceAttribute> attributes, std::pair<int, int> position, Component component);
|
ComponentInstance(std::string name, std::vector<InstanceAttribute*> attributes, std::pair<int, int> position, Component component);
|
||||||
|
|
||||||
virtual ~ComponentInstance() = default;
|
virtual ~ComponentInstance() {
|
||||||
|
Instance::~Instance();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -15,11 +15,10 @@ class InstanceAttribute
|
||||||
public:
|
public:
|
||||||
InstanceAttribute(std::string name, Value value, Attribute attribute);
|
InstanceAttribute(std::string name, Value value, Attribute attribute);
|
||||||
|
|
||||||
std::string name = "";
|
std::string name;
|
||||||
Value value;
|
Value value;
|
||||||
Attribute attribute;
|
Attribute attribute;
|
||||||
|
|
||||||
~InstanceAttribute() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
Library::Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<std::string> componentHeader,
|
Library::Library(string name, string libraryInfo, string header, string componentDirectory,
|
||||||
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connections, map<string, string> messages)
|
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connections, map<string, string> messages)
|
||||||
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), componentHeader(componentHeader), addressSpaces(addressSpaces),
|
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), addressSpaces(addressSpaces),
|
||||||
components(components), buses(buses), connections(connections), messages(messages)
|
components(components), buses(buses), connections(connections), messages(messages)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -20,9 +20,6 @@ std::string Library::getHeader() {
|
||||||
std::string Library::getComponentDirectory() {
|
std::string Library::getComponentDirectory() {
|
||||||
return componentDirectory;
|
return componentDirectory;
|
||||||
}
|
}
|
||||||
std::optional<std::string> Library::getComponentHeader() {
|
|
||||||
return componentHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<AddressSpace> Library::getAddressSpaces() {
|
std::vector<AddressSpace> Library::getAddressSpaces() {
|
||||||
return addressSpaces;
|
return addressSpaces;
|
||||||
|
|
|
@ -21,7 +21,6 @@ class Library
|
||||||
std::string libraryInfo;
|
std::string libraryInfo;
|
||||||
std::string header;
|
std::string header;
|
||||||
std::string componentDirectory;
|
std::string componentDirectory;
|
||||||
std::optional<std::string> componentHeader;
|
|
||||||
|
|
||||||
std::vector<AddressSpace> addressSpaces;
|
std::vector<AddressSpace> addressSpaces;
|
||||||
std::vector<Component> components;
|
std::vector<Component> components;
|
||||||
|
@ -31,14 +30,13 @@ class Library
|
||||||
std::map<std::string, std::string> messages;
|
std::map<std::string, std::string> messages;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<string> componentHeader,
|
Library(string name, string libraryInfo, string header, string componentDirectory,
|
||||||
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connection, map<string, string> messages);
|
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connection, map<string, string> messages);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
std::string getLibraryInfo();
|
std::string getLibraryInfo();
|
||||||
std::string getHeader();
|
std::string getHeader();
|
||||||
std::string getComponentDirectory();
|
std::string getComponentDirectory();
|
||||||
std::optional<std::string> getComponentHeader();
|
|
||||||
|
|
||||||
std::vector<AddressSpace> getAddressSpaces();
|
std::vector<AddressSpace> getAddressSpaces();
|
||||||
std::vector<Component> getComponents();
|
std::vector<Component> getComponents();
|
||||||
|
|
|
@ -18,7 +18,7 @@ Pin::Pin(std::string name, PinType type, std::string tooltip, PinConnection conn
|
||||||
: name(name), type(type), tooltip(tooltip), connection(connection), display(display), wires(wires)
|
: name(name), type(type), tooltip(tooltip), connection(connection), display(display), wires(wires)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string &Pin::getName() {
|
std::string Pin::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
Pin::PinType Pin::getType() {
|
Pin::PinType Pin::getType() {
|
||||||
|
|
|
@ -14,8 +14,8 @@ class PinConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ConnectionType {
|
enum ConnectionType {
|
||||||
REQUIRED,
|
CHECK_ONLY,
|
||||||
OPTIONAL
|
AUTOMATICALLY
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
public:
|
public:
|
||||||
Pin(std::string name, PinType type, std::string tooltip, PinConnection connection, Display display, std::optional<std::vector<Value>> wires);
|
Pin(std::string name, PinType type, std::string tooltip, PinConnection connection, Display display, std::optional<std::vector<Value>> wires);
|
||||||
|
|
||||||
std::string &getName();
|
std::string getName();
|
||||||
PinType getType();
|
PinType getType();
|
||||||
std::string getTooltip();
|
std::string getTooltip();
|
||||||
Display &getDisplay();
|
Display &getDisplay();
|
||||||
|
|
|
@ -17,7 +17,7 @@ bool Condition::evaluate(RuleContext &context) {
|
||||||
request.push_back(params[i]);
|
request.push_back(params[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool result = context.function[function]->validate(request);
|
bool result = context.function[function](request);
|
||||||
return negated ? !result : result;
|
return negated ? !result : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace domain {
|
||||||
struct RuleContext {
|
struct RuleContext {
|
||||||
std::map<std::string, AddressSpace> addressSpaces;
|
std::map<std::string, AddressSpace> addressSpaces;
|
||||||
std::map<std::string, Value> attributes;
|
std::map<std::string, Value> attributes;
|
||||||
std::map<std::string, FunctionValidator*> function;
|
std::map<std::string, FunctionCallback> function;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Condition {
|
class Condition {
|
||||||
|
|
|
@ -6,23 +6,4 @@ Schema::Schema()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Schema::hasConnection(string& component, string& pin) {
|
|
||||||
return getConnection(component, pin) != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConnectionInstance* Schema::getConnection(string& component, string& pin) {
|
|
||||||
for(auto& conn: connections) {
|
|
||||||
if(conn->instance->name == component && conn->connection.getComponent().pin == pin) {
|
|
||||||
return conn.get();
|
|
||||||
}
|
|
||||||
auto dirConn = dynamic_cast<DirectConnectionInstance*>(conn.get());
|
|
||||||
if(dirConn != nullptr) {
|
|
||||||
if(dirConn->secondInstance->name == component && conn->connection.getSecondComponent()->pin == pin) {
|
|
||||||
return dirConn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -14,30 +14,32 @@ class Schema
|
||||||
public:
|
public:
|
||||||
Schema();
|
Schema();
|
||||||
|
|
||||||
std::vector<shared_ptr<BusInstance>> busInstances;
|
std::vector<Instance*> instances;
|
||||||
std::vector<shared_ptr<ComponentInstance>> componentInstances;
|
std::vector<ConnectionInstance*> connections;
|
||||||
|
std::vector<WireInstance*> wires;
|
||||||
|
|
||||||
std::vector<shared_ptr<ConnectionInstance>> connections;
|
WireInstance *getWire(std::string name) {
|
||||||
|
for(auto wire: wires) {
|
||||||
BusInstance *getBusInstance(std::string& name) {
|
if (wire->name == name) {
|
||||||
for(auto& instance: busInstances) {
|
return wire;
|
||||||
if (instance->name == name) {
|
|
||||||
return instance.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
ComponentInstance *getComponentInstance(std::string& name) {
|
|
||||||
for(auto& instance: componentInstances) {
|
|
||||||
if (instance->name == name) {
|
|
||||||
return instance.get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasConnection(string& component, string& pin);
|
bool hasWire(std::string name) {
|
||||||
ConnectionInstance* getConnection(string& component, string& pin);
|
return getWire(name) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Instance *getInstance(std::string name) {
|
||||||
|
for(auto instance: instances) {
|
||||||
|
if (instance->name == name) {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "schemacreator.h"
|
#include "schemacreator.h"
|
||||||
|
|
||||||
#include<set>
|
#include<set>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
|
@ -40,31 +39,19 @@ Value::ValueType toType(ValueNode::ValueType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ValueNode::BOOL:
|
case ValueNode::BOOL:
|
||||||
return Value::BOOL;
|
return Value::BOOL;
|
||||||
case ValueNode::MEMORY:
|
|
||||||
return Value::MEMORY_REFERENCE;
|
|
||||||
case ValueNode::WIRE:
|
case ValueNode::WIRE:
|
||||||
return Value::WIRE_REFERENCE;
|
return Value::WIRE_REFERENCE;
|
||||||
case ValueNode::STRING:
|
case ValueNode::STRING:
|
||||||
return Value::STRING;
|
return Value::STRING;
|
||||||
case ValueNode::INT:
|
case ValueNode::INT:
|
||||||
return Value::INT;
|
return Value::INT;
|
||||||
case ValueNode::NIL:
|
|
||||||
return Value::NIL;
|
|
||||||
default:
|
default:
|
||||||
return Value::UNDEFINED;
|
return Value::UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value toType(ValueNode node, Value::ValueType type = Value::ValueType::UNDEFINED) {
|
Value toType(ValueNode node) {
|
||||||
if(type == Value::MEMORY_REFERENCE) {
|
|
||||||
if(node.getType() == ValueNode::NIL) {
|
|
||||||
return Value::fromMemoryReference(nullopt);
|
|
||||||
} else {
|
|
||||||
return Value::fromMemoryReference(node.asIdentifier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(node.getType() == ValueNode::BOOL) {
|
if(node.getType() == ValueNode::BOOL) {
|
||||||
return Value::fromBool(node.asBool());
|
return Value::fromBool(node.asBool());
|
||||||
} else if(node.getType() == ValueNode::INT) {
|
} else if(node.getType() == ValueNode::INT) {
|
||||||
|
@ -81,8 +68,6 @@ Value toType(ValueNode node, Value::ValueType type = Value::ValueType::UNDEFINED
|
||||||
Bus::BusType toType(BusNode::BusType type) {
|
Bus::BusType toType(BusNode::BusType type) {
|
||||||
if(type == BusNode::AUTOMATIC) {
|
if(type == BusNode::AUTOMATIC) {
|
||||||
return Bus::AUTOMATIC;
|
return Bus::AUTOMATIC;
|
||||||
} else if(type == BusNode::SINGLE_AUTOMATIC) {
|
|
||||||
return Bus::SINGLE_AUTOMATIC;
|
|
||||||
}
|
}
|
||||||
return Bus::REGULAR;
|
return Bus::REGULAR;
|
||||||
}
|
}
|
||||||
|
@ -99,10 +84,10 @@ Pin::PinType toType(PinNode::PinType type) {
|
||||||
|
|
||||||
PinConnection::ConnectionType toType(PinConnectionNode::ConnectionType type)
|
PinConnection::ConnectionType toType(PinConnectionNode::ConnectionType type)
|
||||||
{
|
{
|
||||||
if(type == PinConnectionNode::OPTIONAL) {
|
if(type == PinConnectionNode::AUTOMATICALLY) {
|
||||||
return PinConnection::OPTIONAL;
|
return PinConnection::AUTOMATICALLY;
|
||||||
}
|
}
|
||||||
return PinConnection::REQUIRED;
|
return PinConnection::CHECK_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,26 +99,22 @@ Popup::PopupType toType(PopupNode::PopupType type)
|
||||||
return Popup::ON_DEMAND;
|
return Popup::ON_DEMAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
SchemaCreator::SchemaCreator(std::vector<FunctionValidator*> validators)
|
SchemaCreator::SchemaCreator(std::vector<FunctionSignature> signatures)
|
||||||
: validators(std::move(validators))
|
: signatures(signatures)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
|
std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
|
||||||
{
|
{
|
||||||
// library fields
|
// library fields
|
||||||
if(!node.name) {
|
if(!node.name) {
|
||||||
errors.emplace_back(node.span, "missing @name");
|
errors.push_back(SourceError{node.span, "missing @name"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
} else {
|
} else {
|
||||||
name = node.name->asString();
|
name = node.name->asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.componentHeader.has_value()) {
|
|
||||||
componentHeader = node.componentHeader->asString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!node.componentDirectory) {
|
if(!node.componentDirectory) {
|
||||||
errors.emplace_back(node.span, "missing @componentDirectory");
|
errors.push_back(SourceError{node.span, "missing @componentDirectory"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
} else {
|
} else {
|
||||||
componentDirectory = node.componentDirectory->asString();
|
componentDirectory = node.componentDirectory->asString();
|
||||||
|
@ -155,29 +136,29 @@ std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& buse : node.buses) {
|
for(uint i=0; i<node.buses.size(); i++) {
|
||||||
auto bus = loadBus(buse);
|
auto bus = loadBus(node.buses[i]);
|
||||||
if(bus) {
|
if(bus) {
|
||||||
buses.push_back(*bus);
|
buses.push_back(*bus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& connection : node.connections) {
|
for(uint i=0; i<node.connections.size(); i++) {
|
||||||
auto conn = loadConnection(connection);
|
auto conn = loadConnection(node.connections[i]);
|
||||||
if(conn) {
|
if(conn) {
|
||||||
connections.push_back(*conn);
|
connections.push_back(*conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto & message : node.messages) {
|
for(uint i=0; i<node.messages.size(); i++) {
|
||||||
if(!message.value.is(ValueNode::STRING)) {
|
if(!node.messages[i].value.is(ValueNode::STRING)) {
|
||||||
errors.emplace_back(message.value.span, "expected `string`");
|
errors.push_back(SourceError{node.messages[i].value.span, "expected `string`"});
|
||||||
} else {
|
} else {
|
||||||
messages[message.key.value] = message.value.asString();
|
messages[node.messages[i].key.value] = node.messages[i].value.asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Library(name, libraryInfo, header, componentDirectory, componentHeader, addressSpaces, components, buses, connections, messages);
|
return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||||
|
@ -189,24 +170,24 @@ std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||||
count = std::make_pair<int, int>(node.count->first.value, node.count->second.value);
|
count = std::make_pair<int, int>(node.count->first.value, node.count->second.value);
|
||||||
}
|
}
|
||||||
if(count.first > count.second || count.first < 0) {
|
if(count.first > count.second || count.first < 0) {
|
||||||
errors.emplace_back(node.count->span, "invalid @size");
|
errors.push_back(SourceError{node.count->span, "invalid @size"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto type = toType(node.type.value);
|
auto type = toType(node.type);
|
||||||
|
|
||||||
if(!node.tooltip && type == Bus::REGULAR) {
|
if(!node.tooltip && type == Bus::REGULAR) {
|
||||||
errors.emplace_back(node.span, "missing @tooltip");
|
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string tooltip = node.tooltip->asString();
|
std::string tooltip = node.tooltip->asString();
|
||||||
|
|
||||||
if(!node.display && type == Bus::REGULAR) {
|
if(!node.display && type == Bus::REGULAR) {
|
||||||
errors.emplace_back(node.span, "missing @display");
|
errors.push_back(SourceError{node.span, "missing @display"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
if(node.display && (type == Bus::AUTOMATIC || type == Bus::SINGLE_AUTOMATIC)) {
|
if(node.display && (type == Bus::AUTOMATIC || type == Bus::AUTOMATIC_SINGLE)) {
|
||||||
errors.emplace_back(node.span, "automatic bus cannot have a @display");
|
errors.push_back(SourceError{node.span, "automatic bus cannot have a @display"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +200,7 @@ std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.wires.size() == 0) {
|
if(node.wires.size() == 0) {
|
||||||
errors.emplace_back(node.span, "missing @wires");
|
errors.push_back(SourceError{node.span, "missing @wires"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::vector<Wire> wires;
|
std::vector<Wire> wires;
|
||||||
|
@ -230,11 +211,6 @@ std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == Bus::SINGLE_AUTOMATIC && wires.size() != 1) {
|
|
||||||
errors.emplace_back(node.span, "singleAutomatic bus must have exactly 1 wire defined");
|
|
||||||
return nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Bus(name, tooltip, type, count, wires, display);
|
return Bus(name, tooltip, type, count, wires, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +222,7 @@ std::optional<AddressSpace> SchemaCreator::loadAddressSpace(AddressSpaceNode nod
|
||||||
|
|
||||||
std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
{
|
{
|
||||||
push(ComdelContext("connection", false, true, false, false));
|
push(ComdelContext("connection", false, true, false));
|
||||||
|
|
||||||
std::string bus = node.bus.value;
|
std::string bus = node.bus.value;
|
||||||
auto busInstance = getBus(bus);
|
auto busInstance = getBus(bus);
|
||||||
|
@ -254,10 +230,6 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
errors.emplace_back(node.span, "bus does not exist");
|
errors.emplace_back(node.span, "bus does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(busInstance->getType() == Bus::SINGLE_AUTOMATIC) {
|
|
||||||
current().inSingleAutomaticConnection = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(busInstance->getType() == Bus::REGULAR) {
|
if(busInstance->getType() == Bus::REGULAR) {
|
||||||
ConnectionComponent first{node.first.component.value, node.first.pin.value};
|
ConnectionComponent first{node.first.component.value, node.first.pin.value};
|
||||||
|
|
||||||
|
@ -312,7 +284,7 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
pop();
|
pop();
|
||||||
|
|
||||||
return Connection(first, nullopt, bus, attributes, wires, nullopt);
|
return Connection(first, nullopt, bus, attributes, wires, nullopt);
|
||||||
} else if(busInstance->getType() == Bus::AUTOMATIC || busInstance->getType() == Bus::SINGLE_AUTOMATIC) {
|
} else if(busInstance->getType() == Bus::AUTOMATIC || busInstance->getType() == Bus::AUTOMATIC_SINGLE) {
|
||||||
ConnectionComponent first{node.first.component.value, node.first.pin.value};
|
ConnectionComponent first{node.first.component.value, node.first.pin.value};
|
||||||
|
|
||||||
if(!node.second.has_value()) {
|
if(!node.second.has_value()) {
|
||||||
|
@ -337,10 +309,6 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
current().wires.push_back(wire.getName());
|
current().wires.push_back(wire.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.attributes.size() != 2 && busInstance->getType() == Bus::SINGLE_AUTOMATIC) {
|
|
||||||
errors.emplace_back(node.span, "singleAutomatic must contain 2 attributes");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Attribute> attributes;
|
std::vector<Attribute> attributes;
|
||||||
for(auto & attribute : node.attributes) {
|
for(auto & attribute : node.attributes) {
|
||||||
auto attr = loadAttribute(attribute);
|
auto attr = loadAttribute(attribute);
|
||||||
|
@ -361,9 +329,7 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
firstWires.push_back(Value::fromNull());
|
firstWires.push_back(Value::fromNull());
|
||||||
} else if(firstWire.is(ValueNode::INT)) {
|
} else if(firstWire.is(ValueNode::INT)) {
|
||||||
firstWires.push_back(Value::fromInt(firstWire.asInt()));
|
firstWires.push_back(Value::fromInt(firstWire.asInt()));
|
||||||
} else if(firstWire.is(ValueNode::STRING) && busInstance->getType() == Bus::SINGLE_AUTOMATIC) {
|
} else if(firstWire.is(ValueNode::IDENTIFIER)) {
|
||||||
firstWires.push_back(Value::fromString(firstWire.asString()));
|
|
||||||
} else if(firstWire.is(ValueNode::IDENTIFIER) && busInstance->getType() == Bus::AUTOMATIC) {
|
|
||||||
if(attributeNames.count(firstWire.asIdentifier())) {
|
if(attributeNames.count(firstWire.asIdentifier())) {
|
||||||
firstWires.push_back(Value::fromReference(firstWire.asIdentifier(), Value::ATTRIBUTE_REFERENCE));
|
firstWires.push_back(Value::fromReference(firstWire.asIdentifier(), Value::ATTRIBUTE_REFERENCE));
|
||||||
} else if(wireNames.count(firstWire.asIdentifier())) {
|
} else if(wireNames.count(firstWire.asIdentifier())) {
|
||||||
|
@ -372,7 +338,7 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
errors.emplace_back(firstWire.span, "unknown identifier");
|
errors.emplace_back(firstWire.span, "unknown identifier");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(firstWire.span, "unsupported value type");
|
errors.emplace_back(firstWire.span, "unknown value type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,9 +349,7 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
secondWires.push_back(Value::fromNull());
|
secondWires.push_back(Value::fromNull());
|
||||||
} else if(secondWire.is(ValueNode::INT)) {
|
} else if(secondWire.is(ValueNode::INT)) {
|
||||||
secondWires.push_back(Value::fromInt(secondWire.asInt()));
|
secondWires.push_back(Value::fromInt(secondWire.asInt()));
|
||||||
} else if(secondWire.is(ValueNode::STRING) && busInstance->getType() == Bus::SINGLE_AUTOMATIC) {
|
} else if(secondWire.is(ValueNode::IDENTIFIER)) {
|
||||||
secondWires.push_back(Value::fromString(secondWire.asString()));
|
|
||||||
} else if(secondWire.is(ValueNode::IDENTIFIER) && busInstance->getType() == Bus::AUTOMATIC) {
|
|
||||||
if(attributeNames.count(secondWire.asIdentifier())) {
|
if(attributeNames.count(secondWire.asIdentifier())) {
|
||||||
secondWires.push_back(Value::fromReference(secondWire.asIdentifier(), Value::ATTRIBUTE_REFERENCE));
|
secondWires.push_back(Value::fromReference(secondWire.asIdentifier(), Value::ATTRIBUTE_REFERENCE));
|
||||||
} else if(wireNames.count(secondWire.asIdentifier())) {
|
} else if(wireNames.count(secondWire.asIdentifier())) {
|
||||||
|
@ -394,25 +358,7 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
errors.emplace_back(secondWire.span, "unknown identifier");
|
errors.emplace_back(secondWire.span, "unknown identifier");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(secondWire.span, "unsupported value type");
|
errors.emplace_back(secondWire.span, "unknown value type");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(busInstance->getType() == Bus::SINGLE_AUTOMATIC && attributes.size() == 2) {
|
|
||||||
if(!attributes[0].getPopup().has_value()) {
|
|
||||||
errors.emplace_back(node.attributes[0].span, "@popup is required");
|
|
||||||
} else if(attributes[0].getDefault().getType() != Value::STRING) {
|
|
||||||
errors.emplace_back(node.attributes[0].span, "@attribute must be of type string");
|
|
||||||
} else {
|
|
||||||
attributes[0].getPopup()->setEnumeration(createWireEnumeration(firstWires));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!attributes[1].getPopup().has_value()) {
|
|
||||||
errors.emplace_back(node.attributes[1].span, "@popup is required");
|
|
||||||
} else if(attributes[1].getDefault().getType() != Value::STRING) {
|
|
||||||
errors.emplace_back(node.attributes[1].span, "@attribute must be of type string");
|
|
||||||
} else {
|
|
||||||
attributes[1].getPopup()->setEnumeration(createWireEnumeration(secondWires));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,25 +374,25 @@ std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
|
||||||
|
|
||||||
std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
{
|
{
|
||||||
push(ComdelContext(node.name.value, true, false, false, false));
|
push(ComdelContext(node.name.value, true, false, false));
|
||||||
|
|
||||||
std::string name = node.name.value;
|
std::string name = node.name.value;
|
||||||
|
|
||||||
if(!node.tooltip) {
|
if(!node.tooltip) {
|
||||||
errors.emplace_back(node.span, "missing @tooltip");
|
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string tooltip = node.tooltip->asString();
|
std::string tooltip = node.tooltip->asString();
|
||||||
|
|
||||||
if(!node.source) {
|
if(!node.source) {
|
||||||
errors.emplace_back(node.span, "missing @source");
|
errors.push_back(SourceError{node.span, "missing @source"});
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string source = node.source->asString();
|
std::string source = node.source->asString();
|
||||||
|
|
||||||
Component::ComponentType type = toType(node.type.value);
|
Component::ComponentType type = toType(node.type);
|
||||||
|
|
||||||
std::vector<Attribute> attributes;
|
std::vector<Attribute> attributes;
|
||||||
for(auto& a: node.attributes) {
|
for(auto& a: node.attributes) {
|
||||||
|
@ -455,9 +401,6 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
attributes.push_back(*attribute);
|
attributes.push_back(*attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == Component::PROCESSOR) {
|
|
||||||
attributes.push_back(*createMemoryAttribute());
|
|
||||||
}
|
|
||||||
|
|
||||||
context[context.size() -1 ].attributes = attributes;
|
context[context.size() -1 ].attributes = attributes;
|
||||||
|
|
||||||
|
@ -470,7 +413,7 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!node.instanceName) {
|
if(!node.instanceName) {
|
||||||
errors.emplace_back(node.span, "missing @instanceName");
|
errors.push_back(SourceError{node.span, "missing @instanceName"});
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
@ -481,13 +424,13 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
count = std::make_pair<int, int>(node.count->first.value, node.count->second.value);
|
count = std::make_pair<int, int>(node.count->first.value, node.count->second.value);
|
||||||
}
|
}
|
||||||
if(count.first > count.second || count.first < 0) {
|
if(count.first > count.second || count.first < 0) {
|
||||||
errors.emplace_back(node.count->first.span, "invalid @size");
|
errors.push_back(SourceError{node.count->first.span, "invalid @size"});
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!node.display) {
|
if(!node.display) {
|
||||||
errors.emplace_back(node.span, "missing @display");
|
errors.push_back(SourceError{node.span, "missing @display"});
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
@ -498,8 +441,8 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Pin> pins;
|
std::vector<Pin> pins;
|
||||||
for(auto &p : node.pins) {
|
for(uint i=0; i<node.pins.size(); i++) {
|
||||||
auto pin = loadPin(p);
|
auto pin = loadPin(node.pins[i]);
|
||||||
if(!pin) {
|
if(!pin) {
|
||||||
pop();
|
pop();
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
@ -514,27 +457,27 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
||||||
return Wire(
|
return Wire(
|
||||||
node.name.value,
|
node.name.value,
|
||||||
toType(node.type.value),
|
toType(node.type),
|
||||||
node.size.value,
|
node.size.value,
|
||||||
node.hidden,
|
node.hidden,
|
||||||
node.hasTerminateWith,
|
node.hasTermination,
|
||||||
toType(node.terminateWith)
|
node.isUnterminated
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<Pin> SchemaCreator::loadPin(PinNode node)
|
optional<Pin> SchemaCreator::loadPin(PinNode node)
|
||||||
{
|
{
|
||||||
std::string name = node.name.value;
|
std::string name = node.name.value;
|
||||||
Pin::PinType type = toType(node.type.value);
|
Pin::PinType type = toType(node.type);
|
||||||
|
|
||||||
if(!node.tooltip) {
|
if(!node.tooltip) {
|
||||||
errors.emplace_back(node.span, "missing @tooltip");
|
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string tooltip = node.tooltip->asString();
|
std::string tooltip = node.tooltip->asString();
|
||||||
|
|
||||||
if(!node.display) {
|
if(!node.display) {
|
||||||
errors.emplace_back(node.span, "missing @display");
|
errors.push_back(SourceError{node.span, "missing @display"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::vector<Attribute> attributes;
|
std::vector<Attribute> attributes;
|
||||||
|
@ -544,7 +487,7 @@ optional<Pin> SchemaCreator::loadPin(PinNode node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!node.connection) {
|
if(!node.connection) {
|
||||||
errors.emplace_back(node.span, "missing @connection");
|
errors.push_back(SourceError{node.span, "missing @connection"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
auto connection = loadPinConnection(*node.connection);
|
auto connection = loadPinConnection(*node.connection);
|
||||||
|
@ -605,7 +548,7 @@ std::optional<Display> SchemaCreator::loadDisplay(DisplayNode node)
|
||||||
h = getIntProperty(item, "h");
|
h = getIntProperty(item, "h");
|
||||||
displayItem.pin = ui::Pin(x, y, w, h);
|
displayItem.pin = ui::Pin(x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(item.type.span, "unsupported display type");
|
errors.push_back(SourceError{item.type.span, "unsupported display type"});
|
||||||
}
|
}
|
||||||
items.push_back(displayItem);
|
items.push_back(displayItem);
|
||||||
}
|
}
|
||||||
|
@ -616,8 +559,8 @@ std::optional<Display> SchemaCreator::loadDisplay(DisplayNode node)
|
||||||
PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node)
|
PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node)
|
||||||
{
|
{
|
||||||
std::string message = node.message.asString();
|
std::string message = node.message.asString();
|
||||||
PinConnection::ConnectionType type = toType(node.type.value);
|
PinConnection::ConnectionType type = toType(node.type);
|
||||||
return {message, type};
|
return PinConnection(message, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
|
std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
|
||||||
|
@ -634,30 +577,23 @@ std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
|
||||||
} else if (node.type == ValueNode::STRING) {
|
} else if (node.type == ValueNode::STRING) {
|
||||||
value = Value::fromString(node.defaultValue->asString());
|
value = Value::fromString(node.defaultValue->asString());
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(node.name.span, "unsupported type");
|
errors.push_back(SourceError{node.name.span, "unsupported type"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(current().inConnection && !current().inSingleAutomaticConnection) { // TODO remove identifier
|
if(current().inConnection) { // TODO remove identifier
|
||||||
if (node.type == ValueNode::WIRE || node.type == ValueNode::IDENTIFIER) {
|
if (node.type == ValueNode::WIRE || node.type == ValueNode::IDENTIFIER) {
|
||||||
if(current().doesWireExists(node.defaultValue->asIdentifier())) {
|
if(current().doesWireExists(node.defaultValue->asIdentifier())) {
|
||||||
value = Value::fromReference(node.defaultValue->asIdentifier(), Value::WIRE_REFERENCE);
|
value = Value::fromReference(node.defaultValue->asIdentifier(), Value::WIRE_REFERENCE);
|
||||||
} else {
|
} else {
|
||||||
value = Value::fromReference("", Value::WIRE_REFERENCE);
|
value = Value::fromReference("", Value::WIRE_REFERENCE);
|
||||||
errors.emplace_back(node.span, "unknown identifier");
|
errors.push_back(SourceError{node.span, "unknown identifier"});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(node.name.span, "unsupported type");
|
errors.push_back(SourceError{node.name.span, "unsupported type"});
|
||||||
}
|
|
||||||
}
|
|
||||||
if(current().inSingleAutomaticConnection) {
|
|
||||||
if (node.type == ValueNode::STRING) {
|
|
||||||
value = Value::fromString(node.defaultValue->asString());
|
|
||||||
} else {
|
|
||||||
errors.emplace_back(node.name.span, "unsupported type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current().attributes.emplace_back(name, value);
|
current().attributes.push_back(Attribute(name, value));
|
||||||
|
|
||||||
std::optional<Popup> popup;
|
std::optional<Popup> popup;
|
||||||
if(node.popup) {
|
if(node.popup) {
|
||||||
|
@ -670,21 +606,21 @@ std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
|
||||||
|
|
||||||
std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type)
|
std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type)
|
||||||
{
|
{
|
||||||
auto popupType = toType(node.type.value().value);
|
auto popupType = toType(*node.type);
|
||||||
|
|
||||||
pushAdditional(name);
|
pushAdditional(name);
|
||||||
|
|
||||||
current().attributes.clear();
|
current().attributes.clear();
|
||||||
current().attributes.emplace_back(name, Value::ofType(type));
|
current().attributes.push_back(Attribute(name, Value::ofType(type)));
|
||||||
|
|
||||||
if(!node.title) {
|
if(!node.title) {
|
||||||
errors.emplace_back(node.span, "missing @title");
|
errors.push_back(SourceError{node.span, "missing @title"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string title = node.title->asString();
|
std::string title = node.title->asString();
|
||||||
|
|
||||||
if(!node.text) {
|
if(!node.text) {
|
||||||
errors.emplace_back(node.span, "missing @text");
|
errors.push_back(SourceError{node.span, "missing @text"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::string text = node.text->asString();
|
std::string text = node.text->asString();
|
||||||
|
@ -699,34 +635,34 @@ std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name,
|
||||||
|
|
||||||
std::vector<Enumeration> enumeration;
|
std::vector<Enumeration> enumeration;
|
||||||
if(node.enumerated) {
|
if(node.enumerated) {
|
||||||
for(auto& enumNode : node.enumeration) {
|
for(uint i=0; i<node.enumeration.size(); i++) {
|
||||||
if(type == Value::INT || type == Value::STRING || type == Value::BOOL) {
|
if(type == Value::INT || type == Value::STRING || type == Value::BOOL) {
|
||||||
auto value = toType(enumNode.value);
|
auto value = toType(node.enumeration[i].value);
|
||||||
if(value.getType() == type) {
|
if(value.getType() == type) {
|
||||||
enumeration.emplace_back(enumNode.key.asString(), value);
|
enumeration.push_back(Enumeration(node.enumeration[i].key.asString(), value));
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(enumNode.span, "wrong type");
|
errors.push_back(SourceError{node.enumeration[i].span, "wrong type"});
|
||||||
}
|
}
|
||||||
} else if(type == Value::WIRE_REFERENCE) {
|
} else if(type == Value::WIRE_REFERENCE) {
|
||||||
auto value = toType(enumNode.value);
|
auto value = toType(node.enumeration[i].value);
|
||||||
if(value.isType(Value::UNDEFINED)) {
|
if(value.isType(Value::UNDEFINED)) {
|
||||||
if(current().doesWireExists(value.asReference())) {
|
if(current().doesWireExists(value.asReference())) {
|
||||||
value = Value::fromReference(value.asReference(), Value::WIRE_REFERENCE);
|
value = Value::fromReference(value.asReference(), Value::WIRE_REFERENCE);
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(enumNode.span, "unknown wire");
|
errors.push_back(SourceError{node.enumeration[i].span, "unknown wire"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(value.isType(Value::WIRE_REFERENCE) || value.isType(Value::INT) || value.isType(Value::NIL)) {
|
if(value.isType(Value::WIRE_REFERENCE) || value.isType(Value::INT) || value.isType(Value::NIL)) {
|
||||||
enumeration.emplace_back(enumNode.key.asString(), value);
|
enumeration.push_back(Enumeration(node.enumeration[i].key.asString(), value));
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(enumNode.span, "wrong type");
|
errors.push_back(SourceError{node.enumeration[i].span, "wrong type"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(type == Value::WIRE_REFERENCE && !current().inConnection) {
|
if(type == Value::WIRE_REFERENCE && !current().inConnection) {
|
||||||
errors.emplace_back(node.span, "@enumeration is required for attributes of type wire");
|
errors.push_back(SourceError{node.span, "@enumeration is required for attributes of type wire"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +678,7 @@ std::optional<Rule> SchemaCreator::loadRule(RuleNode node)
|
||||||
for(auto& stmt: node.statements) {
|
for(auto& stmt: node.statements) {
|
||||||
auto condition = loadCondition(stmt.condition);
|
auto condition = loadCondition(stmt.condition);
|
||||||
if(condition) {
|
if(condition) {
|
||||||
statements.emplace_back(*condition, Action(toType(stmt.action.type.value), stmt.action.message.asString()));
|
statements.push_back(IfStatement(*condition, Action(toType(stmt.action.type), stmt.action.message.asString())));
|
||||||
} else {
|
} else {
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
@ -755,19 +691,19 @@ std::optional<Condition> SchemaCreator::loadCondition(ConditionNode node)
|
||||||
{
|
{
|
||||||
std::string function = node.functionName.value;
|
std::string function = node.functionName.value;
|
||||||
|
|
||||||
for(auto & validator : validators) {
|
for(uint i=0; i<signatures.size(); i++) {
|
||||||
if(validator->getName() == function) {
|
if(signatures[i].name == function) {
|
||||||
if(validator->getSignature().size() == node.params.size()) {
|
if(signatures[i].params.size() == node.params.size()) {
|
||||||
std::vector<Value> params;
|
std::vector<Value> params;
|
||||||
for(uint j=0; j<validator->getSignature().size(); j++) {
|
for(uint j=0; j<signatures[i].params.size(); j++) {
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
auto type = toType(node.params[j]);
|
auto type = toType(node.params[j]);
|
||||||
if (type.getType() == Value::UNDEFINED) {
|
if (type.getType() == Value::UNDEFINED) {
|
||||||
if(current().doesAttributeExists(type.asReference(), validator->getSignature()[j])) {
|
if(current().doesAttributeExists(type.asReference(), signatures[i].params[j])) {
|
||||||
exists = true;
|
exists = true;
|
||||||
type = Value::fromReference(type.asReference(), Value::ATTRIBUTE_REFERENCE);
|
type = Value::fromReference(type.asReference(), Value::ATTRIBUTE_REFERENCE);
|
||||||
}
|
}
|
||||||
if(validator->getSignature()[j] == Value::ADDRESS_SPACE) {
|
if(signatures[i].params[j] == Value::ADDRESS_SPACE) {
|
||||||
if(hasAddressSpace(type.asReference())) {
|
if(hasAddressSpace(type.asReference())) {
|
||||||
exists = true;
|
exists = true;
|
||||||
type = Value::fromReference(type.asReference(), Value::ADDRESS_SPACE_REFERENCE);
|
type = Value::fromReference(type.asReference(), Value::ADDRESS_SPACE_REFERENCE);
|
||||||
|
@ -775,69 +711,76 @@ std::optional<Condition> SchemaCreator::loadCondition(ConditionNode node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!exists) {
|
if(!exists) {
|
||||||
errors.emplace_back(node.functionName.span, "unknown reference " + type.asReference());
|
errors.push_back(SourceError{node.functionName.span, "unknown reference " + type.asReference()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params.push_back(type);
|
params.push_back(type);
|
||||||
}
|
}
|
||||||
return Condition(function, params, node.negated);
|
return Condition(function, params, node.negated);
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(node.functionName.span, "wrong number of parameters");
|
errors.push_back(SourceError{node.functionName.span, "wrong number of parameters"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.emplace_back(node.functionName.span, "unknown function name");
|
errors.push_back(SourceError{node.functionName.span, "unknown function name"});
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
|
std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &library)
|
||||||
{
|
{
|
||||||
auto *schema = new Schema();
|
Schema schema;
|
||||||
|
|
||||||
for(auto &instance: node.instances) {
|
for(auto &instance: node.instances) {
|
||||||
if(library.hasComponent(instance.component.value)) {
|
if(library.hasComponent(instance.component.value)) {
|
||||||
schema->componentInstances.push_back(loadComponentInstance(instance, library));
|
schema.instances.push_back(loadComponentInstance(instance, library));
|
||||||
}
|
}
|
||||||
if(library.hasBus(instance.component.value)) {
|
if(library.hasBus(instance.component.value)) {
|
||||||
schema->busInstances.push_back(loadBusInstance(instance, library));
|
schema.instances.push_back(loadBusInstance(instance, library));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto &wire: node.wires) {
|
||||||
|
auto w = loadWireInstance(wire);
|
||||||
|
if(w) {
|
||||||
|
schema.wires.push_back(*w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto &conn: node.connections) {
|
for(auto &conn: node.connections) {
|
||||||
auto firstComponent = schema->getComponentInstance(conn.first.instance.value);
|
auto firstComponent = dynamic_cast<ComponentInstance*>(schema.getInstance(conn.first.instance.value));
|
||||||
if(firstComponent == nullptr) {
|
if(firstComponent == NULL) {
|
||||||
errors.emplace_back(conn.first.instance.span, "unknown component");
|
errors.push_back(SourceError{conn.first.instance.span, "unknown component"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!firstComponent->component.hasPin(conn.first.pin.value)) {
|
if(!firstComponent->component.hasPin(conn.first.pin.value)) {
|
||||||
errors.emplace_back(conn.first.pin.span, "unknown pin");
|
errors.push_back(SourceError{conn.first.pin.span, "unknown pin"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ComponentInstance *secondComponent = nullptr;
|
ComponentInstance *secondComponent = NULL;
|
||||||
if(conn.second.has_value()) {
|
if(conn.second.has_value()) {
|
||||||
secondComponent = schema->getComponentInstance(conn.second->instance.value);
|
secondComponent = dynamic_cast<ComponentInstance*>(schema.getInstance(conn.second->instance.value));
|
||||||
if(secondComponent == nullptr) {
|
if(secondComponent == NULL) {
|
||||||
errors.emplace_back(conn.second->instance.span, "unknown component");
|
errors.push_back(SourceError{conn.second->instance.span, "unknown component"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!secondComponent->component.hasPin(conn.second->pin.value)) {
|
if(!secondComponent->component.hasPin(conn.second->pin.value)) {
|
||||||
errors.emplace_back(conn.second->pin.span, "unknown pin");
|
errors.push_back(SourceError{conn.second->pin.span, "unknown pin"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bus = schema->getBusInstance(conn.bus.value);
|
auto bus = dynamic_cast<BusInstance*>(schema.getInstance(conn.bus.value));
|
||||||
if(bus == nullptr) {
|
if(bus == NULL) {
|
||||||
errors.emplace_back(conn.bus.span, "unknown bus");
|
errors.push_back(SourceError{conn.bus.span, "unknown bus"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Connection> connection = std::nullopt;
|
std::optional<Connection> connection = std::nullopt;
|
||||||
if(secondComponent != nullptr) {
|
if(secondComponent != NULL) {
|
||||||
ConnectionComponent firstConn{firstComponent->component.getName(), conn.first.pin.value};
|
ConnectionComponent firstConn{firstComponent->component.getName(), conn.first.pin.value};
|
||||||
ConnectionComponent secondConn{secondComponent->component.getName(), conn.second->pin.value};
|
ConnectionComponent secondConn{secondComponent->component.getName(), conn.second->pin.value};
|
||||||
|
|
||||||
|
@ -846,7 +789,7 @@ Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
|
||||||
secondConn)) {
|
secondConn)) {
|
||||||
connection = *library.getConnection(firstConn, bus->bus.getName(), secondConn);
|
connection = *library.getConnection(firstConn, bus->bus.getName(), secondConn);
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(conn.span, "unknown connection");
|
errors.push_back(SourceError{conn.span, "unknown connection"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -856,12 +799,23 @@ Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
|
||||||
bus->bus.getName())) {
|
bus->bus.getName())) {
|
||||||
connection = *library.getConnection(firstConn, bus->bus.getName());
|
connection = *library.getConnection(firstConn, bus->bus.getName());
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(conn.span, "unknown connection");
|
errors.push_back(SourceError{conn.span, "unknown connection"});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<InstanceAttribute> attributes;
|
if(!conn.wire) {
|
||||||
|
errors.push_back(SourceError{conn.span, "missing @wire"});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!schema.hasWire(conn.wire->value)) {
|
||||||
|
errors.push_back(SourceError{conn.wire->span, "unknown wire"});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wire = schema.getWire(conn.wire->value);
|
||||||
|
|
||||||
|
std::vector<InstanceAttribute*> attributes;
|
||||||
for(auto& attr: conn.attributes) {
|
for(auto& attr: conn.attributes) {
|
||||||
if(connection->hasAttribute(attr.name.value)) {
|
if(connection->hasAttribute(attr.name.value)) {
|
||||||
auto attribute = connection->getAttribute(attr.name.value);
|
auto attribute = connection->getAttribute(attr.name.value);
|
||||||
|
@ -873,26 +827,26 @@ Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(value.isType(Value::UNDEFINED)) {
|
if(value.isType(Value::UNDEFINED)) {
|
||||||
errors.emplace_back(attr.span, "invalid value");
|
errors.push_back(SourceError{attr.span, "invalid value"});
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.emplace_back(attribute.getName(), toType(attr.value), attribute);
|
attributes.push_back(new InstanceAttribute(attribute.getName(), toType(attr.value), attribute));
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(attr.name.span, "unknown attribute");
|
errors.push_back(SourceError(attr.name.span, "unknown attribute"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(secondComponent == nullptr) {
|
if(secondComponent == NULL) {
|
||||||
schema->connections.push_back(std::make_shared<BusConnectionInstance>(firstComponent, attributes, bus, *connection));
|
schema.connections.push_back(new BusConnectionInstance(firstComponent, attributes, bus, wire, *connection));
|
||||||
} else {
|
} else {
|
||||||
schema->connections.push_back(std::make_shared<DirectConnectionInstance>(firstComponent, secondComponent, attributes, bus, *connection));
|
schema.connections.push_back(new DirectConnectionInstance(firstComponent, secondComponent, attributes, bus, wire, *connection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<ComponentInstance> SchemaCreator::loadComponentInstance(InstanceNode instance, Library &library) {
|
ComponentInstance *SchemaCreator::loadComponentInstance(InstanceNode instance, Library &library) {
|
||||||
|
|
||||||
auto name = instance.name.value;
|
auto name = instance.name.value;
|
||||||
auto position = std::make_pair(instance.position->first.value, instance.position->second.value);
|
auto position = std::make_pair(instance.position->first.value, instance.position->second.value);
|
||||||
|
@ -900,27 +854,19 @@ shared_ptr<ComponentInstance> SchemaCreator::loadComponentInstance(InstanceNode
|
||||||
auto component = library.getComponent(instance.component.value);
|
auto component = library.getComponent(instance.component.value);
|
||||||
|
|
||||||
// validate attributes
|
// validate attributes
|
||||||
std::vector<InstanceAttribute> attributes;
|
std::vector<InstanceAttribute*> attributes;
|
||||||
for(auto& attr: instance.attributes) {
|
for(auto& attr: instance.attributes) {
|
||||||
if(component.hasAttribute(attr.name.value, toType(attr.value.getType()))) {
|
if(component.hasAttribute(attr.name.value, toType(attr.value.getType()))) {
|
||||||
auto attribute = component.getAttribute(attr.name.value);
|
auto attribute = component.getAttribute(attr.name.value);
|
||||||
attributes.emplace_back(attribute.getName(), toType(attr.value, attribute.getDefault().getType()), attribute);
|
attributes.push_back(new InstanceAttribute(attribute.getName(), toType(attr.value), attribute));
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(SourceError(attr.name.span, "unknown attribute"));
|
errors.push_back(SourceError(attr.name.span, "unknown attribute"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attributes.size() < component.getAttributes().size()) {
|
return new ComponentInstance(name, attributes, position, component);
|
||||||
for(auto& attr: component.getAttributes()) {
|
|
||||||
if(std::count_if(attributes.begin(), attributes.end(), [&attr](InstanceAttribute& attribute){ return attr.getName() == attribute.name; }) == 0) {
|
|
||||||
errors.emplace_back(SourceError(instance.span, "missing attribute '" + attr.getName() + "'"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_shared<ComponentInstance>(name, attributes, position, component);
|
|
||||||
}
|
}
|
||||||
std::shared_ptr<BusInstance> SchemaCreator::loadBusInstance(InstanceNode instance, Library &library) {
|
BusInstance *SchemaCreator::loadBusInstance(InstanceNode instance, Library &library) {
|
||||||
|
|
||||||
auto name = instance.name.value;
|
auto name = instance.name.value;
|
||||||
auto position = std::make_pair(instance.position->first.value, instance.position->second.value);
|
auto position = std::make_pair(instance.position->first.value, instance.position->second.value);
|
||||||
|
@ -932,25 +878,25 @@ std::shared_ptr<BusInstance> SchemaCreator::loadBusInstance(InstanceNode instanc
|
||||||
size = instance.size->value;
|
size = instance.size->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<BusInstance>(name, position, bus, static_cast<int>(size));
|
return new BusInstance(name, position, bus, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Enumeration> SchemaCreator::createWireEnumeration(vector<Value> wireValues) {
|
std::optional<WireInstance*> SchemaCreator::loadWireInstance(WireInstanceNode node) {
|
||||||
vector<Enumeration> wires;
|
|
||||||
for(auto& wire: wireValues) {
|
if(!node.display) {
|
||||||
if(wire.isType(Value::STRING)) {
|
errors.push_back(SourceError{node.span, "missing @text"});
|
||||||
wires.emplace_back(wire.asString(), wire);
|
return nullopt;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return wires;
|
auto display = loadDisplay(*node.display);
|
||||||
}
|
if(!display) {
|
||||||
|
return nullopt;
|
||||||
std::optional<Attribute> SchemaCreator::createMemoryAttribute() {
|
|
||||||
return Attribute("_memory", Value::fromMemoryReference(nullopt), createMemoryPopup());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<Popup> SchemaCreator::createMemoryPopup() {
|
|
||||||
return Popup("Postavi memoriju", "Postavi memoriju za izabrani procesor", Popup::AUTOMATIC, vector<Rule>{}, vector<Enumeration>{});
|
|
||||||
}
|
}
|
||||||
|
std::pair<int, int> position = std::make_pair(0, 0);
|
||||||
|
if(node.position) {
|
||||||
|
position = std::make_pair(node.position->first.value, node.position->second.value);
|
||||||
|
}
|
||||||
|
return std::optional<WireInstance*>(new WireInstance(node.name.value, *display, position));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -18,11 +18,10 @@ struct ComdelContext {
|
||||||
std::string name;
|
std::string name;
|
||||||
bool inComponent;
|
bool inComponent;
|
||||||
bool inConnection;
|
bool inConnection;
|
||||||
bool inSingleAutomaticConnection;
|
|
||||||
bool inBus;
|
bool inBus;
|
||||||
|
|
||||||
ComdelContext(std::string name, bool inComponent, bool inConnection, bool inSingleAutomaticConnection, bool inBus)
|
ComdelContext(std::string name, bool inComponent, bool inConnection, bool inBus)
|
||||||
: name(name), inComponent(inComponent), inConnection(inConnection), inSingleAutomaticConnection(inSingleAutomaticConnection), inBus(inBus)
|
: name(name), inComponent(inComponent), inConnection(inConnection), inBus(inBus)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool doesAttributeExists(std::string name, Value::ValueType type) {
|
bool doesAttributeExists(std::string name, Value::ValueType type) {
|
||||||
|
@ -53,7 +52,6 @@ class SchemaCreator
|
||||||
std::string libraryInfo;
|
std::string libraryInfo;
|
||||||
std::string header;
|
std::string header;
|
||||||
std::string componentDirectory;
|
std::string componentDirectory;
|
||||||
std::optional<std::string> componentHeader = nullopt;
|
|
||||||
std::vector<AddressSpace> addressSpaces;
|
std::vector<AddressSpace> addressSpaces;
|
||||||
std::vector<Component> components;
|
std::vector<Component> components;
|
||||||
std::vector<Bus> buses;
|
std::vector<Bus> buses;
|
||||||
|
@ -62,7 +60,7 @@ class SchemaCreator
|
||||||
|
|
||||||
|
|
||||||
std::vector<SourceError> errors;
|
std::vector<SourceError> errors;
|
||||||
std::vector<FunctionValidator*> validators;
|
std::vector<FunctionSignature> signatures;
|
||||||
|
|
||||||
std::optional<AddressSpace> loadAddressSpace(AddressSpaceNode node);
|
std::optional<AddressSpace> loadAddressSpace(AddressSpaceNode node);
|
||||||
std::optional<Component> loadComponent(ComponentNode node);
|
std::optional<Component> loadComponent(ComponentNode node);
|
||||||
|
@ -77,10 +75,9 @@ class SchemaCreator
|
||||||
std::optional<Connection> loadConnection(ConnectionNode node);
|
std::optional<Connection> loadConnection(ConnectionNode node);
|
||||||
std::optional<Bus> loadBus(BusNode node);
|
std::optional<Bus> loadBus(BusNode node);
|
||||||
|
|
||||||
std::shared_ptr<ComponentInstance> loadComponentInstance(InstanceNode instance, Library &library);
|
ComponentInstance *loadComponentInstance(InstanceNode instance, Library &library);
|
||||||
std::shared_ptr<BusInstance> loadBusInstance(InstanceNode instance, Library &library);
|
BusInstance *loadBusInstance(InstanceNode instance, Library &library);
|
||||||
|
std::optional<WireInstance*> loadWireInstance(WireInstanceNode node);
|
||||||
std::optional<Attribute> createMemoryAttribute();
|
|
||||||
|
|
||||||
std::optional<Bus> getBus(std::string name) {
|
std::optional<Bus> getBus(std::string name) {
|
||||||
for(auto &bus: buses) {
|
for(auto &bus: buses) {
|
||||||
|
@ -117,11 +114,11 @@ class SchemaCreator
|
||||||
this->context.push_back(context);
|
this->context.push_back(context);
|
||||||
}
|
}
|
||||||
void pushAdditional(std::string name) {
|
void pushAdditional(std::string name) {
|
||||||
if(!this->context.empty()) {
|
if(this->context.size() > 0) {
|
||||||
this->context.push_back(current());
|
this->context.push_back(current());
|
||||||
current().name = name;
|
current().name = name;
|
||||||
} else {
|
} else {
|
||||||
ComdelContext con(name, false, false, false, false);
|
ComdelContext con(name, false, false, false);
|
||||||
push(con);
|
push(con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +130,7 @@ class SchemaCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SchemaCreator(std::vector<FunctionValidator*> validators);
|
SchemaCreator(std::vector<FunctionSignature> signatures);
|
||||||
|
|
||||||
std::vector<SourceError> getErrors() {
|
std::vector<SourceError> getErrors() {
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -141,11 +138,7 @@ public:
|
||||||
|
|
||||||
std::optional<Library> loadLibrary(LibraryNode node);
|
std::optional<Library> loadLibrary(LibraryNode node);
|
||||||
|
|
||||||
Schema* loadSchema(SchemaNode node, Library &library);
|
std::optional<Schema> loadSchema(SchemaNode node, Library &library);
|
||||||
|
|
||||||
vector <Enumeration> createWireEnumeration(vector<Value> vector1);
|
|
||||||
|
|
||||||
std::optional<Popup> createMemoryPopup();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -68,16 +68,6 @@ std::string Value::asReference() {
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::optional<std::string> Value::asMemoryReference() {
|
|
||||||
return memoryReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
domain::ComponentInstance *Value::asMemory() {
|
|
||||||
return memory;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Value::setInt(long long value) {
|
void Value::setInt(long long value) {
|
||||||
if(isType(Value::INT)) {
|
if(isType(Value::INT)) {
|
||||||
this->intValue = value;
|
this->intValue = value;
|
||||||
|
@ -134,11 +124,11 @@ Value Value::fromReference(std::string value, Value::ValueType type) {
|
||||||
val.reference = value;
|
val.reference = value;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value Value::ofType(Value::ValueType type) {
|
Value Value::ofType(Value::ValueType type) {
|
||||||
Value val;
|
Value val;
|
||||||
val.type = type;
|
val.type = type;
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value Value::fromNull() {
|
Value Value::fromNull() {
|
||||||
|
@ -147,43 +137,4 @@ Value Value::fromNull() {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Value::stringify() {
|
|
||||||
switch (type) {
|
|
||||||
case INT:
|
|
||||||
return std::to_string(intValue);
|
|
||||||
case BOOL:
|
|
||||||
return boolValue ? "true" : "false";
|
|
||||||
case STRING:
|
|
||||||
return "\"" + stringValue + "\"";
|
|
||||||
case NIL:
|
|
||||||
return "null";
|
|
||||||
case WIRE_REFERENCE:
|
|
||||||
case ADDRESS_SPACE_REFERENCE:
|
|
||||||
case ATTRIBUTE_REFERENCE:
|
|
||||||
return reference;
|
|
||||||
case MEMORY_REFERENCE:
|
|
||||||
if(memoryReference->empty()) {
|
|
||||||
return "null";
|
|
||||||
} else {
|
|
||||||
return memoryReference.value();
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Value Value::fromMemoryReference(std::optional<std::string> value) {
|
|
||||||
Value val;
|
|
||||||
val.type = MEMORY_REFERENCE;
|
|
||||||
val.memoryReference = value;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value Value::fromMemory(domain::ComponentInstance *memory) {
|
|
||||||
Value val;
|
|
||||||
val.type = MEMORY;
|
|
||||||
val.memory = memory;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
class ComponentInstance;
|
|
||||||
|
|
||||||
class Value
|
class Value
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -21,8 +19,6 @@ public:
|
||||||
ADDRESS_SPACE,
|
ADDRESS_SPACE,
|
||||||
ADDRESS_SPACE_REFERENCE,
|
ADDRESS_SPACE_REFERENCE,
|
||||||
ATTRIBUTE_REFERENCE,
|
ATTRIBUTE_REFERENCE,
|
||||||
MEMORY_REFERENCE,
|
|
||||||
MEMORY,
|
|
||||||
WIRE_REFERENCE,
|
WIRE_REFERENCE,
|
||||||
NIL,
|
NIL,
|
||||||
UNDEFINED,
|
UNDEFINED,
|
||||||
|
@ -34,9 +30,6 @@ private:
|
||||||
bool boolValue;
|
bool boolValue;
|
||||||
std::optional<AddressSpace> addressSpace;
|
std::optional<AddressSpace> addressSpace;
|
||||||
std::string reference;
|
std::string reference;
|
||||||
domain::ComponentInstance *memory;
|
|
||||||
|
|
||||||
std::optional<std::string> memoryReference;
|
|
||||||
|
|
||||||
ValueType type;
|
ValueType type;
|
||||||
|
|
||||||
|
@ -46,33 +39,6 @@ public:
|
||||||
this->type = UNDEFINED;
|
this->type = UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equals(Value value) {
|
|
||||||
if(value.getType() == type) {
|
|
||||||
switch (type) {
|
|
||||||
case INT:
|
|
||||||
return value.asInt() == intValue;
|
|
||||||
case STRING:
|
|
||||||
return value.asString() == stringValue;
|
|
||||||
case NIL:
|
|
||||||
case UNDEFINED:
|
|
||||||
return true;
|
|
||||||
case WIRE_REFERENCE:
|
|
||||||
case ATTRIBUTE_REFERENCE:
|
|
||||||
case ADDRESS_SPACE_REFERENCE:
|
|
||||||
return value.asReference() == reference;
|
|
||||||
case MEMORY_REFERENCE:
|
|
||||||
return value.asMemoryReference() == memoryReference;
|
|
||||||
case MEMORY:
|
|
||||||
return value.asMemory() == memory;
|
|
||||||
case BOOL:
|
|
||||||
return value.asBool() == boolValue;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string string();
|
std::string string();
|
||||||
|
|
||||||
ValueType getType();
|
ValueType getType();
|
||||||
|
@ -82,8 +48,6 @@ public:
|
||||||
std::string asString();
|
std::string asString();
|
||||||
bool asBool();
|
bool asBool();
|
||||||
std::string asReference();
|
std::string asReference();
|
||||||
std::optional<std::string> asMemoryReference();
|
|
||||||
domain::ComponentInstance* asMemory();
|
|
||||||
AddressSpace asAddressSpace();
|
AddressSpace asAddressSpace();
|
||||||
|
|
||||||
void setInt(long long intValue);
|
void setInt(long long intValue);
|
||||||
|
@ -91,8 +55,6 @@ public:
|
||||||
void setBool(bool value);
|
void setBool(bool value);
|
||||||
void setReference(std::string value);
|
void setReference(std::string value);
|
||||||
|
|
||||||
std::string stringify();
|
|
||||||
|
|
||||||
static Value fromInt(long long value);
|
static Value fromInt(long long value);
|
||||||
static Value fromString(std::string value);
|
static Value fromString(std::string value);
|
||||||
static Value fromBool(bool value);
|
static Value fromBool(bool value);
|
||||||
|
@ -100,8 +62,6 @@ public:
|
||||||
static Value fromAddressSpace(AddressSpace addressSpace);
|
static Value fromAddressSpace(AddressSpace addressSpace);
|
||||||
static Value fromReference(std::string value, ValueType type);
|
static Value fromReference(std::string value, ValueType type);
|
||||||
static Value ofType(ValueType type);
|
static Value ofType(ValueType type);
|
||||||
static Value fromMemoryReference(std::optional<std::string> memoryReference);
|
|
||||||
static Value fromMemory(domain::ComponentInstance *memory);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#include "astnode.h"
|
#include "astnode.h"
|
||||||
|
|
||||||
/*************************** AST NODE ********************************/
|
|
||||||
|
|
||||||
AstNode::~AstNode() = default;
|
AstNode::~AstNode() = default;
|
||||||
|
|
||||||
/*************************** NUMBER NODE ********************************/
|
NumberNode::NumberNode(std::string expression) {
|
||||||
|
|
||||||
NumberNode::NumberNode(const std::string& expression) {
|
|
||||||
if(expression.size() > 2) {
|
if(expression.size() > 2) {
|
||||||
if(expression.substr(0, 2) == "0x") {
|
if(expression.substr(0, 2) == "0x") {
|
||||||
this->value = std::stoll(expression, 0, 16);
|
this->value = std::stoll(expression, 0, 16);
|
||||||
|
@ -19,91 +15,3 @@ NumberNode::NumberNode(const std::string& expression) {
|
||||||
this->value = std::stoll(expression, 0, 10);
|
this->value = std::stoll(expression, 0, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************** STRING NODE ********************************/
|
|
||||||
|
|
||||||
std::string StringNode::asString() {
|
|
||||||
return value.substr(1, value.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************** VALUE NODE ********************************/
|
|
||||||
|
|
||||||
long long ValueNode::asInt() {
|
|
||||||
if(is(INT)) {
|
|
||||||
return intValue.value();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ValueNode::asString() {
|
|
||||||
if(is(STRING)) {
|
|
||||||
return stringValue.value();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ValueNode::asIdentifier() {
|
|
||||||
if(is(IDENTIFIER) || is(WIRE)) {
|
|
||||||
return identifierValue.value();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValueNode::asBool() {
|
|
||||||
if(is(BOOL)) {
|
|
||||||
return boolValue.value();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValueNode::is(ValueNode::ValueType valueType) {
|
|
||||||
return type.value == valueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofBool(bool _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(BOOL);
|
|
||||||
value.boolValue = std::optional<bool>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofInt(long long int _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(INT);
|
|
||||||
value.intValue = std::optional<long long>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofString(std::string _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(STRING);
|
|
||||||
value.stringValue = std::optional<std::string>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofIdentifier(std::string _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(IDENTIFIER);
|
|
||||||
value.identifierValue = std::optional<std::string>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofNull() {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(NIL);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofWire(std::optional<std::string> _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(WIRE);
|
|
||||||
value.identifierValue = _value;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofMemory(std::optional<std::string> _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(MEMORY);
|
|
||||||
value.identifierValue = _value;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,27 +16,24 @@ public:
|
||||||
|
|
||||||
AstNode() = default;
|
AstNode() = default;
|
||||||
|
|
||||||
virtual ~AstNode();
|
virtual ~AstNode(); // this is defined in Ast.cpp just so that the
|
||||||
|
// compiler doesn't complain about not knowing which
|
||||||
|
// object file to include the vtable in
|
||||||
AstNode(AstNode&&) = default;
|
AstNode(AstNode&&) = default;
|
||||||
|
|
||||||
AstNode& operator=(AstNode&&) = default;
|
AstNode& operator=(AstNode&&) = default;
|
||||||
AstNode(const AstNode&) = default;
|
AstNode(const AstNode&) = default;
|
||||||
|
|
||||||
AstNode& operator=(const AstNode&) = default;
|
AstNode& operator=(const AstNode&) = default;
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct EnumNode: public AstNode
|
|
||||||
{
|
|
||||||
EnumNode() = default;
|
|
||||||
explicit EnumNode(T value): value(value) {}
|
|
||||||
|
|
||||||
T value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StringNode: public AstNode
|
struct StringNode: public AstNode
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value;
|
||||||
std::string asString();
|
std::string asString() {
|
||||||
|
return value.substr(1, value.length() - 2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdentifierNode: public AstNode
|
struct IdentifierNode: public AstNode
|
||||||
|
@ -46,7 +43,7 @@ struct IdentifierNode: public AstNode
|
||||||
|
|
||||||
struct NumberNode: public AstNode {
|
struct NumberNode: public AstNode {
|
||||||
long long int value;
|
long long int value;
|
||||||
explicit NumberNode(const std::string& expression);
|
NumberNode(std::string expression);
|
||||||
NumberNode(): value(0) {}
|
NumberNode(): value(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +54,7 @@ struct CountNode: public AstNode
|
||||||
NumberNode second;
|
NumberNode second;
|
||||||
|
|
||||||
CountNode(NumberNode first, NumberNode second): first(first), second(second) {}
|
CountNode(NumberNode first, NumberNode second): first(first), second(second) {}
|
||||||
CountNode() = default;
|
CountNode() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +65,7 @@ struct AddressSpaceNode: public AstNode
|
||||||
NumberNode end;
|
NumberNode end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ValueNode: public AstNode
|
class ValueNode: public AstNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -77,37 +75,92 @@ public:
|
||||||
BOOL,
|
BOOL,
|
||||||
WIRE,
|
WIRE,
|
||||||
IDENTIFIER,
|
IDENTIFIER,
|
||||||
MEMORY,
|
|
||||||
NIL,
|
NIL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EnumNode<ValueType> type;
|
ValueType type;
|
||||||
std::optional<long long> intValue;
|
std::optional<long long> intValue;
|
||||||
std::optional<std::string> stringValue;
|
std::optional<std::string> stringValue;
|
||||||
std::optional<bool> boolValue;
|
std::optional<bool> boolValue;
|
||||||
std::optional<std::string> identifierValue;
|
std::optional<std::string> identifierValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueNode() = default;
|
ValueNode() {};
|
||||||
|
|
||||||
ValueType getType() {
|
ValueType getType() {
|
||||||
return type.value;
|
return type;
|
||||||
|
}
|
||||||
|
long long asInt() {
|
||||||
|
if(is(INT)) {
|
||||||
|
return intValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to int";
|
||||||
|
}
|
||||||
|
std::string asString() {
|
||||||
|
if(is(STRING)) {
|
||||||
|
return stringValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to string";
|
||||||
|
}
|
||||||
|
std::string asIdentifier() {
|
||||||
|
if(is(IDENTIFIER) || is(WIRE)) {
|
||||||
|
return identifierValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to identifier";
|
||||||
|
}
|
||||||
|
bool asBool() {
|
||||||
|
if(is(BOOL)) {
|
||||||
|
return boolValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to bool";
|
||||||
}
|
}
|
||||||
long long asInt();
|
|
||||||
std::string asString();
|
|
||||||
std::string asIdentifier();
|
|
||||||
bool asBool();
|
|
||||||
|
|
||||||
bool is(ValueType valueType);
|
bool is(ValueType type) {
|
||||||
|
return this->type == type;
|
||||||
|
}
|
||||||
|
|
||||||
static ValueNode ofBool(bool _value);
|
static ValueNode ofBool(bool _value) {
|
||||||
static ValueNode ofInt(long long _value);
|
ValueNode value;
|
||||||
static ValueNode ofString(std::string _value);
|
value.type = BOOL;
|
||||||
static ValueNode ofIdentifier(std::string _value);
|
value.boolValue = std::optional<bool>(_value);
|
||||||
static ValueNode ofMemory(std::optional<std::string> _value);
|
return value;
|
||||||
static ValueNode ofNull();
|
}
|
||||||
static ValueNode ofWire(std::optional<std::string> _value);
|
|
||||||
|
static ValueNode ofInt(long long _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = INT;
|
||||||
|
value.intValue = std::optional<long long>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofString(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = STRING;
|
||||||
|
value.stringValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofIdentifier(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = IDENTIFIER;
|
||||||
|
value.identifierValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofNull() {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = NIL;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofWire(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = WIRE;
|
||||||
|
value.identifierValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConditionNode
|
struct ConditionNode
|
||||||
|
@ -124,7 +177,7 @@ public:
|
||||||
WARNING
|
WARNING
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumNode<ActionType> type;
|
ActionType type;
|
||||||
StringNode message;
|
StringNode message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,11 +188,14 @@ struct IfStatementNode: public AstNode
|
||||||
ActionNode action;
|
ActionNode action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RuleNode: public AstNode
|
struct RuleNode: public AstNode
|
||||||
{
|
{
|
||||||
std::vector<IfStatementNode> statements;
|
std::vector<IfStatementNode> statements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct EnumerationNode: public AstNode
|
struct EnumerationNode: public AstNode
|
||||||
{
|
{
|
||||||
StringNode key;
|
StringNode key;
|
||||||
|
@ -153,7 +209,7 @@ struct PopupNode: public AstNode
|
||||||
ON_DEMAND
|
ON_DEMAND
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<EnumNode<PopupType>> type;
|
std::optional<PopupType> type;
|
||||||
std::optional<StringNode> title;
|
std::optional<StringNode> title;
|
||||||
std::optional<StringNode> text;
|
std::optional<StringNode> text;
|
||||||
|
|
||||||
|
@ -169,28 +225,32 @@ struct PropertyNode: public AstNode
|
||||||
ValueNode value;
|
ValueNode value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct DisplayItemNode: public AstNode
|
struct DisplayItemNode: public AstNode
|
||||||
{
|
{
|
||||||
IdentifierNode type;
|
IdentifierNode type;
|
||||||
std::vector<PropertyNode> values;
|
std::vector<PropertyNode> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct DisplayNode: public AstNode
|
struct DisplayNode: public AstNode
|
||||||
{
|
{
|
||||||
std::vector<DisplayItemNode> items;
|
std::vector<DisplayItemNode> items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PinConnectionNode: public AstNode
|
struct PinConnectionNode: public AstNode
|
||||||
{
|
{
|
||||||
enum ConnectionType {
|
enum ConnectionType {
|
||||||
REQUIRED,
|
CHECK_ONLY,
|
||||||
OPTIONAL
|
AUTOMATICALLY
|
||||||
};
|
};
|
||||||
|
|
||||||
StringNode message;
|
StringNode message;
|
||||||
EnumNode<ConnectionType> type;
|
ConnectionType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PinNode: public AstNode
|
struct PinNode: public AstNode
|
||||||
{
|
{
|
||||||
enum PinType {
|
enum PinType {
|
||||||
|
@ -200,13 +260,14 @@ struct PinNode: public AstNode
|
||||||
};
|
};
|
||||||
|
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
EnumNode<PinType> type;
|
PinType type;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<PinConnectionNode> connection;
|
std::optional<PinConnectionNode> connection;
|
||||||
std::optional<DisplayNode> display;
|
std::optional<DisplayNode> display;
|
||||||
std::optional<std::vector<ValueNode>> wires;
|
std::optional<std::vector<ValueNode>> wires;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct WireNode: public AstNode
|
struct WireNode: public AstNode
|
||||||
{
|
{
|
||||||
enum WireType {
|
enum WireType {
|
||||||
|
@ -215,16 +276,17 @@ struct WireNode: public AstNode
|
||||||
WIRED_OR,
|
WIRED_OR,
|
||||||
R_WIRE
|
R_WIRE
|
||||||
};
|
};
|
||||||
EnumNode<WireType> type;
|
WireType type;
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
NumberNode size;
|
NumberNode size;
|
||||||
|
|
||||||
bool hidden = false;
|
bool hidden;
|
||||||
|
|
||||||
bool hasTerminateWith;
|
bool hasTermination;
|
||||||
ValueNode terminateWith;
|
long long isUnterminated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct AttributeNode: public AstNode
|
struct AttributeNode: public AstNode
|
||||||
{
|
{
|
||||||
ValueNode::ValueType type;
|
ValueNode::ValueType type;
|
||||||
|
@ -262,7 +324,7 @@ struct ComponentNode: public AstNode
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<StringNode> source;
|
std::optional<StringNode> source;
|
||||||
EnumNode<ComponentType> type;
|
ComponentType type;
|
||||||
std::vector<RuleNode> rules;
|
std::vector<RuleNode> rules;
|
||||||
std::optional<StringNode> instanceName;
|
std::optional<StringNode> instanceName;
|
||||||
std::optional<CountNode> count;
|
std::optional<CountNode> count;
|
||||||
|
@ -271,15 +333,15 @@ struct ComponentNode: public AstNode
|
||||||
std::vector<AttributeNode> attributes;
|
std::vector<AttributeNode> attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct BusNode: public AstNode
|
struct BusNode: public AstNode
|
||||||
{
|
{
|
||||||
enum BusType {
|
enum BusType {
|
||||||
AUTOMATIC,
|
AUTOMATIC,
|
||||||
REGULAR,
|
REGULAR
|
||||||
SINGLE_AUTOMATIC
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumNode<BusType> type;
|
BusType type;
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<CountNode> count;
|
std::optional<CountNode> count;
|
||||||
|
@ -294,7 +356,6 @@ struct LibraryNode: public AstNode
|
||||||
std::optional<StringNode> libraryInfo;
|
std::optional<StringNode> libraryInfo;
|
||||||
std::optional<StringNode> header;
|
std::optional<StringNode> header;
|
||||||
std::optional<StringNode> componentDirectory;
|
std::optional<StringNode> componentDirectory;
|
||||||
std::optional<StringNode> componentHeader;
|
|
||||||
|
|
||||||
std::vector<AddressSpaceNode> addressSpaces;
|
std::vector<AddressSpaceNode> addressSpaces;
|
||||||
|
|
||||||
|
@ -306,6 +367,15 @@ struct LibraryNode: public AstNode
|
||||||
};
|
};
|
||||||
|
|
||||||
// SCHEMA models
|
// SCHEMA models
|
||||||
|
|
||||||
|
|
||||||
|
struct WireInstanceNode: public AstNode
|
||||||
|
{
|
||||||
|
IdentifierNode name;
|
||||||
|
std::optional<CountNode> position;
|
||||||
|
std::optional<DisplayNode> display;
|
||||||
|
};
|
||||||
|
|
||||||
struct InstanceAttributeNode: public AstNode
|
struct InstanceAttributeNode: public AstNode
|
||||||
{
|
{
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
|
@ -323,8 +393,7 @@ struct InstanceNode: public AstNode
|
||||||
std::optional<NumberNode> size;
|
std::optional<NumberNode> size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConnectionComponentInstance: public AstNode
|
struct ConnectionComponentInstance {
|
||||||
{
|
|
||||||
IdentifierNode instance;
|
IdentifierNode instance;
|
||||||
IdentifierNode pin;
|
IdentifierNode pin;
|
||||||
};
|
};
|
||||||
|
@ -335,6 +404,7 @@ struct ConnectionInstanceNode: public AstNode
|
||||||
std::optional<ConnectionComponentInstance> second;
|
std::optional<ConnectionComponentInstance> second;
|
||||||
|
|
||||||
IdentifierNode bus;
|
IdentifierNode bus;
|
||||||
|
std::optional<IdentifierNode> wire;
|
||||||
|
|
||||||
std::vector<InstanceAttributeNode> attributes;
|
std::vector<InstanceAttributeNode> attributes;
|
||||||
};
|
};
|
||||||
|
@ -345,6 +415,7 @@ struct SchemaNode: public AstNode
|
||||||
std::optional<StringNode> source;
|
std::optional<StringNode> source;
|
||||||
|
|
||||||
std::vector<InstanceNode> instances;
|
std::vector<InstanceNode> instances;
|
||||||
|
std::vector<WireInstanceNode> wires;
|
||||||
std::vector<ConnectionInstanceNode> connections;
|
std::vector<ConnectionInstanceNode> connections;
|
||||||
|
|
||||||
std::optional<LibraryNode> library;
|
std::optional<LibraryNode> library;
|
||||||
|
|
|
@ -145,30 +145,6 @@ ComdelParser::parseList(std::optional<TokenType> openDelim,
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComdelParser::skipUntilNextKeyword() {
|
|
||||||
int depth = 0;
|
|
||||||
bool enteredBlock = false;
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
if(is_keyword(current().type) && (!enteredBlock || (enteredBlock && depth == 0))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(check(TokenType::LBRACE)) {
|
|
||||||
enteredBlock = true;
|
|
||||||
depth++;
|
|
||||||
} else if(check(TokenType::RBRACE)) {
|
|
||||||
if(depth == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
depth--;
|
|
||||||
} else if(check(TokenType::END_OF_FILE)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bump();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<SourceError> &ComdelParser::getErrors()
|
const std::vector<SourceError> &ComdelParser::getErrors()
|
||||||
{
|
{
|
||||||
return errors;
|
return errors;
|
||||||
|
@ -243,9 +219,6 @@ std::optional<LibraryNode> ComdelParser::parse()
|
||||||
} else if(check(TokenType::KW_HEADER)) {
|
} else if(check(TokenType::KW_HEADER)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(library.header, parseString());
|
ASSIGN_OR_SET_ERR(library.header, parseString());
|
||||||
} else if(check(TokenType::KW_COMPONENT_HEADER)) {
|
|
||||||
bump();
|
|
||||||
ASSIGN_OR_SET_ERR(library.componentHeader, parseString());
|
|
||||||
} else if(check(TokenType::KW_DIRECTORY)) {
|
} else if(check(TokenType::KW_DIRECTORY)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(library.componentDirectory, parseString());
|
ASSIGN_OR_SET_ERR(library.componentDirectory, parseString());
|
||||||
|
@ -268,17 +241,12 @@ std::optional<LibraryNode> ComdelParser::parse()
|
||||||
false,
|
false,
|
||||||
[this]{return parseProperty(std::optional<TokenType>(TokenType::STRING));}
|
[this]{return parseProperty(std::optional<TokenType>(TokenType::STRING));}
|
||||||
));
|
));
|
||||||
if(!err.has_value()) {
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
bump();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
err = unexpected();
|
||||||
bump();
|
|
||||||
}
|
}
|
||||||
if(!err.has_value()) {
|
if(!err.has_value()) {
|
||||||
errors.push_back(err.error());
|
errors.push_back(err.error());
|
||||||
skipUntilNextKeyword();
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +409,15 @@ PResult<ComponentNode> ComdelParser::parseComponent()
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(component.name, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(component.name, parseIdentifier());
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(component.type, parseComponentType());
|
if(check(TokenType::CT_PROCESSOR)) {
|
||||||
|
bump();
|
||||||
|
component.type = ComponentNode::PROCESSOR;
|
||||||
|
} else if(check(TokenType::CT_MEMORY)) {
|
||||||
|
bump();
|
||||||
|
component.type = ComponentNode::MEMORY;
|
||||||
|
} else {
|
||||||
|
component.type = ComponentNode::OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
|
@ -449,33 +425,25 @@ PResult<ComponentNode> ComdelParser::parseComponent()
|
||||||
PResult<poly<AstNode>> err;
|
PResult<poly<AstNode>> err;
|
||||||
if(check(TokenType::KW_INSTANCE_NAME)) {
|
if(check(TokenType::KW_INSTANCE_NAME)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(component.instanceName, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(component.instanceName, parseString());
|
||||||
} else if(check(TokenType::KW_TOOLTIP)) {
|
} else if(check(TokenType::KW_TOOLTIP)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(component.tooltip, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(component.tooltip, parseString());
|
||||||
} else if(check(TokenType::KW_SOURCE)) {
|
} else if(check(TokenType::KW_SOURCE)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(component.source, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(component.source, parseString());
|
||||||
} else if(check(TokenType::KW_COUNT)) {
|
} else if(check(TokenType::KW_COUNT)) {
|
||||||
ASSIGN_OR_SET_ERR(component.count, parseCount());
|
ASSIGN_OR_RETURN_IF_ERR(component.count, parseCount());
|
||||||
} else if(check(TokenType::KW_DISPLAY)) {
|
} else if(check(TokenType::KW_DISPLAY)) {
|
||||||
ASSIGN_OR_SET_ERR(component.display, parseDisplay());
|
ASSIGN_OR_RETURN_IF_ERR(component.display, parseDisplay());
|
||||||
} else if(check(TokenType::KW_PIN)) {
|
} else if(check(TokenType::KW_PIN)) {
|
||||||
APPEND_OR_SET_ERR(component.pins, parsePin());
|
APPEND_OR_RETURN_IF_ERR(component.pins, parsePin());
|
||||||
} else if(check(TokenType::KW_ATTRIBUTE)) {
|
} else if(check(TokenType::KW_ATTRIBUTE)) {
|
||||||
APPEND_OR_SET_ERR(component.attributes, parseAttribute());
|
APPEND_OR_RETURN_IF_ERR(component.attributes, parseAttribute());
|
||||||
} else if(check(TokenType::KW_RULE)) {
|
} else if(check(TokenType::KW_RULE)) {
|
||||||
APPEND_OR_SET_ERR(component.rules, parseRule());
|
APPEND_OR_RETURN_IF_ERR(component.rules, parseRule());
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,23 +452,6 @@ PResult<ComponentNode> ComdelParser::parseComponent()
|
||||||
return spanner(component);
|
return spanner(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<ComponentNode::ComponentType>> ComdelParser::parseComponentType() {
|
|
||||||
EnumNode<ComponentNode::ComponentType> type;
|
|
||||||
|
|
||||||
auto spanner = getSpanner();
|
|
||||||
|
|
||||||
if(check(TokenType::CT_PROCESSOR)) {
|
|
||||||
bump();
|
|
||||||
type = EnumNode(ComponentNode::PROCESSOR);
|
|
||||||
} else if(check(TokenType::CT_MEMORY)) {
|
|
||||||
bump();
|
|
||||||
type = EnumNode(ComponentNode::MEMORY);
|
|
||||||
} else {
|
|
||||||
type = EnumNode(ComponentNode::OTHER);
|
|
||||||
}
|
|
||||||
return spanner(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -558,15 +509,22 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(bus.name, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(bus.name, parseIdentifier());
|
||||||
|
|
||||||
auto type = parseBusType();
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
RETURN_IF_ERR(type);
|
auto tokenType = parseIdentifier();
|
||||||
|
if(tokenType.value().value == "automatic") {
|
||||||
bus.type = *type;
|
bus.type = BusNode::AUTOMATIC;
|
||||||
|
} else if(tokenType.value().value == "regular") {
|
||||||
|
bus.type = BusNode::REGULAR;
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
|
||||||
if(check(TokenType::KW_TOOLTIP)) {
|
if(check(TokenType::KW_TOOLTIP)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_RETURN_IF_ERR(bus.tooltip, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(bus.tooltip, parseString());
|
||||||
|
@ -586,15 +544,7 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
}
|
}
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::RBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::RBRACE);
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,30 +553,10 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
return spanner(bus);
|
return spanner(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<BusNode::BusType>> ComdelParser::parseBusType() {
|
|
||||||
PResult<EnumNode<BusNode::BusType>> type;
|
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
|
||||||
auto tokenType = parseIdentifier();
|
|
||||||
if(tokenType.value().value == "automatic") {
|
|
||||||
type = EnumNode(BusNode::AUTOMATIC);
|
|
||||||
} else if(tokenType.value().value == "regular") {
|
|
||||||
type = EnumNode(BusNode::REGULAR);
|
|
||||||
} else if(tokenType.value().value == "singleAutomatic") {
|
|
||||||
type = EnumNode(BusNode::SINGLE_AUTOMATIC);
|
|
||||||
} else {
|
|
||||||
type = PError(SourceError{current().span, "expected 'automatic', 'singleAutomatic' or 'regular'"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type = PError(SourceError{current().span, "expected 'automatic', 'singleAutomatic' or 'regular'"});
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* WireNode := NAME(<SIZE>){0,1} TYPE [hidden | terminated_with (#number | null)])*
|
* WireNode := NAME(<SIZE>){0,1} TYPE)*
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
PResult<WireNode> ComdelParser::parseWire() {
|
PResult<WireNode> ComdelParser::parseWire() {
|
||||||
|
@ -644,42 +574,20 @@ PResult<WireNode> ComdelParser::parseWire() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// default
|
// default
|
||||||
wire.type = EnumNode(WireNode::WIRE);
|
wire.type = WireNode::WIRE;
|
||||||
|
|
||||||
if(check(TokenType::WIRE_DEFAULT)) {
|
if(check(TokenType::WIRE_DEFAULT)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRE);
|
wire.type = WireNode::WIRE;
|
||||||
} else if(check(TokenType::WIRE_AND)) {
|
} else if(check(TokenType::WIRE_AND)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRED_AND);
|
wire.type = WireNode::WIRED_AND;
|
||||||
} else if(check(TokenType::WIRE_OR)) {
|
} else if(check(TokenType::WIRE_OR)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRED_OR);
|
wire.type = WireNode::WIRED_OR;
|
||||||
} else if(check(TokenType::R_WIRE)) {
|
} else if(check(TokenType::R_WIRE)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::R_WIRE);
|
wire.type = WireNode::R_WIRE;
|
||||||
}
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
if(check(TokenType::HIDDEN)) {
|
|
||||||
bump();
|
|
||||||
wire.hidden = true;
|
|
||||||
} else if(check(TokenType::TERMINATE_WITH)) {
|
|
||||||
bump();
|
|
||||||
wire.hasTerminateWith = true;
|
|
||||||
if(check(TokenType::NIL)) {
|
|
||||||
bump();
|
|
||||||
wire.terminateWith = ValueNode::ofNull();
|
|
||||||
} else if(check(TokenType::NUMBER)) {
|
|
||||||
auto number = parseNumber();
|
|
||||||
wire.terminateWith = ValueNode::ofInt(number->value);
|
|
||||||
} else {
|
|
||||||
auto token = current();
|
|
||||||
return PError(SourceError{token.span, "unexpected token"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return spanner(wire);
|
return spanner(wire);
|
||||||
|
@ -705,13 +613,13 @@ PResult<PinNode> ComdelParser::parsePin() {
|
||||||
|
|
||||||
if(check(TokenType::PIN_IN)) {
|
if(check(TokenType::PIN_IN)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::IN);
|
pin.type = PinNode::IN;
|
||||||
} else if(check(TokenType::PIN_OUT)) {
|
} else if(check(TokenType::PIN_OUT)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::OUT);
|
pin.type = PinNode::OUT;
|
||||||
} else if(check(TokenType::PIN_IN_OUT)) {
|
} else if(check(TokenType::PIN_IN_OUT)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::IN_OUT);
|
pin.type = PinNode::IN_OUT;
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
@ -719,14 +627,13 @@ PResult<PinNode> ComdelParser::parsePin() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
|
||||||
if (check(TokenType::KW_TOOLTIP)) {
|
if (check(TokenType::KW_TOOLTIP)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(pin.tooltip, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(pin.tooltip, parseString());
|
||||||
} else if (check(TokenType::KW_DISPLAY)) {
|
} else if (check(TokenType::KW_DISPLAY)) {
|
||||||
ASSIGN_OR_SET_ERR(pin.display, parseDisplay());
|
ASSIGN_OR_RETURN_IF_ERR(pin.display, parseDisplay());
|
||||||
} else if (check(TokenType::KW_CONNECTION)) {
|
} else if (check(TokenType::KW_CONNECTION)) {
|
||||||
ASSIGN_OR_SET_ERR(pin.connection, parsePinConnection());
|
ASSIGN_OR_RETURN_IF_ERR(pin.connection, parsePinConnection());
|
||||||
} else if (check(TokenType::KW_WIRES)){
|
} else if (check(TokenType::KW_WIRES)){
|
||||||
bump();
|
bump();
|
||||||
auto wires = parseList<ValueNode>(std::optional<TokenType>(TokenType::LBRACE), TokenType::RBRACE, std::optional<TokenType>(TokenType::COMMA), false,
|
auto wires = parseList<ValueNode>(std::optional<TokenType>(TokenType::LBRACE), TokenType::RBRACE, std::optional<TokenType>(TokenType::COMMA), false,
|
||||||
|
@ -734,15 +641,7 @@ PResult<PinNode> ComdelParser::parsePin() {
|
||||||
RETURN_IF_ERR(wires);
|
RETURN_IF_ERR(wires);
|
||||||
pin.wires = *wires;
|
pin.wires = *wires;
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,7 +662,18 @@ PResult<PinConnectionNode> ComdelParser::parsePinConnection() {
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION);
|
RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION);
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(connection.type, parseConnectionType());
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
|
auto type = parseIdentifier();
|
||||||
|
if(type.value().value == "check_only") {
|
||||||
|
connection.type = PinConnectionNode::CHECK_ONLY;
|
||||||
|
} else if(type.value().value == "automatically") {
|
||||||
|
connection.type = PinConnectionNode::AUTOMATICALLY;
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LPAREN);
|
RETURN_IF_NOT_TOKEN(TokenType::LPAREN);
|
||||||
ASSIGN_OR_RETURN_IF_ERR(connection.message, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(connection.message, parseString());
|
||||||
|
@ -772,26 +682,6 @@ PResult<PinConnectionNode> ComdelParser::parsePinConnection() {
|
||||||
return spanner(connection);
|
return spanner(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<PinConnectionNode::ConnectionType>> ComdelParser::parseConnectionType() {
|
|
||||||
auto spanner = getSpanner();
|
|
||||||
|
|
||||||
EnumNode<PinConnectionNode::ConnectionType> type;
|
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
|
||||||
auto identifier = parseIdentifier();
|
|
||||||
if(identifier.value().value == "required") {
|
|
||||||
type = EnumNode(PinConnectionNode::REQUIRED);
|
|
||||||
} else if(identifier.value().value == "optional") {
|
|
||||||
type = EnumNode(PinConnectionNode::OPTIONAL);
|
|
||||||
} else {
|
|
||||||
return PError(SourceError{current().span, "expected connection type 'required' or 'optional'"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return PError(SourceError{current().span, "expected connection type 'required' or 'optional'"});
|
|
||||||
}
|
|
||||||
|
|
||||||
return spanner(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -856,23 +746,13 @@ PResult<AttributeNode> ComdelParser::parseAttribute() {
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
} else if(attribute.type == ValueNode::MEMORY) {
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
|
||||||
auto identifier = parseIdentifier();
|
|
||||||
attribute.defaultValue = ValueNode::ofMemory(identifier->value);
|
|
||||||
} else if(check(TokenType::NIL)) {
|
|
||||||
bump();
|
|
||||||
attribute.defaultValue = ValueNode::ofMemory(std::nullopt);
|
|
||||||
} else {
|
|
||||||
return unexpected();
|
|
||||||
}
|
|
||||||
} else if(attribute.type == ValueNode::WIRE) {
|
} else if(attribute.type == ValueNode::WIRE) {
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
auto identifier = parseIdentifier();
|
auto identifier = parseIdentifier();
|
||||||
attribute.defaultValue = ValueNode::ofWire(identifier->value);
|
attribute.defaultValue = ValueNode::ofWire(identifier->value);
|
||||||
} else if(check(TokenType::NIL)) {
|
} else if(check(TokenType::NIL)) {
|
||||||
bump();
|
bump();
|
||||||
attribute.defaultValue = ValueNode::ofWire(std::nullopt);
|
attribute.defaultValue = ValueNode::ofNull();
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
@ -928,34 +808,33 @@ PResult<PopupNode> ComdelParser::parsePopup() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::KW_POPUP);
|
RETURN_IF_NOT_TOKEN(TokenType::KW_POPUP);
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
auto identifier = parseIdentifier();
|
auto type = parseIdentifier();
|
||||||
if(identifier.value().value == "automatic") {
|
if(type.value().value == "automatic") {
|
||||||
popup.type = EnumNode(PopupNode::AUTOMATIC);
|
popup.type = PopupNode::AUTOMATIC;
|
||||||
} else if(identifier.value().value == "on_demand") {
|
} else if(type.value().value == "on_demand") {
|
||||||
popup.type = EnumNode(PopupNode::ON_DEMAND);
|
popup.type = PopupNode::ON_DEMAND;
|
||||||
} else {
|
} else {
|
||||||
return PError(SourceError{current().span, "expected type 'automatic', 'on_demand'"});
|
return PError(SourceError{current().span, "expected type 'automatic', 'on_demand'"});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
popup.type = EnumNode(PopupNode::ON_DEMAND);
|
popup.type = PopupNode::ON_DEMAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
|
||||||
if(check(TokenType::KW_TITLE)) {
|
if(check(TokenType::KW_TITLE)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(popup.title, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(popup.title, parseString());
|
||||||
} else if(check(TokenType::KW_TEXT)) {
|
} else if(check(TokenType::KW_TEXT)) {
|
||||||
bump();
|
bump();
|
||||||
ASSIGN_OR_SET_ERR(popup.text, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(popup.text, parseString());
|
||||||
} else if(check(TokenType::KW_RULE)) {
|
} else if(check(TokenType::KW_RULE)) {
|
||||||
APPEND_OR_SET_ERR(popup.rules, parseRule());
|
APPEND_OR_RETURN_IF_ERR(popup.rules, parseRule());
|
||||||
} else if(check(TokenType::KW_ENUMERATED)) {
|
} else if(check(TokenType::KW_ENUMERATED)) {
|
||||||
bump();
|
bump();
|
||||||
popup.enumerated = true;
|
popup.enumerated = true;
|
||||||
ASSIGN_OR_SET_ERR(popup.enumeration,
|
ASSIGN_OR_RETURN_IF_ERR(popup.enumeration,
|
||||||
parseList<EnumerationNode>(
|
parseList<EnumerationNode>(
|
||||||
std::optional<TokenType>(TokenType::LBRACE),
|
std::optional<TokenType>(TokenType::LBRACE),
|
||||||
TokenType::RBRACE,
|
TokenType::RBRACE,
|
||||||
|
@ -965,15 +844,7 @@ PResult<PopupNode> ComdelParser::parsePopup() {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,7 +855,7 @@ PResult<PopupNode> ComdelParser::parsePopup() {
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* ConnectionNode := "@connection (" + COMPONENT + "." + PIN + "," + BUS [ + "," + COMPONENT2 + "." + "PIN2"] + ") {" + CONNECTION + "}"
|
* ConnectionNode := "@connection (" + COMPONENT + "." + PIN + "," + BUS) {" + CONNECTION + "}"
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
PResult<ConnectionNode> ComdelParser::parseConnection() {
|
PResult<ConnectionNode> ComdelParser::parseConnection() {
|
||||||
|
@ -1003,6 +874,7 @@ PResult<ConnectionNode> ComdelParser::parseConnection() {
|
||||||
if(check(TokenType::COMMA)) {
|
if(check(TokenType::COMMA)) {
|
||||||
auto conn = ConnectionComponentNode{};
|
auto conn = ConnectionComponentNode{};
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::COMMA);
|
RETURN_IF_NOT_TOKEN(TokenType::COMMA);
|
||||||
|
RETURN_IF_NOT_TOKEN(TokenType::LPAREN);
|
||||||
ASSIGN_OR_RETURN_IF_ERR(conn.component, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(conn.component, parseIdentifier());
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::DOT);
|
RETURN_IF_NOT_TOKEN(TokenType::DOT);
|
||||||
ASSIGN_OR_RETURN_IF_ERR(conn.pin, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(conn.pin, parseIdentifier());
|
||||||
|
@ -1016,7 +888,6 @@ PResult<ConnectionNode> ComdelParser::parseConnection() {
|
||||||
int wireCount = 0;
|
int wireCount = 0;
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
|
||||||
if (check(TokenType::KW_ATTRIBUTE)) {
|
if (check(TokenType::KW_ATTRIBUTE)) {
|
||||||
APPEND_OR_RETURN_IF_ERR(connection.attributes, parseAttribute());
|
APPEND_OR_RETURN_IF_ERR(connection.attributes, parseAttribute());
|
||||||
} else if(check(TokenType::KW_WIRES)) {
|
} else if(check(TokenType::KW_WIRES)) {
|
||||||
|
@ -1033,15 +904,7 @@ PResult<ConnectionNode> ComdelParser::parseConnection() {
|
||||||
}
|
}
|
||||||
wireCount++;
|
wireCount++;
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,9 +975,9 @@ PResult<IfStatementNode> ComdelParser::parseIfStatement() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
if(check(TokenType::ERROR)) {
|
if(check(TokenType::ERROR)) {
|
||||||
ifStatement.action.type = EnumNode(ActionNode::ERROR);
|
ifStatement.action.type = ActionNode::ERROR;
|
||||||
} else if(check(TokenType::WARNING)) {
|
} else if(check(TokenType::WARNING)) {
|
||||||
ifStatement.action.type = EnumNode(ActionNode::WARNING);
|
ifStatement.action.type = ActionNode::WARNING;
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
@ -1166,21 +1029,21 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||||
auto source = parseString();
|
auto source = parseString();
|
||||||
schema.source = *source;
|
schema.source = *source;
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(current().span, "expected `@source`");
|
errors.push_back(SourceError{current().span, "expected `@source`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(current().span, "expected `@source`");
|
errors.push_back(SourceError{current().span, "expected `@source`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check(TokenType::KW_SCHEMA)) {
|
if(!check(TokenType::KW_SCHEMA)) {
|
||||||
errors.emplace_back(current().span, "expected `@schema`");
|
errors.push_back(SourceError{current().span, "expected `@schema`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
bump();
|
bump();
|
||||||
if(!check(TokenType::LBRACE)) {
|
if(!check(TokenType::LBRACE)) {
|
||||||
errors.emplace_back(current().span, "expected `{`");
|
errors.push_back(SourceError{current().span, "expected `{`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
bump();
|
bump();
|
||||||
|
@ -1189,30 +1052,27 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||||
PResult<poly<AstNode>> err;
|
PResult<poly<AstNode>> err;
|
||||||
if(check(TokenType::KW_INSTANCE)){
|
if(check(TokenType::KW_INSTANCE)){
|
||||||
APPEND_OR_SET_ERR(schema.instances, parseInstance());
|
APPEND_OR_SET_ERR(schema.instances, parseInstance());
|
||||||
|
} else if(check(TokenType::KW_WIRE)) {
|
||||||
|
APPEND_OR_SET_ERR(schema.wires, parseWireInstance());
|
||||||
} else if(check(TokenType::KW_CONNECTION)) {
|
} else if(check(TokenType::KW_CONNECTION)) {
|
||||||
APPEND_OR_SET_ERR(schema.connections, parseConnectionInstance());
|
APPEND_OR_SET_ERR(schema.connections, parseConnectionInstance());
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
err = unexpected();
|
||||||
bump();
|
|
||||||
}
|
}
|
||||||
if(!err.has_value()) {
|
if(!err.has_value()) {
|
||||||
errors.push_back(err.error());
|
errors.push_back(err.error());
|
||||||
skipUntilNextKeyword();
|
break;
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
errors.emplace_back(current().span, "expected `}` reached EOF");
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!check(TokenType::RBRACE)) {
|
if(!check(TokenType::RBRACE)) {
|
||||||
errors.emplace_back(current().span, "expected `}`");
|
errors.push_back(SourceError{current().span, "expected `}`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else {
|
} else {
|
||||||
bump();
|
bump();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check(TokenType::END_OF_FILE)) {
|
if(!check(TokenType::END_OF_FILE)) {
|
||||||
errors.emplace_back(current().span, "expected `EOF`");
|
errors.push_back(SourceError{current().span, "expected `EOF`"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors.size())
|
if (errors.size())
|
||||||
|
@ -1220,6 +1080,30 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||||
|
|
||||||
return spanner(schema);
|
return spanner(schema);
|
||||||
}
|
}
|
||||||
|
PResult<WireInstanceNode> ComdelParser::parseWireInstance() {
|
||||||
|
auto spanner = getSpanner();
|
||||||
|
WireInstanceNode wireInstance;
|
||||||
|
|
||||||
|
RETURN_IF_NOT_TOKEN(TokenType::KW_WIRE);
|
||||||
|
ASSIGN_OR_RETURN_IF_ERR(wireInstance.name, parseIdentifier());
|
||||||
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
|
while(!check(TokenType::RBRACE)) {
|
||||||
|
if(check(TokenType::KW_POSITION)) {
|
||||||
|
ASSIGN_OR_RETURN_IF_ERR(wireInstance.position, parsePosition());
|
||||||
|
} else if(check(TokenType::KW_DISPLAY)) {
|
||||||
|
ASSIGN_OR_RETURN_IF_ERR(wireInstance.display, parseDisplay());
|
||||||
|
} else {
|
||||||
|
return unexpected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_IF_NOT_TOKEN(TokenType::RBRACE);
|
||||||
|
|
||||||
|
return spanner(wireInstance);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -1258,26 +1142,17 @@ PResult<InstanceNode> ComdelParser::parseInstance() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
|
||||||
if(check(TokenType::KW_POSITION)) {
|
if(check(TokenType::KW_POSITION)) {
|
||||||
ASSIGN_OR_SET_ERR(instance.position, parsePosition());
|
ASSIGN_OR_RETURN_IF_ERR(instance.position, parsePosition());
|
||||||
} else if(check(TokenType::KW_ATTRIBUTE)) {
|
} else if(check(TokenType::KW_ATTRIBUTE)) {
|
||||||
APPEND_OR_SET_ERR(instance.attributes, parseInstanceAttribute());
|
APPEND_OR_RETURN_IF_ERR(instance.attributes, parseInstanceAttribute());
|
||||||
} else if(check(TokenType::KW_SIZE)) {
|
} else if(check(TokenType::KW_SIZE)) {
|
||||||
bump();
|
bump();
|
||||||
auto number = parseNumber();
|
auto number = parseNumber();
|
||||||
RETURN_IF_ERR(number);
|
RETURN_IF_ERR(number);
|
||||||
instance.size = *number;
|
instance.size = *number;
|
||||||
} else {
|
} else {
|
||||||
err = unexpected();
|
return unexpected();
|
||||||
bump();
|
|
||||||
}
|
|
||||||
if(!err.has_value()) {
|
|
||||||
errors.push_back(err.error());
|
|
||||||
skipUntilNextKeyword();
|
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,19 +1197,13 @@ PResult<ConnectionInstanceNode> ComdelParser::parseConnectionInstance() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
while(!check(TokenType::RBRACE)) {
|
while(!check(TokenType::RBRACE)) {
|
||||||
PResult<poly<AstNode>> err;
|
if(check(TokenType::KW_WIRE)) {
|
||||||
if(check(TokenType::KW_ATTRIBUTE)) {
|
|
||||||
APPEND_OR_SET_ERR(connection.attributes, parseInstanceAttribute());
|
|
||||||
} else {
|
|
||||||
err = unexpected();
|
|
||||||
bump();
|
bump();
|
||||||
}
|
ASSIGN_OR_RETURN_IF_ERR(connection.wire, parseIdentifier());
|
||||||
if(!err.has_value()) {
|
} else if(check(TokenType::KW_ATTRIBUTE)) {
|
||||||
errors.push_back(err.error());
|
APPEND_OR_RETURN_IF_ERR(connection.attributes, parseInstanceAttribute());
|
||||||
skipUntilNextKeyword();
|
} else {
|
||||||
if(check(TokenType::END_OF_FILE)) {
|
return unexpected();
|
||||||
return PError({Span(spanner.lo), "Reached EOF"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1344,16 +1213,13 @@ PResult<ConnectionInstanceNode> ComdelParser::parseConnectionInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<ValueNode> ComdelParser::parseConnectionWire() {
|
PResult<ValueNode> ComdelParser::parseConnectionWire() {
|
||||||
auto spanner = getSpanner();
|
|
||||||
if(check(TokenType::NUMBER)) {
|
if(check(TokenType::NUMBER)) {
|
||||||
return spanner(ValueNode::ofInt(parseNumber()->value));
|
return ValueNode::ofInt(parseNumber()->value);
|
||||||
} else if(check(TokenType::NIL)) {
|
} else if(check(TokenType::NIL)) {
|
||||||
bump();
|
bump();
|
||||||
return spanner(ValueNode::ofNull());
|
return ValueNode::ofNull();
|
||||||
} else if(check(TokenType::STRING)) {
|
|
||||||
return spanner(ValueNode::ofString(parseString()->value));
|
|
||||||
} else if(check(TokenType::IDENTIFIER)) {
|
} else if(check(TokenType::IDENTIFIER)) {
|
||||||
return spanner(ValueNode::ofIdentifier(parseIdentifier()->value));
|
return ValueNode::ofIdentifier(parseIdentifier()->value);
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,13 @@
|
||||||
/// Spanner's call operator MOVES from the node so it should
|
/// Spanner's call operator MOVES from the node so it should
|
||||||
/// be always used last.
|
/// be always used last.
|
||||||
class Spanner {
|
class Spanner {
|
||||||
|
const Span lo; // the low end of the span, beginning of the node
|
||||||
|
|
||||||
// REFERENCE to the parser's prevSpan. After parsing a node this will
|
// REFERENCE to the parser's prevSpan. After parsing a node this will
|
||||||
// "point" to the span of the last token contained in the node.
|
// "point" to the span of the last token contained in the node.
|
||||||
const Span& prevSpan;
|
const Span& prevSpan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Span lo; // the low end of the span, beginning of the node
|
|
||||||
|
|
||||||
|
|
||||||
Spanner(Span lo, Span& prevSpan) : lo(lo), prevSpan(prevSpan) {}
|
Spanner(Span lo, Span& prevSpan) : lo(lo), prevSpan(prevSpan) {}
|
||||||
|
|
||||||
template <typename T, typename = std::enable_if<std::is_base_of<AstNode, T>::value>>
|
template <typename T, typename = std::enable_if<std::is_base_of<AstNode, T>::value>>
|
||||||
|
@ -49,8 +48,6 @@ private:
|
||||||
bool consume(TokenType tokenType);
|
bool consume(TokenType tokenType);
|
||||||
bool check(TokenType tokenType);
|
bool check(TokenType tokenType);
|
||||||
|
|
||||||
void skipUntilNextKeyword();
|
|
||||||
|
|
||||||
Token ¤t();
|
Token ¤t();
|
||||||
|
|
||||||
[[nodiscard]] PError unexpected();
|
[[nodiscard]] PError unexpected();
|
||||||
|
@ -64,6 +61,7 @@ private:
|
||||||
|
|
||||||
Spanner getSpanner();
|
Spanner getSpanner();
|
||||||
|
|
||||||
|
|
||||||
PResult<StringNode> parseString();
|
PResult<StringNode> parseString();
|
||||||
PResult<IdentifierNode> parseIdentifier();
|
PResult<IdentifierNode> parseIdentifier();
|
||||||
PResult<NumberNode> parseNumber();
|
PResult<NumberNode> parseNumber();
|
||||||
|
@ -88,6 +86,7 @@ private:
|
||||||
PResult<ValueNode> parseValue();
|
PResult<ValueNode> parseValue();
|
||||||
|
|
||||||
|
|
||||||
|
PResult<WireInstanceNode> parseWireInstance();
|
||||||
PResult<CountNode> parsePosition();
|
PResult<CountNode> parsePosition();
|
||||||
PResult<InstanceNode> parseInstance();
|
PResult<InstanceNode> parseInstance();
|
||||||
PResult<InstanceAttributeNode> parseInstanceAttribute();
|
PResult<InstanceAttributeNode> parseInstanceAttribute();
|
||||||
|
@ -98,12 +97,6 @@ public:
|
||||||
std::optional<SchemaNode> parseSchema();
|
std::optional<SchemaNode> parseSchema();
|
||||||
std::optional<LibraryNode> parse();
|
std::optional<LibraryNode> parse();
|
||||||
const std::vector<SourceError>& getErrors();
|
const std::vector<SourceError>& getErrors();
|
||||||
|
|
||||||
PResult<EnumNode<ComponentNode::ComponentType>> parseComponentType();
|
|
||||||
|
|
||||||
PResult<EnumNode<BusNode::BusType>> parseBusType();
|
|
||||||
|
|
||||||
PResult<EnumNode<PinConnectionNode::ConnectionType>> parseConnectionType();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMDEL_PARSER_H
|
#endif // COMDEL_PARSER_H
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "parser_util.h"
|
||||||
|
|
||||||
|
parser_util::parser_util()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef PARSER_UTIL_H
|
||||||
|
#define PARSER_UTIL_H
|
||||||
|
|
||||||
|
|
||||||
|
class parser_util
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
parser_util();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PARSER_UTIL_H
|
|
@ -72,7 +72,6 @@ enum class TokenType {
|
||||||
KW_NAME,
|
KW_NAME,
|
||||||
KW_INFO,
|
KW_INFO,
|
||||||
KW_HEADER,
|
KW_HEADER,
|
||||||
KW_COMPONENT_HEADER,
|
|
||||||
KW_DIRECTORY,
|
KW_DIRECTORY,
|
||||||
KW_LIBRARY,
|
KW_LIBRARY,
|
||||||
KW_ADDRESS,
|
KW_ADDRESS,
|
||||||
|
@ -125,10 +124,6 @@ enum class TokenType {
|
||||||
ERROR,
|
ERROR,
|
||||||
WARNING,
|
WARNING,
|
||||||
|
|
||||||
// WIRE SETTINGS
|
|
||||||
HIDDEN,
|
|
||||||
TERMINATE_WITH,
|
|
||||||
|
|
||||||
// OTHER
|
// OTHER
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,6 @@ struct TokenTables {
|
||||||
std::unordered_map<std::string, TokenType> keywords;
|
std::unordered_map<std::string, TokenType> keywords;
|
||||||
|
|
||||||
TokenType tokenize(std::string value, TokenType initial);
|
TokenType tokenize(std::string value, TokenType initial);
|
||||||
bool is_keyword(TokenType token);
|
|
||||||
|
|
||||||
void add(TokenType tokenType, const std::string& txt,
|
void add(TokenType tokenType, const std::string& txt,
|
||||||
unsigned short attribs = 0);
|
unsigned short attribs = 0);
|
||||||
|
@ -42,7 +41,7 @@ void TokenTables::add (TokenType tokenType, const std::string& txt,
|
||||||
TokenTables::TokenTables() {
|
TokenTables::TokenTables() {
|
||||||
|
|
||||||
add( TokenType::IDENTIFIER, "identifier" );
|
add( TokenType::IDENTIFIER, "identifier" );
|
||||||
add( TokenType::KEYWORD, "keyword" , KEYWORD_NAME);
|
add( TokenType::KEYWORD, "keyword" );
|
||||||
|
|
||||||
// Literals (bool is not here, it has two keywords: false and true)
|
// Literals (bool is not here, it has two keywords: false and true)
|
||||||
add( TokenType::NUMBER, "number");
|
add( TokenType::NUMBER, "number");
|
||||||
|
@ -80,35 +79,34 @@ TokenTables::TokenTables() {
|
||||||
add( TokenType::NIL, "null", TOKENIZABLE),
|
add( TokenType::NIL, "null", TOKENIZABLE),
|
||||||
|
|
||||||
// all keywords
|
// all keywords
|
||||||
add( TokenType::KW_NAME, "@name", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_NAME, "@name", TOKENIZABLE),
|
||||||
add( TokenType::KW_INFO, "@info", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_INFO, "@info", TOKENIZABLE),
|
||||||
add( TokenType::KW_HEADER, "@header", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_HEADER, "@header", TOKENIZABLE),
|
||||||
add( TokenType::KW_COMPONENT_HEADER, "@componentHeader", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_DIRECTORY, "@directory", TOKENIZABLE),
|
||||||
add( TokenType::KW_DIRECTORY, "@directory", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_LIBRARY, "@library", TOKENIZABLE),
|
||||||
add( TokenType::KW_LIBRARY, "@library", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_ADDRESS, "@address", TOKENIZABLE),
|
||||||
add( TokenType::KW_ADDRESS, "@address", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_COMPONENT, "@component", TOKENIZABLE),
|
||||||
add( TokenType::KW_COMPONENT, "@component", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_MESSAGES, "@messages", TOKENIZABLE),
|
||||||
add( TokenType::KW_MESSAGES, "@messages", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_INSTANCE_NAME, "@instanceName", TOKENIZABLE),
|
||||||
add( TokenType::KW_INSTANCE_NAME, "@instanceName", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_COUNT, "@count", TOKENIZABLE),
|
||||||
add( TokenType::KW_COUNT, "@count", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_DISPLAY, "@display", TOKENIZABLE),
|
||||||
add( TokenType::KW_DISPLAY, "@display", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_PIN, "@pin", TOKENIZABLE),
|
||||||
add( TokenType::KW_PIN, "@pin", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_TOOLTIP, "@tooltip", TOKENIZABLE),
|
||||||
add( TokenType::KW_TOOLTIP, "@tooltip", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_CONNECTION, "@connection", TOKENIZABLE),
|
||||||
add( TokenType::KW_CONNECTION, "@connection", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_ATTRIBUTE, "@attribute", TOKENIZABLE),
|
||||||
add( TokenType::KW_ATTRIBUTE, "@attribute", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_SOURCE, "@source", TOKENIZABLE),
|
||||||
add( TokenType::KW_SOURCE, "@source", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_POPUP, "@popup", TOKENIZABLE),
|
||||||
add( TokenType::KW_POPUP, "@popup", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_RULE, "@rule", TOKENIZABLE),
|
||||||
add( TokenType::KW_RULE, "@rule", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_TITLE, "@title", TOKENIZABLE),
|
||||||
add( TokenType::KW_TITLE, "@title", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_TEXT, "@text", TOKENIZABLE),
|
||||||
add( TokenType::KW_TEXT, "@text", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_BUS, "@bus", TOKENIZABLE),
|
||||||
add( TokenType::KW_BUS, "@bus", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_WIRES, "@wires", TOKENIZABLE),
|
||||||
add( TokenType::KW_WIRES, "@wires", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_ENUMERATED, "@enumerated", TOKENIZABLE),
|
||||||
add( TokenType::KW_ENUMERATED, "@enumerated", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_WIRE, "@wire", TOKENIZABLE),
|
||||||
add( TokenType::KW_WIRE, "@wire", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_INSTANCE, "@instance", TOKENIZABLE),
|
||||||
add( TokenType::KW_INSTANCE, "@instance", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_SCHEMA, "@schema", TOKENIZABLE),
|
||||||
add( TokenType::KW_SCHEMA, "@schema", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_POSITION, "@position", TOKENIZABLE),
|
||||||
add( TokenType::KW_POSITION, "@position", TOKENIZABLE | KEYWORD_NAME),
|
add( TokenType::KW_SIZE, "@size", TOKENIZABLE),
|
||||||
add( TokenType::KW_SIZE, "@size", TOKENIZABLE | KEYWORD_NAME),
|
|
||||||
|
|
||||||
// All types
|
// All types
|
||||||
add( TokenType::INT_TYPE, "int", TOKENIZABLE),
|
add( TokenType::INT_TYPE, "int", TOKENIZABLE),
|
||||||
|
@ -136,10 +134,10 @@ TokenTables::TokenTables() {
|
||||||
add( TokenType::WARNING, "warning", TOKENIZABLE),
|
add( TokenType::WARNING, "warning", TOKENIZABLE),
|
||||||
|
|
||||||
|
|
||||||
// WireNode settings types
|
// Built-in functions (they are also keywords)
|
||||||
add( TokenType::HIDDEN, "hidden", TOKENIZABLE),
|
/*
|
||||||
add( TokenType::TERMINATE_WITH, "terminate_with", TOKENIZABLE),
|
* TODO
|
||||||
|
*/
|
||||||
// Miscelaneous
|
// Miscelaneous
|
||||||
add( TokenType::END_OF_FILE, "eof" );
|
add( TokenType::END_OF_FILE, "eof" );
|
||||||
}
|
}
|
||||||
|
@ -158,19 +156,6 @@ TokenType TokenTables::tokenize(std::string value, TokenType initial) {
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenTables::is_keyword(TokenType token) {
|
|
||||||
for(auto& [key, param]: allTokensInfo) {
|
|
||||||
if(param.attributes & KEYWORD_NAME && key == token) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TokenType from_token(std::string value, TokenType initial) {
|
TokenType from_token(std::string value, TokenType initial) {
|
||||||
return tokenTables.tokenize(value, initial);
|
return tokenTables.tokenize(value, initial);
|
||||||
}
|
|
||||||
|
|
||||||
bool is_keyword(TokenType tokenType) {
|
|
||||||
return tokenTables.is_keyword(tokenType);
|
|
||||||
}
|
}
|
|
@ -10,6 +10,4 @@ const std::string& tokenTypeToString(TokenType tokenType);
|
||||||
|
|
||||||
TokenType from_token(std::string value, TokenType initial);
|
TokenType from_token(std::string value, TokenType initial);
|
||||||
|
|
||||||
bool is_keyword(TokenType tokenType);
|
|
||||||
|
|
||||||
#endif // TOKENS_TYPE_H
|
#endif // TOKENS_TYPE_H
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
@name "Jednostavni FRISC"
|
@name "Jednostavni FRISC"
|
||||||
@info "Ova biblioteka omogućuje kreiranje sustava s procesorom FRISC s pojednostavljenim načinom spajanja bez potrebe da se spajaju pojedine linije sabirnice."
|
@info "Ova biblioteka omogućuje kreiranje sustava s procesorom FRISC s pojednostavljenim načinom spajanja bez potrebe da se spajaju pojedine linije sabirnice."
|
||||||
@directory "libraries\frisc\vjezba1"
|
@directory "libraries\frisc\vjezba1"
|
||||||
@header "// Version 0.0.1"
|
|
||||||
@componentHeader " clock 100MHz;"
|
|
||||||
|
|
||||||
@address glavniAS(0,0xFFFFFFFF)
|
@address glavniAS(0,0xFFFFFFFF)
|
||||||
@address pomocniAS(0xFFFF0000,0xFFFFFFFF)
|
@address pomocniAS(0xFFFF0000,0xFFFFFFFF)
|
||||||
|
@ -19,7 +17,7 @@
|
||||||
|
|
||||||
@component FRISC processor {
|
@component FRISC processor {
|
||||||
@instanceName "procesor"
|
@instanceName "procesor"
|
||||||
@tooltip "Procesor FRISC, mora postojati jedan"
|
@tooltip "procesor FRISC, mora postojati jedan"
|
||||||
@count (1, 1)
|
@count (1, 1)
|
||||||
@source "FRISC.cdl"
|
@source "FRISC.cdl"
|
||||||
@display {
|
@display {
|
||||||
|
@ -53,7 +51,7 @@
|
||||||
}
|
}
|
||||||
@pin glavniPin inOut {
|
@pin glavniPin inOut {
|
||||||
@tooltip "pin za spajanje na glavnu sabirnicu"
|
@tooltip "pin za spajanje na glavnu sabirnicu"
|
||||||
@connection required("COMDEL se ne može stvoriti. FRISC nije spojen na sabirnicu")
|
@connection check_only("COMDEL se ne može stvoriti. FRISC nije spojen na sabirnicu")
|
||||||
@display {
|
@display {
|
||||||
/*
|
/*
|
||||||
pin {
|
pin {
|
||||||
|
@ -77,27 +75,6 @@
|
||||||
@tooltip "Memorijska komponenta, mora postojati barem jedna"
|
@tooltip "Memorijska komponenta, mora postojati barem jedna"
|
||||||
@count (1,1000)
|
@count (1,1000)
|
||||||
@source "memory.cdl"
|
@source "memory.cdl"
|
||||||
|
|
||||||
@attribute sinkroniziran bool default false {
|
|
||||||
@popup automatic {
|
|
||||||
@title "Postavite sinkroniziranost"
|
|
||||||
@text "Zadajte sinkronizaciju"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@attribute brzina int default 1 {
|
|
||||||
@popup automatic {
|
|
||||||
@title "Postavite brzinu memorije"
|
|
||||||
@text "Zadajte brzinu memorije"
|
|
||||||
@enumerated {
|
|
||||||
"Spora" = 1,
|
|
||||||
"Srednja" = 5,
|
|
||||||
"Brza" = 25,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@attribute kapacitet int default 65536 {
|
@attribute kapacitet int default 65536 {
|
||||||
@popup automatic {
|
@popup automatic {
|
||||||
@title "Kapacitet memorije"
|
@title "Kapacitet memorije"
|
||||||
|
@ -169,7 +146,7 @@
|
||||||
|
|
||||||
@pin glavniPin inOut {
|
@pin glavniPin inOut {
|
||||||
@tooltip "pin za spajanje na glavnu sabirnicu"
|
@tooltip "pin za spajanje na glavnu sabirnicu"
|
||||||
@connection required("COMDEL se ne može stvoriti. Memorija nije spojena na sabirnicu")
|
@connection check_only("COMDEL se ne može stvoriti. Memorija nije spojena na sabirnicu")
|
||||||
@display {
|
@display {
|
||||||
/*
|
/*
|
||||||
pin {
|
pin {
|
||||||
|
@ -194,7 +171,6 @@
|
||||||
@tooltip "DMA-kontroler"
|
@tooltip "DMA-kontroler"
|
||||||
@count (1,1000)
|
@count (1,1000)
|
||||||
@source "dma.cdl"
|
@source "dma.cdl"
|
||||||
|
|
||||||
@attribute pocetnaAdresa int default 0 {
|
@attribute pocetnaAdresa int default 0 {
|
||||||
@popup automatic {
|
@popup automatic {
|
||||||
@title "Početna adresa DMA-kontrolera"
|
@title "Početna adresa DMA-kontrolera"
|
||||||
|
@ -238,7 +214,7 @@
|
||||||
|
|
||||||
@pin glavniPin in {
|
@pin glavniPin in {
|
||||||
@tooltip "pin za spajanje na glavnu sabirnicu"
|
@tooltip "pin za spajanje na glavnu sabirnicu"
|
||||||
@connection required("COMDEL se ne može stvoriti. DMA nije spojena na sabirnicu")
|
@connection check_only("COMDEL se ne može stvoriti. DMA nije spojena na sabirnicu")
|
||||||
@display {
|
@display {
|
||||||
/*
|
/*
|
||||||
pin {
|
pin {
|
||||||
|
@ -259,7 +235,7 @@
|
||||||
|
|
||||||
@pin dodatnaPoveznica in {
|
@pin dodatnaPoveznica in {
|
||||||
@tooltip "pin za spajanje na pomocnu sabirnicu"
|
@tooltip "pin za spajanje na pomocnu sabirnicu"
|
||||||
@connection optional("COMDEL se ne može stvoriti. DMA nije spojen na nesto!")
|
@connection check_only("COMDEL se ne može stvoriti. DMA nije spojen na nesto!")
|
||||||
@display {
|
@display {
|
||||||
pin {
|
pin {
|
||||||
x: 0; y: 0; w: 0; h: 0;
|
x: 0; y: 0; w: 0; h: 0;
|
||||||
|
@ -297,9 +273,9 @@
|
||||||
INT2 wired_and,
|
INT2 wired_and,
|
||||||
INT3 wired_and,
|
INT3 wired_and,
|
||||||
SIZE<3>,
|
SIZE<3>,
|
||||||
IACK hidden,
|
IACK,
|
||||||
BREQ hidden,
|
BREQ,
|
||||||
BACK hidden
|
BACK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@bus PIOSabirnica automatic {
|
@bus PIOSabirnica automatic {
|
||||||
|
@ -309,14 +285,6 @@
|
||||||
STROBE
|
STROBE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@bus Test singleAutomatic {
|
|
||||||
@tooltip "sabirnica za spajanje FRISC a s memorijama i UI/jedinicama"
|
|
||||||
@count (1,1)
|
|
||||||
|
|
||||||
@wires {
|
|
||||||
CONNECTOR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@connection (FRISC.glavniPin, glavnaSabirnica) {
|
@connection (FRISC.glavniPin, glavnaSabirnica) {
|
||||||
@wires{ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, INT1, INT2, INT3, IACK, 1, null}
|
@wires{ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, INT1, INT2, INT3, IACK, 1, null}
|
||||||
|
@ -339,28 +307,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@wires{ADR, DATA, READ, WRITE, SIZE, WAIT, interupt, BREQ, BACK}
|
@wires{ADR, DATA, READ, WRITE, SIZE, WAIT, interupt, BREQ, BACK}
|
||||||
}
|
|
||||||
|
|
||||||
@connection (DMA.glavniPin, PIOSabirnica, FRISC.glavniPin) {
|
|
||||||
@wires{PIO_DATA, READY, STROBE}
|
|
||||||
@wires{PIO_DATA, READY, STROBE}
|
|
||||||
}
|
|
||||||
|
|
||||||
@connection (FRISC.glavniPin, Test, Memorija.glavniPin) {
|
|
||||||
@wires{null, "READY", null}
|
|
||||||
@wires{"PIO_DATA", null, null}
|
|
||||||
|
|
||||||
@attribute dmaPoveznica string default "" {
|
|
||||||
@popup automatic {
|
|
||||||
@title "Spoji DMA kraj"
|
|
||||||
@text "Odaberite poveznicu za dma kraja"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@attribute mmaPoveznica string default "" {
|
|
||||||
@popup automatic {
|
|
||||||
@title "Spoji MMA kraj"
|
|
||||||
@text "Odaberite poveznicu za mma kraja"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,13 +3,10 @@
|
||||||
@schema {
|
@schema {
|
||||||
@instance proc FRISC {
|
@instance proc FRISC {
|
||||||
@position (0, 0)
|
@position (0, 0)
|
||||||
@attribute _memory null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@instance mem Memorija {
|
@instance mem Memorija {
|
||||||
@position (0, 250)
|
@position (0, 250)
|
||||||
@attribute sinkroniziran false
|
|
||||||
@attribute brzina 1
|
|
||||||
@attribute kapacitet 1024
|
@attribute kapacitet 1024
|
||||||
@attribute size 8
|
@attribute size 8
|
||||||
@attribute pocetnaAdresa 1023
|
@attribute pocetnaAdresa 1023
|
||||||
|
@ -20,14 +17,39 @@
|
||||||
@size 100
|
@size 100
|
||||||
}
|
}
|
||||||
|
|
||||||
@instance testBus Test {}
|
@wire wire_001 {
|
||||||
|
@position (50, 116)
|
||||||
|
@display {
|
||||||
|
/*
|
||||||
|
line {
|
||||||
|
color: blue;
|
||||||
|
points: 100;
|
||||||
|
}*/
|
||||||
|
line {
|
||||||
|
x1: 0; y1: 0; x2: 0; y2: 84;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@connection (proc.glavniPin, bus) {}
|
@wire wire_002 {
|
||||||
|
@position (50, 220)
|
||||||
|
@display {
|
||||||
|
/*
|
||||||
|
line {
|
||||||
|
color: blue;
|
||||||
|
points: 100;
|
||||||
|
}*/
|
||||||
|
line {
|
||||||
|
x1: 0; y1: 0; x2: 0; y2: 14;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@connection (mem.glavniPin, bus) {}
|
@connection (proc.glavniPin, bus) {
|
||||||
|
@wire wire_001
|
||||||
|
}
|
||||||
|
|
||||||
@connection (proc.glavniPin, testBus, mem.glavniPin) {
|
@connection (mem.glavniPin, bus) {
|
||||||
@attribute dmaPoveznica "READY"
|
@wire wire_002
|
||||||
@attribute mmaPoveznica "PIO_DATA"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
@source "frisc_library.csl"
|
|
||||||
|
|
||||||
@schema {
|
|
||||||
@instance proc FRISC {
|
|
||||||
@position (0, 0)
|
|
||||||
@attribute _memory mem
|
|
||||||
}
|
|
||||||
|
|
||||||
@instance mem Memorija {
|
|
||||||
@position (0, 250)
|
|
||||||
@attribute sinkroniziran false
|
|
||||||
@attribute brzina 1
|
|
||||||
@attribute kapacitet 1024
|
|
||||||
@attribute size 8
|
|
||||||
@attribute pocetnaAdresa 1023
|
|
||||||
}
|
|
||||||
|
|
||||||
@instance bus glavnaSabirnica {
|
|
||||||
@position (0, 200)
|
|
||||||
@size 100
|
|
||||||
}
|
|
||||||
|
|
||||||
@instance testBus Test {
|
|
||||||
@position (0, 200)
|
|
||||||
@size 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@connection (proc.glavniPin, bus) {
|
|
||||||
}
|
|
||||||
@connection (mem.glavniPin, bus) {
|
|
||||||
}
|
|
||||||
@connection (proc.glavniPin, testBus, mem.glavniPin) {
|
|
||||||
@attribute dmaPoveznica "READY"
|
|
||||||
@attribute mmaPoveznica "PIO_DATA"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,26 +10,19 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <sstream>
|
||||||
#include <comdel/domain/comdelvalidator.h>
|
#include <comdel/domain/comdelvalidator.h>
|
||||||
#include <fstream>
|
|
||||||
#include <comdel/domain/comdel_generator.h>
|
|
||||||
|
|
||||||
std::optional<domain::Library> MainWindow::library;
|
|
||||||
domain::Schema* MainWindow::schema;
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
schema = nullptr;
|
|
||||||
library = std::nullopt;
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setupUi();
|
setupUi();
|
||||||
|
|
||||||
// define allowed methods
|
// define allowed methods
|
||||||
validators = domain::getSupportedValidators();
|
signatures = domain::getSupportedFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupUi()
|
void MainWindow::setupUi()
|
||||||
|
@ -42,8 +35,6 @@ void MainWindow::setupUi()
|
||||||
// setup toolbar
|
// setup toolbar
|
||||||
ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary);
|
ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary);
|
||||||
ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema);
|
ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema);
|
||||||
ui->toolBar->addAction("Save schema", this, &MainWindow::onStoreScheme);
|
|
||||||
ui->toolBar->addAction("Generate system", this, &MainWindow::onGenerateComdel);
|
|
||||||
|
|
||||||
connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema);
|
connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema);
|
||||||
|
|
||||||
|
@ -77,30 +68,28 @@ void MainWindow::onLoadLibrary() {
|
||||||
log->clear();
|
log->clear();
|
||||||
|
|
||||||
if(!filename.isEmpty()) {
|
if(!filename.isEmpty()) {
|
||||||
librarySource = filename.toStdString();
|
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
ParseContext parseContext;
|
ParseContext parseContext;
|
||||||
auto libraryNode = loadLibraryFromFile(&parseContext, filename.toStdString().c_str(), buffer);
|
auto libraryNode = loadLibraryFromFile(&parseContext, filename.toStdString().c_str(), buffer);
|
||||||
if(libraryNode) {
|
if(libraryNode) {
|
||||||
domain::SchemaCreator generator(validators);
|
domain::SchemaCreator generator(signatures);
|
||||||
library = generator.loadLibrary(*libraryNode);
|
library = generator.loadLibrary(*libraryNode);
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generator.getErrors().empty()) {
|
if(generator.getErrors().empty()) {
|
||||||
libraryDisplay->setLibrary(library);
|
libraryDisplay->setLibrary(library);
|
||||||
|
|
||||||
// on library load we create a new schema
|
// on library load we create a new schema
|
||||||
schema = new domain::Schema();
|
schema = domain::Schema();
|
||||||
schemaDisplay->setSchema(schema);
|
schemaDisplay->setSchema(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
buffer<<"Failed loading library"<<std::endl;
|
std::cout<<"Bad request"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,25 +111,19 @@ void MainWindow::onLoadSchema() {
|
||||||
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), buffer);
|
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), buffer);
|
||||||
|
|
||||||
if(schemaNode) {
|
if(schemaNode) {
|
||||||
domain::SchemaCreator generator(validators);
|
domain::SchemaCreator generator(signatures);
|
||||||
library = generator.loadLibrary(*schemaNode->library);
|
library = generator.loadLibrary(*schemaNode->library);
|
||||||
|
|
||||||
librarySource = schemaNode->source->value;
|
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(library) {
|
if(library) {
|
||||||
schema = generator.loadSchema(*schemaNode, *library);
|
schema = generator.loadSchema(*schemaNode, *library);
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
delete schema;
|
|
||||||
schema = nullptr;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
library = std::nullopt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generator.getErrors().empty()) {
|
if(generator.getErrors().empty()) {
|
||||||
|
@ -153,49 +136,21 @@ void MainWindow::onLoadSchema() {
|
||||||
log->appendPlainText(QString::fromStdString(buffer.str()));
|
log->appendPlainText(QString::fromStdString(buffer.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStoreScheme() {
|
|
||||||
if(schema == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(this,
|
|
||||||
tr("Save schema"), "/home", tr("Comdel schema (*.csl)"));
|
|
||||||
|
|
||||||
std::ostringstream buffer;
|
|
||||||
|
|
||||||
domain::generateSchemaFile(librarySource, schema, buffer);
|
|
||||||
|
|
||||||
std::ofstream out(filename.toStdString(), std::ios::out | std::ios::binary);
|
|
||||||
out<<buffer.str();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onGenerateComdel() {
|
|
||||||
if(schema == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(this,
|
|
||||||
tr("Save schema"), "/home", tr("Comdel system (*.system)"));
|
|
||||||
|
|
||||||
std::ostringstream buffer;
|
|
||||||
|
|
||||||
domain::generateComdelFile(schema, library.value(), buffer);
|
|
||||||
|
|
||||||
std::ofstream out(filename.toStdString(), std::ios::out | std::ios::binary);
|
|
||||||
out<<buffer.str();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::onValidateSchema(bool /*toggled*/) {
|
void MainWindow::onValidateSchema(bool /*toggled*/) {
|
||||||
if(schema == nullptr) {
|
if(!schema.has_value()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this->validationErrors.clear();
|
this->validationErrors.clear();
|
||||||
|
|
||||||
domain::ComdelValidator validator{validators};
|
std::map<std::string, domain::FunctionCallback> callbacks;
|
||||||
|
auto functions = domain::getSupportedFunctions();
|
||||||
|
for(auto &func: functions) {
|
||||||
|
callbacks[func.name] = func.callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
domain::ComdelValidator validator{callbacks};
|
||||||
|
|
||||||
domain::ValidationContext context;
|
domain::ValidationContext context;
|
||||||
context.instance = nullptr;
|
context.instance = nullptr;
|
||||||
|
@ -214,10 +169,10 @@ void MainWindow::onValidateSchema(bool /*toggled*/) {
|
||||||
std::ostringstream buff;
|
std::ostringstream buff;
|
||||||
|
|
||||||
for(auto err: errors) {
|
for(auto err: errors) {
|
||||||
if(err.instance != nullptr) {
|
if(err.instance != NULL) {
|
||||||
buff << err.instance->name;
|
buff << err.instance->name;
|
||||||
}
|
}
|
||||||
if(err.attribute != nullptr) {
|
if(err.attribute != NULL) {
|
||||||
buff << "::" << err.attribute->name;
|
buff << "::" << err.attribute->name;
|
||||||
}
|
}
|
||||||
if(err.type == domain::Action::ERROR) {
|
if(err.type == domain::Action::ERROR) {
|
||||||
|
@ -236,10 +191,7 @@ void MainWindow::onValidateSchema(bool /*toggled*/) {
|
||||||
|
|
||||||
void MainWindow::clear() {
|
void MainWindow::clear() {
|
||||||
validationErrors.clear();
|
validationErrors.clear();
|
||||||
if(schema != nullptr) {
|
schema = std::nullopt;
|
||||||
delete schema;
|
|
||||||
schema = nullptr;
|
|
||||||
}
|
|
||||||
library = std::nullopt;
|
library = std::nullopt;
|
||||||
|
|
||||||
libraryDisplay->setLibrary(library);
|
libraryDisplay->setLibrary(library);
|
||||||
|
@ -249,4 +201,4 @@ void MainWindow::clear() {
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
19
mainwindow.h
19
mainwindow.h
|
@ -27,35 +27,22 @@ public:
|
||||||
display::Library *libraryDisplay;
|
display::Library *libraryDisplay;
|
||||||
display::Schema *schemaDisplay;
|
display::Schema *schemaDisplay;
|
||||||
|
|
||||||
static std::optional<domain::Library> library;
|
std::optional<domain::Library> library = std::nullopt;
|
||||||
static domain::Schema* schema;
|
std::optional<domain::Schema> schema = std::nullopt;
|
||||||
|
|
||||||
std::vector<domain::FunctionValidator*> validators;
|
std::vector<domain::FunctionSignature> signatures;
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
static domain::Schema* getSchema() {
|
|
||||||
return schema;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::optional<domain::Library> getLibrary() {
|
|
||||||
return library;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onLoadLibrary();
|
void onLoadLibrary();
|
||||||
void onLoadSchema();
|
void onLoadSchema();
|
||||||
void onValidateSchema(bool toggled);
|
void onValidateSchema(bool toggled);
|
||||||
void onStoreScheme();
|
|
||||||
void onGenerateComdel();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string librarySource;
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QPlainTextEdit *log;
|
QPlainTextEdit *log;
|
||||||
std::vector<domain::ValidationError> validationErrors;
|
std::vector<domain::ValidationError> validationErrors;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // MAIN_WINDOW_H
|
#endif // MAIN_WINDOW_H
|
||||||
|
|
Loading…
Reference in New Issue