Commit 631550d9 authored by Maxime Perrotin's avatar Maxime Perrotin

Add testcase for NEWTYPE

parent 6f84af91
......@@ -264,7 +264,7 @@ end {pr}_Lib;'''.format(pr=process_name.lower(),
# Create a .gpr to build the Ada generated code
ada_gpr = '''project {pr}_Ada is
for Languages use ("Ada");
for Source_Dirs use ("code");
for Source_Dirs use (".");
for Object_Dir use "obj";
end {pr}_Ada;'''.format(pr=process_name.lower())
......
......@@ -1999,7 +1999,7 @@ end DataView_{lang};'''
template_makefile = '''all:
\tgprbuild -p -P {pr}.gpr # generate Ada code from the SDL model
\tgprbuild -p -P dataview_ada.gpr # generate Ada code from the ASN.1 model
\tgprbuild -p -P {pr}_ada.gpr # build the Ada code
\tgprbuild -p -P code/{pr}_ada.gpr # build the Ada code
clean:
\trm -rf obj code'''.format(pr=prj_name)
......
include ../shared.mk
ROOT_MODEL=og.pr
all: test-ada test-llvm
edit:
$(OPENGEODE) og.pr
test-parse:
$(OPENGEODE) og.pr --check
test-qgen-parse:
$(TESTQGEN_PARSE) $(ROOT_MODEL)
test-qgen-ada:
$(TESTQGEN_ADA) $(ROOT_MODEL)
test-qgen-c:
$(TESTQGEN_C) $(ROOT_MODEL)
test-qgen-gt-ada:
$(TESTQGEN_GT_ADA) $(ROOT_MODEL)
test-qgen-gt-c:
$(TESTQGEN_GT_C) $(ROOT_MODEL)
test-ada:
make -f Makefile.og
test-c:
$(OPENGEODE) og.pr --toC
mono $(ASN1SCC) -c -typePrefix asn1Scc -equal dataview-uniq.asn
$(CC) -O$(O) -c *.c
test-llvm:
$(OPENGEODE) og.pr --llvm -O$(O)
$(LLC) *.ll
$(CC) -O$(O) -c *.s
coverage:
coverage run -p $(OPENGEODE) og.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
all:
gprbuild -p -P og.gpr # generate Ada code from the SDL model
gprbuild -p -P dataview_ada.gpr # generate Ada code from the ASN.1 model
gprbuild -p -P code/og_ada.gpr # build the Ada code
clean:
rm -rf obj code
\ No newline at end of file
TASTE-Dataview DEFINITIONS ::=
BEGIN
MyInteger ::= INTEGER (0..255)
SeqOf ::= SEQUENCE (SIZE(0..100)) OF MyInteger
END
#!/usr/bin/env python
# ASN.1 Data model
asn1Files = []
asn1Modules = []
exportedTypes = {}
exportedVariables = {}
importedModules = {}
types = {}
variables = {}
asn1Files.append("dataview-uniq.asn")
asn1Modules.append("TASTE-Dataview")
exportedTypes["TASTE-Dataview"] = ["MyInteger", "SeqOf"]
exportedVariables["TASTE-Dataview"] = []
importedModules["TASTE-Dataview"] = []
types["MyInteger"] = type("MyInteger", (object,), {
"Line": 4, "CharPositionInLine": 14, "type": type("MyInteger_type", (object,), {
"Line": 4, "CharPositionInLine": 14, "kind": "IntegerType", "Min": "0", "Max": "255"
})
})
types["SeqOf"] = type("SeqOf", (object,), {
"Line": 5, "CharPositionInLine": 14, "type": type("SeqOf_type", (object,), {
"Line": 5, "CharPositionInLine": 14, "kind": "SequenceOfType", "Min": "0", "Max": "100", "type": type("SeqOf_type", (object,), {
"Line": 5, "CharPositionInLine": 41, "kind": "ReferenceType", "ReferencedTypeName": "MyInteger", "Min": "0", "Max": "255"
})
})
})
system og;
/* CIF TEXT (228, 136), (391, 216) */
-- demonstrating how to create custom types with the newtype
-- sdl construct
use dv comment 'dataview-uniq.asn';
signal dd;
signal we;
/* CIF ENDTEXT */
channel c
from env to og with dd;
from og to env with we;
endchannel;
block og;
signalroute r
from env to og with dd;
from og to env with we;
connect c and r;
/* CIF PROCESS (225, 49), (150, 75) */
process og;
/* CIF TEXT (121, 80), (342, 114) */
newtype MyArray
array (myinteger, myinteger)
endnewtype;
dcl x MyArray := { 1,2,3 };
/* CIF ENDTEXT */
/* CIF START (155, 216), (70, 35) */
START;
/* CIF NEXTSTATE (155, 266), (70, 35) */
NEXTSTATE wait;
/* CIF state (296, 231), (70, 35) */
state wait;
/* CIF input (289, 286), (84, 35) */
input dd;
/* CIF NEXTSTATE (296, 336), (70, 35) */
NEXTSTATE wait;
endstate;
endprocess og;
endblock;
endsystem;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment