Commit a33a2d07 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Remove debug prints

parent 012cb298
......@@ -935,6 +935,13 @@ def compare_types(type_a, type_b): # type -> [warnings]
# TODO: Check that OctetString types have compatible range
elif type_a.kind == 'SequenceType' and mismatch:
raise TypeError(mismatch)
elif type_a.kind == 'IntegerType' and mismatch:
# Detect Signed/Unsigned type mismatch
min_a, min_b = float(type_a.Min), float(type_b.Min)
if (min_a >= 0) != (min_b >= 0):
raise TypeError(mismatch + "(signed vs unsigned type)")
else:
warnings.append(mismatch)
elif mismatch:
warnings.append(mismatch)
#print traceback.print_stack()
......@@ -1059,12 +1066,13 @@ def fix_expression_types(expr, context): # type: -> [warnings]
# we must fix missing inner types
# (due to similarities, the following should be refactored FIXME)
if isinstance(expr.right, ogAST.PrimSequence):
#print "Left:", type_name(expr.left.exprType), "Right:", expr.right.inputString
# left side must have a known type
asn_type = find_basic_type(expr.left.exprType)
if asn_type.kind != 'SequenceType':
raise TypeError('left side must be a SEQUENCE type')
for field, fd_expr in expr.right.value.viewitems():
if fd_expr.exprType == UNKNOWN_TYPE:
# if fd_expr.exprType == UNKNOWN_TYPE:
try:
expected_type = asn_type.Children.get(
field.replace('_', '-')).type
......@@ -1098,6 +1106,7 @@ def fix_expression_types(expr, context): # type: -> [warnings]
warnings.extend(fix_expression_types(check_expr, context))
expr.right.value['value'] = check_expr.right
elif isinstance(expr.right, ogAST.PrimConditional):
#print "[Parser] [Conditional] ", expr.right.inputString
for det in ('then', 'else'):
# Recursively fix possibly missing types in the expression
check_expr = ogAST.ExprAssign()
......@@ -1108,8 +1117,8 @@ def fix_expression_types(expr, context): # type: -> [warnings]
expr.right.value[det] = check_expr.right
# Set the type of "then" and "else" to the reference type:
expr.right.value[det].exprType = expr.left.exprType
# We must also set the type of the overal expression to the same
expr.right.exprType = expr.left.exprType
# We must also set the type of the overal expression to the same
expr.right.exprType = expr.left.exprType
if expr.right.is_raw != expr.left.is_raw:
warnings.extend(check_type_compatibility(raw_expr, ref_type, context))
......@@ -1566,6 +1575,9 @@ def conditional_expression(root, context):
errors.append(error(root, msg))
# TODO: Refactor this
# The type of the expression is set to the type of the "then" part,
# but this is not always right, in the case of raw numbers ("then" part
# may be unsigned, while the real expected type is signed)
try:
expr.left = then_expr
expr.right = else_expr
......@@ -1577,9 +1589,9 @@ def conditional_expression(root, context):
errors.append(error(root, str(err)))
expr.value = {
'if': if_expr,
'then': then_expr,
'else': else_expr,
'if' : if_expr,
'then' : then_expr,
'else' : else_expr,
'tmpVar': expr.tmpVar
}
return expr, errors, warnings
......
......@@ -6,18 +6,13 @@ edit:
$(OPENGEODE) orchestrator.pr system_structure.pr
test-parse:
$(OPENGEODE) orchestrator.pr system_structure.pr --check
test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATBIND) -n orchestrator.ali
$(GNATLINK) -o test_ada test_ada.o orchestrator.ali -lgnat
./test_ada
#gcov orchestrator.adb
test-c: orchestrator.c test_c.o dataview-uniq.o
$(CC) orchestrator.c -c -o orchestrator.o
$(CC) test_c.o orchestrator.c dataview-uniq.o -lm -o test_c
./test_c
$(OPENGEODE) orchestrator.pr system_structure.pr --check || echo [OK]
test-ada:
$(OPENGEODE) orchestrator.pr system_structure.pr --check || echo [OK]
test-c:
$(OPENGEODE) orchestrator.pr system_structure.pr --check &&
test-llvm: orchestrator.o
......
This test should fail before generating code, due to a type mismatch (signed/unsigned integer mix)
/* CIF PROCESS (250, 149), (150, 75) */
PROCESS orchestrator;
/* CIF TEXT (81, 252), (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;
process orchestrator;
/* CIF TEXT (317, 19), (255, 143) */
-- MyInteger is a signed integer
DCL a MyInteger := 4;
DCL e MyChoice;
DCL j MyComplexType;
/* CIF ENDTEXT */
/* CIF TEXT (59, 8), (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 (437, 19), (319, 382) */
-- Some test data
DCL a MyInteger := 4;
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 m MyChoice2;
/* CIF ENDTEXT */
/* CIF PROCEDURE (146, 614), (91, 50) */
PROCEDURE myproc;
/* CIF TEXT (409, 0), (197, 140) */
-- A Local variable
DCL foo MyInteger;
-- Procedure interface
fpar
in toto MyInteger,
in/out tutu MyInteger;
/* CIF ENDTEXT */
/* CIF START (617, 19), (100, 50) */
START;
/* CIF TASK (617, 84), (100, 50) */
TASK a := 42;
/* CIF DECISION (617, 149), (100, 70) */
DECISION toto;
/* CIF ANSWER (422, 239), (100, 35) */
(<10):
/* CIF TASK (409, 289), (126, 50) */
TASK tutu := 128;
/* CIF ANSWER (548, 239), (100, 35) */
ELSE:
/* CIF TASK (543, 289), (110, 50) */
TASK tutu := 254;
ENDDECISION;
/* CIF TASK (617, 354), (100, 50) */
TASK foo := a;
/* CIF RETURN (642, 419), (50, 50) */
RETURN ;
ENDPROCEDURE;
/* CIF START (953, 3), (100, 50) */
/* CIF START (697, 142), (69, 32) */
START;
/* CIF TASK (796, 73), (413, 368) */
TASK a := 42 + 5 * 3 - 1,
b := { hello, world },
a := length(b),
c := {a 5, b taste},
f := hello,
g := b:{a 33, b you},
e:=g,
e := a:TRUE,
b(1) := hello,
--h := {mantissa 1, base 2, exponent 5},
h := -42.5,
i := {},
i := { 1 },
a := length(i),
a := if e!a then 8 else if b(0) = hello then a else 9 fi fi,
j := { a { x if e!a then 5 else a fi, y 6 } },
k := { {x 4}, {x 5} },
l := a:{ x 5 },
a := if present(e)=b then 42 else 43 fi,
a := abs(-5),
h := abs(-42.5),
h := abs(h),
i := {1, 2},
m := B:C:TRUE
/* CIF COMMENT (1273, 237), (158, 40) */
COMMENT 'This is a comment
A multiline one, I mean';
/* CIF TASK (939, 456), (128, 53) */
TASK for x in i:
call writeln(x);
endfor;
/* CIF PROCEDURECALL (875, 524), (255, 50) */
CALL writeln('Should show "5 42.5": ', a, h);
/* CIF DECISION (947, 589), (112, 70) */
DECISION present(e);
/* CIF ANSWER (953, 679), (100, 31) */
(a):
/* CIF TASK (949, 729), (108, 50) */
TASK a := 37;
/* CIF ANSWER (1106, 679), (100, 35) */
(b):
/* CIF TASK (1066, 729), (179, 50) */
TASK a := 38;
/* CIF ANSWER (1256, 679), (100, 35) */
ELSE:
ENDDECISION;
/* CIF DECISION (953, 794), (100, 70) */
DECISION e;
/* CIF ANSWER (840, 884), (100, 35) */
(a:TRUE):
/* CIF TASK (840, 939), (100, 50) */
TASK a := 41;
/* CIF ANSWER (646, 884), (100, 35) */
(g):
/* CIF TASK (646, 939), (100, 50) */
TASK a := 40;
/* CIF ANSWER (1077, 884), (100, 35) */
ELSE:
/* CIF TASK (1077, 939), (100, 50) */
TASK a := 42;
ENDDECISION;
/* CIF NEXTSTATE (956, 1004), (94, 38) */
NEXTSTATE Stopped;
/* CIF LABEL (452, 491), (152, 50) */
CONNECTION Transition_to_Stop:
/* CIF OUTPUT (451, 556), (153, 50) */
OUTPUT housekeeping(31);
/* CIF NEXTSTATE (478, 621), (100, 50) */
/* CIF task (610, 189), (243, 41) */
task j := { a { x if e!a then 5 else a fi, y 6 } };
/* CIF NEXTSTATE (695, 246), (74, 34) */
NEXTSTATE Stopped;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (2396, 617), (100, 50) */
STATE Running;
/* CIF INPUT (2386, 687), (120, 50) */
INPUT run(myCmd);
/* CIF OUTPUT (2363, 752), (165, 50) */
OUTPUT housekeeping(42);
/* CIF JOIN (2421, 817), (50, 50) */
JOIN Transition_to_Stop;
ENDSTATE;
/* CIF STATE (2064, 20), (100, 50) */
STATE Stopped;
/* CIF INPUT (2396, 90), (100, 50) */
INPUT run(a)
/* CIF COMMENT (2368, 21), (167, 50) */
/* CIF Keep Specific Geode HyperLink 'http://www.esa.int' */
COMMENT 'My comment is rich';
/* CIF LABEL (2396, 155), (100, 50) */
Here:
/* CIF DECISION (2396, 220), (100, 70) */
DECISION a>10;
/* CIF ANSWER (2304, 310), (100, 35) */
(TRUE):
/* CIF PROCEDURECALL (2209, 360), (290, 47) */
CALL writeln
('a is too big! - decrementing :', a, a - 1);
/* CIF TASK (2298, 422), (112, 50) */
TASK a := a - 1;
/* CIF PROCEDURECALL (2296, 487), (116, 50) */
CALL myproc(5,a);
/* CIF JOIN (2329, 552), (50, 50) */
JOIN Here;
/* CIF ANSWER (2509, 310), (100, 35) */
(FALSE):
ENDDECISION;
/* CIF NEXTSTATE (2396, 617), (100, 50) */
NEXTSTATE Running;
/* CIF INPUT (1746, 90), (100, 50) */
INPUT pulse;
/* CIF OUTPUT (1715, 155), (161, 50) */
OUTPUT housekeeping (1);
/* CIF NEXTSTATE (1750, 220), (91, 46) */
NEXTSTATE -
/* CIF COMMENT (1909, 213), (153, 50) */
COMMENT 'Stay in the same state';
ENDSTATE;
/* CIF STATE (1503, 29), (100, 50) */
STATE Running;
/* CIF INPUT (1503, 99), (100, 50) */
INPUT pulse;
/* CIF TASK (1456, 164), (193, 50) */
TASK a := (a+1) mod 10;
/* CIF PROCEDURECALL (1450, 229), (205, 50) */
CALL writeln
('Calling GNC with value ', a);
/* CIF PROCEDURECALL (1474, 294), (158, 50) */
CALL computeGNC(a, a);
/* CIF OUTPUT (1479, 359), (148, 50) */
OUTPUT housekeeping(a);
/* CIF NEXTSTATE (1503, 424), (100, 50) */
NEXTSTATE Running;
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
/* CIF state (139, 297), (73, 35) */
state stopped;
endstate;
endprocess orchestrator;
\ No newline at end of file
#include <math.h>
#include <stdio.h>
#include "dataview-uniq.h"
extern void adainit();
void orchestrator_RI_housekeeping(asn1SccMyInteger *toto)
{
printf("%lld\n", *toto);
}
int main()
{
printf("[C Code] Running test\n");
adainit();
return 0;
}
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