Commit 3ee16c41 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Return error code when Ada code generation fails

parent d370faca
......@@ -2694,11 +2694,13 @@ def parse(files):
def generate(process, options):
''' Generate code '''
ret = 0
if options.toAda or options.shared or options.dll:
LOG.info('Generating Ada code')
try:
AdaGenerator.generate(process, simu=options.shared)
except (TypeError, ValueError, NameError) as err:
ret = 1
LOG.error(str(err))
LOG.debug(str(traceback.format_exc()))
LOG.error('Ada code generation failed')
......@@ -2707,6 +2709,7 @@ def generate(process, options):
try:
CGenerator.generate(process, simu=options.shared, options=options)
except (TypeError, ValueError, NameError) as err:
ret = 1
LOG.error(str(err))
LOG.debug(str(traceback.format_exc()))
LOG.error('C generation failed')
......@@ -2715,6 +2718,7 @@ def generate(process, options):
try:
LlvmGenerator.generate(process, options=options)
except (TypeError, ValueError, NameError) as err:
ret = 1
LOG.error(str(err))
LOG.debug(str(traceback.format_exc()))
LOG.error('LLVM IR generation failed')
......@@ -2722,6 +2726,7 @@ def generate(process, options):
if options.stg:
LOG.info('Using backend file {}'.format(options.stg))
StgBackend.generate(process, simu=options.shared, stgfile=options.stg)
return ret
def export(ast, options):
......@@ -2806,7 +2811,7 @@ def cli(options):
if any((options.toAda, options.llvm, options.shared,
options.stg, options.dll, options.toC)):
if not errors:
generate(ast.processes[0], options)
errors = generate(ast.processes[0], options)
else:
LOG.error('Too many errors, cannot generate code')
......
......@@ -23,8 +23,8 @@ clean:
mono $(ASN1SCC) -c -typePrefix asn1Scc -equal dataview-uniq.asn
%.ali: %.pr FORCE
$(OPENGEODE) $< system_structure.pr --toAda
mono $(ASN1SCC) -Ada -typePrefix asn1Scc -equal dataview-uniq.asn
$(OPENGEODE) $< system_structure.pr --toAda && \
mono $(ASN1SCC) -Ada -typePrefix asn1Scc -equal dataview-uniq.asn && \
$(GNATMAKE) -O$(O) -gnat2012 -c -g -fprofile-arcs -ftest-coverage *.adb
%.o: %.asn FORCE
......
/* CIF PROCESS (150, 150), (150, 75) */
PROCESS orchestrator;
/* CIF TEXT (1110, -703), (319, 392) */
-- Some test data
DCL a MyInteger;
DCL b MySeqOf;
DCL c MySeq;
DCL e, g MyChoice;
DCL f MyEnum;
DCL h MyReal;
DCL i MyPossiblyEmptySeqOf;
DCL j MyComplexType;
DCL k MyComplexSeqOf;
DCL l MyComplexChoice;
DCL myCmd MyInteger;
dcl deep DeepSeq;
/* CIF ENDTEXT */
/* CIF TEXT (-939, -690), (366, 195) */
-- This demo shows the main features
-- and syntax currently supported by
-- OpenGEODE
-- The description of the signal and
-- external procedures is in the file called
-- "system_structure.pr".
-- To open this model you must load both
-- files from the command line:
-- $ opengeode system_structure.pr orchestrator.pr
/* CIF ENDTEXT */
/* CIF TEXT (-925, -483), (276, 283) */
-- You can manually declare an
-- external procedure:
-- procedure tototo;
-- fpar titi MyInteger;
-- external;
-- In that case you are responsible for
-- providing the body code.
-- toto is used to check that
-- the FPAR in myproc that also
-- has a param called toto does
-- not conflict.
dcl toto MySeqOf;
/* CIF ENDTEXT */
/* CIF PROCEDURE (-849, -181), (91, 50) */
PROCEDURE myproc;
/* CIF TEXT (339, -68), (197, 140) */
-- A Local variable
DCL foo MyInteger;
-- Procedure interface
fpar
in toto MyInteger,
in/out tutu MyInteger;
/* CIF ENDTEXT */
/* CIF START (617, -49), (100, 50) */
START;
/* CIF TASK (617, 16), (100, 50) */
TASK a := 42;
/* CIF DECISION (617, 81), (100, 70) */
DECISION toto;
/* CIF ANSWER (557, 171), (100, 35) */
(<10):
/* CIF TASK (544, 221), (126, 50) */
TASK tutu := 128;
/* CIF ANSWER (683, 171), (100, 35) */
ELSE:
/* CIF TASK (678, 221), (110, 50) */
TASK tutu := 254;
ENDDECISION;
/* CIF TASK (617, 286), (100, 50) */
TASK foo := a;
/* CIF RETURN (642, 351), (50, 50) */
RETURN ;
ENDPROCEDURE;
/* CIF START (612, -699), (100, 50) */
START;
/* CIF TASK (467, -629), (389, 458) */
TASK a := 42 + 5 * 3 - 1,
/* CIF PROCESS (148, 150), (150, 75) */
process orchestrator;
/* CIF TEXT (2022, 238), (276, 283) */
-- You can manually declare an
-- external procedure:
-- procedure tototo;
-- fpar titi MyInteger;
-- external;
-- In that case you are responsible for
-- providing the body code.
-- toto is used to check that
-- the FPAR in myproc that also
-- has a param called toto does
-- not conflict.
dcl toto MySeqOf;
/* CIF ENDTEXT */
/* CIF TEXT (1974, 690), (366, 195) */
-- This demo shows the main features
-- and syntax currently supported by
-- OpenGEODE
-- The description of the signal and
-- external procedures is in the file called
-- "system_structure.pr".
-- To open this model you must load both
-- files from the command line:
-- $ opengeode system_structure.pr orchestrator.pr
/* CIF ENDTEXT */
/* CIF TEXT (2350, 703), (319, 392) */
-- Some test data
DCL a MyInteger;
DCL b MySeqOf;
DCL c MySeq;
DCL e, g MyChoice;
DCL f MyEnum;
DCL h MyReal;
DCL i MyPossiblyEmptySeqOf;
DCL j MyComplexType;
DCL k MyComplexSeqOf;
DCL l MyComplexChoice;
DCL myCmd MyInteger;
dcl deep DeepSeq;
/* CIF ENDTEXT */
/* CIF procedure (1397, 181), (91, 50) */
procedure myproc;
/* CIF TEXT (339, 68), (197, 140) */
-- A Local variable
DCL foo MyInteger;
-- Procedure interface
fpar
in toto MyInteger,
in/out tutu MyInteger;
/* CIF ENDTEXT */
/* CIF START (617, 49), (100, 50) */
START;
/* CIF task (617, 114), (100, 50) */
task a := 42;
/* CIF decision (617, 179), (100, 70) */
decision toto;
/* CIF ANSWER (557, 269), (100, 35) */
(<10):
/* CIF task (544, 319), (126, 50) */
task tutu := 128;
/* CIF ANSWER (683, 269), (100, 35) */
ELSE:
/* CIF task (678, 319), (110, 50) */
task tutu := 254;
enddecision;
/* CIF task (617, 384), (100, 50) */
task foo := a;
/* CIF return (642, 449), (50, 50) */
return ;
endprocedure;
/* CIF START (1374, 507), (100, 50) */
START;
/* CIF task (1229, 572), (389, 458) */
task a := 42 + 5 * 3 - 1,
b := { hello, world },
a := length(b),
c := {a 5, b taste},
......@@ -118,119 +118,115 @@ deep!a := { b { c 4, d e:TRUE } },
-- deep!a!b!d!e := FALSE
-- Use the following syntax instead:
deep!a!b!d := e:FALSE
/* CIF COMMENT (882, -409), (190, 68) */
COMMENT 'This is a multiline
/* CIF comment (1740, 758), (190, 68) */
comment 'This is a multiline
comment - should
we reflected as so
in the generated code';
/* CIF DECISION (606, -156), (112, 70) */
DECISION present(e);
/* CIF ANSWER (543, -66), (45, 35) */
(a):
/* CIF TASK (528, -16), (75, 50) */
TASK a := 37;
/* CIF ANSWER (639, -65), (46, 35) */
(b):
/* CIF TASK (624, -15), (75, 50) */
TASK a := 38;
/* CIF ANSWER (704, -66), (69, 35) */
ELSE:
ENDDECISION;
/* CIF DECISION (612, 50), (100, 70) */
DECISION e;
/* CIF ANSWER (612, 140), (100, 35) */
(a:TRUE):
/* CIF TASK (612, 195), (100, 50) */
TASK a := 41;
/* CIF ANSWER (492, 140), (100, 35) */
(g):
/* CIF TASK (492, 195), (100, 50) */
TASK a := 40;
/* CIF ANSWER (732, 140), (100, 35) */
ELSE:
/* CIF TASK (732, 195), (100, 50) */
TASK a := 42;
ENDDECISION;
/* CIF NEXTSTATE (615, 260), (94, 38) */
NEXTSTATE Stopped;
/* CIF LABEL (-454, -215), (153, 73) */
CONNECTION Transition_to_Stop:
/* CIF PROCEDURECALL (-560, -127), (365, 50) */
CALL writeln
/* CIF decision (1368, 1045), (112, 70) */
decision present(e);
/* CIF ANSWER (1305, 1135), (45, 35) */
(a):
/* CIF task (1290, 1185), (75, 50) */
task a := 37;
/* CIF ANSWER (1401, 1135), (46, 35) */
(b):
/* CIF task (1386, 1185), (75, 50) */
task a := 38;
/* CIF ANSWER (1466, 1135), (69, 35) */
ELSE:
enddecision;
/* CIF decision (1374, 1250), (100, 70) */
decision e;
/* CIF ANSWER (1374, 1340), (100, 35) */
(a:TRUE):
/* CIF task (1374, 1390), (100, 50) */
task a := 41;
/* CIF ANSWER (1254, 1340), (100, 35) */
(g):
/* CIF task (1254, 1390), (100, 50) */
task a := 40;
/* CIF ANSWER (1494, 1340), (100, 35) */
ELSE:
/* CIF task (1494, 1390), (100, 50) */
task a := 42;
enddecision;
/* CIF NEXTSTATE (1377, 1455), (94, 38) */
NEXTSTATE Stopped;
/* CIF label (1002, 215), (153, 73) */
connection Transition_to_Stop:
/* CIF PROCEDURECALL (896, 303), (365, 50) */
call writeln
('Floating label: Transition to stop (Sending HK 31)');
/* CIF OUTPUT (-454, -62), (153, 50) */
OUTPUT housekeeping(31);
/* CIF NEXTSTATE (-428, 3), (100, 50) */
NEXTSTATE Stopped;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (272, -613), (100, 50) */
STATE Running;
/* CIF INPUT (272, -543), (100, 50) */
INPUT pulse;
/* CIF TASK (225, -478), (193, 50) */
TASK a := (a+1) mod 10;
/* CIF PROCEDURECALL (256, -413), (132, 50) */
CALL writeln
('Calling GNC');
/* CIF PROCEDURECALL (243, -348), (158, 50) */
CALL computeGNC(a, a);
/* CIF OUTPUT (248, -283), (148, 50) */
OUTPUT housekeeping(a);
/* CIF NEXTSTATE (272, -218), (100, 50) */
NEXTSTATE Running;
ENDSTATE;
/* CIF STATE (-8, -89), (100, 50) */
STATE Running;
/* CIF INPUT (-19, -19), (120, 50) */
INPUT run(myCmd);
/* CIF PROCEDURECALL (-79, 46), (240, 50) */
CALL writeln
/* CIF output (1002, 368), (153, 50) */
output housekeeping(31);
/* CIF NEXTSTATE (1028, 433), (100, 50) */
NEXTSTATE Stopped;
/* CIF End Label */
endconnection;
/* CIF state (119, 1283), (100, 50) */
state Running;
/* CIF input (130, 1353), (120, 50) */
input run(myCmd);
/* CIF PROCEDURECALL (70, 1418), (240, 50) */
call writeln
('Already running! So stopping');
/* CIF JOIN (16, 111), (50, 50) */
JOIN Transition_to_Stop;
ENDSTATE;
/* CIF STATE (-236, -686), (100, 50) */
STATE Stopped;
/* CIF INPUT (-8, -616), (100, 50) */
INPUT run(a)
/* CIF COMMENT (-36, -685), (167, 50) */
/* CIF Keep Specific Geode HyperLink 'http://www.esa.int' */
COMMENT 'My comment is rich';
/* CIF LABEL (-8, -551), (100, 50) */
Here:
/* CIF DECISION (-8, -486), (100, 70) */
DECISION a>10;
/* CIF ANSWER (-94, -396), (100, 35) */
(TRUE):
/* CIF PROCEDURECALL (-189, -346), (290, 47) */
CALL writeln
/* CIF join (165, 1483), (50, 50) */
join Transition_to_Stop;
endstate;
/* CIF state (429, 686), (100, 50) */
state Stopped;
/* CIF input (119, 756), (100, 50) */
input run(a)
/* CIF comment (306, 774), (167, 50) */
/* CIF Keep Specific Geode HyperLink 'http://www.esa.int' */
comment 'My comment is rich';
/* CIF label (119, 821), (100, 50) */
Here:
/* CIF decision (119, 886), (100, 70) */
decision a>10;
/* CIF ANSWER (95, 976), (100, 35) */
(TRUE):
/* CIF PROCEDURECALL (0, 1026), (290, 47) */
call writeln
('a is too big! - decrementing :', a, a - 1);
/* CIF TASK (-111, -284), (135, 50) */
TASK a := (a - 1) mod 1;
/* CIF PROCEDURECALL (-102, -219), (116, 50) */
CALL myproc(5,a);
/* CIF JOIN (-69, -154), (50, 50) */
JOIN Here;
/* CIF ANSWER (110, -395), (100, 35) */
(FALSE):
ENDDECISION;
/* CIF NEXTSTATE (-8, -89), (100, 50) */
NEXTSTATE Running;
/* CIF INPUT (-537, -616), (100, 50) */
INPUT *
/* CIF COMMENT (-417, -616), (218, 50) */
COMMENT 'All signals not explicitely
/* CIF task (77, 1088), (135, 50) */
task a := (a - 1) mod 1;
/* CIF PROCEDURECALL (87, 1153), (116, 50) */
call myproc(5,a);
/* CIF join (120, 1218), (50, 50) */
join Here;
/* CIF ANSWER (300, 976), (100, 35) */
(FALSE):
enddecision;
/* CIF NEXTSTATE (119, 1283), (100, 50) */
NEXTSTATE Running;
/* CIF input (603, 765), (100, 50) */
input *
/* CIF comment (743, 768), (218, 50) */
comment 'All signals not explicitely
processed. Must be "pulse"';
/* CIF OUTPUT (-567, -551), (161, 50) */
OUTPUT housekeeping (1);
/* CIF NEXTSTATE (-532, -486), (91, 46) */
NEXTSTATE -
/* CIF COMMENT (-421, -488), (185, 50) */
COMMENT 'Stay in the same state';
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
/* CIF output (572, 830), (161, 50) */
output housekeeping (1);
/* CIF NEXTSTATE (607, 895), (91, 46) */
NEXTSTATE -
/* CIF comment (562, 970), (185, 50) */
comment 'Stay in the same state';
endstate;
/* CIF state (1073, 613), (100, 50) */
state Running;
/* CIF input (1073, 683), (100, 50) */
input pulse;
/* CIF task (1026, 748), (193, 50) */
task a := (a+1) mod 10;
/* CIF PROCEDURECALL (1057, 813), (132, 50) */
call writeln
('Calling GNC');
/* CIF PROCEDURECALL (1044, 878), (158, 50) */
call computeGNC(a, a);
/* CIF output (1049, 943), (148, 50) */
output housekeeping(a);
/* CIF NEXTSTATE (1073, 1008), (100, 50) */
NEXTSTATE Running;
endstate;
endprocess orchestrator;
\ 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