Commit 4d4e6027 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test case for procedure calls

parent efd04650
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
export ASN1SCC=$(shell which asn1.exe)
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/titi_ada.gpr # build the Ada code
clean:
rm -rf obj code
\ No newline at end of file
TASTE-Dataview DEFINITIONS ::=
BEGIN
MyChoice ::= CHOICE {
a CHOICE {
b CHOICE {
c BOOLEAN,
d BOOLEAN
},
e BOOLEAN
},
f BOOLEAN
}
Some-Thing ::= MyInteger
MyInteger ::= INTEGER (0..255)
My-OctStr ::= OCTET STRING (SIZE (0..20))
SeqOf ::= SEQUENCE (SIZE(0..100)) OF MyInteger
Type1 ::= INTEGER(0..1)
Type2 ::= BOOLEAN
Toto ::= SEQUENCE { elem-1 Type1, elem-2 Type2 }
SeqBool ::= SEQUENCE(SIZE(1..5)) OF BOOLEAN
Enum-T ::= ENUMERATED {enum1}
default-seqof SeqOf ::= {4,7,9}
default-str My-OctStr ::= 'DEADBEEF'H
END
DV DEFINITIONS ::=
BEGIN
Temperature ::= REAL (0.0 .. 10.0)
Temperature-Difference ::= Temperature (-100.0 .. 100.0)
SomeInt ::= INTEGER (-100..200)
low SomeInt ::= 5
high SomeInt ::= 10
END
project DataView_Ada is
for Languages use ("ASN1");
for Source_Dirs use (".");
for Source_Files use ("dataview.asn");
for Object_Dir use "code";
package Naming is
for Body_Suffix ("ASN1") use ".asn";
end Naming;
package Compiler is
for Driver ("ASN1") use "mono";
for Leading_Required_Switches ("ASN1") use
(external("ASN1SCC"),
"-Ada",
"-typePrefix",
"Asn1Scc");
end Compiler;
end DataView_Ada;
\ No newline at end of file
project DataView_c is
for Languages use ("ASN1");
for Source_Dirs use (".");
for Source_Files use ("dataview.asn");
for Object_Dir use "code";
package Naming is
for Body_Suffix ("ASN1") use ".asn";
end Naming;
package Compiler is
for Driver ("ASN1") use "mono";
for Leading_Required_Switches ("ASN1") use
(external("ASN1SCC"),
"-c",
"-typePrefix",
"Asn1Scc");
end Compiler;
end DataView_c;
\ No newline at end of file
project og is
for Languages use ("SDL");
for Source_Dirs use (".");
for Object_Dir use "code";
for Source_Files use ("og.pr");
package Naming is
for Body_Suffix ("SDL") use ".pr";
end Naming;
package Compiler is
for Driver ("SDL") use "opengeode";
for Object_File_Suffix ("SDL") use ".adb";
for Leading_Required_Switches ("SDL") use ("--toAda");
end Compiler;
end og;
\ No newline at end of file
system titi;
/* CIF TEXT (394, 92), (271, 305) */
use dv comment 'dataview.asn';
signal a;
/* CIF ENDTEXT */
channel c
from env to titi with a;
endchannel;
block titi;
signalroute r
from env to titi with a;
connect c and r;
/* CIF PROCESS (215, 147), (150, 75) */
process titi;
/* CIF TEXT (236, 81), (391, 297) */
-- Check procedure calls with/without return or parameters
dcl one, two Temperature := 2.0;
dcl diff Temperature_Difference;
dcl u SomeInt;
/* CIF ENDTEXT */
/* CIF procedure (347, 552), (117, 35) */
procedure procWithReturn;
/* CIF TEXT (142, 194), (267, 140) */
-- Text area for declarations and comments
fpar in t Temperature;
returns Temperature;
/* CIF ENDTEXT */
/* CIF START (854, 137), (70, 35) */
START;
/* CIF return (871, 192), (35, 35) */
return 5.0;
endprocedure;
/* CIF procedure (353, 505), (107, 35) */
procedure procNoReturn;
/* CIF START (117, 52), (70, 35) */
START;
/* CIF return (134, 107), (35, 35) */
return ;
endprocedure;
/* CIF procedure (343, 620), (171, 35) */
procedure procNoParamsButReturn;
/* CIF TEXT (103, 121), (267, 137) */
returns Temperature;
/* CIF ENDTEXT */
/* CIF START (639, 218), (70, 35) */
START;
/* CIF return (656, 273), (35, 35) */
return 5.0;
endprocedure;
/* CIF START (669, 229), (70, 35) */
START;
/* CIF task (642, 284), (124, 35) */
task diff := two - one;
/* CIF PROCEDURECALL (653, 339), (101, 35) */
call procnoreturn;
/* CIF task (613, 394), (181, 40) */
task one := procwithreturn(1.1);
/* CIF task (579, 454), (250, 35) */
task one := call procNoParamsButReturn;
/* CIF decision (669, 509), (70, 50) */
decision u;
/* CIF ANSWER (579, 579), (70, 24) */
(< low):
/* CIF ANSWER (669, 579), (70, 24) */
(> high):
/* CIF ANSWER (759, 579), (70, 24) */
else:
enddecision;
/* CIF NEXTSTATE (669, 619), (70, 35) */
NEXTSTATE wait;
/* CIF state (947, 254), (70, 35) */
state wait;
endstate;
endprocess titi;
endblock;
endsystem;
\ No newline at end of file
Supports Markdown
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