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

Bugfix in Ada and LLVM backends

parent 5446f062
......@@ -1367,8 +1367,9 @@ def _sequence(seq):
for elem, value in seq.value.viewitems():
# Set the type of the field - easy thanks to ASN.1 flattened AST
delem = elem.replace('_', '-')
value.exprType = (TYPES
[seqType.ReferencedTypeName].type.Children[delem].type)
#value.exprType = (TYPES
# [seqType.ReferencedTypeName].type.Children[delem].type)
value.exprType = find_basic_type(seqType).Children[delem].type
value_stmts, value_str, local_var = expression(value)
ada_string += sep + elem + ' => ' + value_str
sep = ', '
......
......@@ -1533,7 +1533,9 @@ def _prim_sequence(prim, ctx):
for field_name, field_expr in prim.value.viewitems():
# Workarround for unknown types in nested sequences
field_expr.exprType = seq_asn1ty.type.Children[field_name.replace('_', '-')].type
#field_expr.exprType = seq_asn1ty.type.Children[field_name.replace('_', '-')].type
field_expr.exprType = ctx.basic_asn1type_of(prim.exprType).Children[\
field_name.replace('_', '-')].type
field_idx_cons = lc.Constant.int(ctx.i32, struct.idx(field_name))
field_ptr = ctx.builder.gep(struct_ptr, [ctx.zero, field_idx_cons])
......
Datamodel DEFINITIONS ::= BEGIN
-- ./dataview-uniq.asn
MyInteger ::= T_UInt8
-- ./dataview-uniq.asn
MyReal ::= REAL (0 .. 1000)
-- ./dataview-uniq.asn
MyEnum ::= ENUMERATED {
hello(0),
world(1),
howareyou(2)
}
-- ./dataview-uniq.asn
MySeq ::= SEQUENCE {
a MyInteger,
b MySeq_b
}
-- ./dataview-uniq.asn
MySeq2 ::= MySeq
-- ./dataview-uniq.asn
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq,
c MySeq2
}
-- ./dataview-uniq.asn
MyChoice2 ::= MyChoice
-- ./dataview-uniq.asn
MySeqOf ::= SEQUENCE (SIZE (2 .. 2)) OF MyEnum
-- ./dataview-uniq.asn
MyOctStr ::= OCTET STRING (SIZE (3 .. 3))
-- ./dataview-uniq.asn
MySeq_b ::= ENUMERATED {
taste(1),
welcomes(2),
you(3)
}
-- ./dataview-uniq.asn
T_Int32 ::= INTEGER (-2147483648 .. 2147483647)
-- ./dataview-uniq.asn
T_UInt32 ::= INTEGER (0 .. 4294967295)
-- ./dataview-uniq.asn
T_Int8 ::= INTEGER (-128 .. 127)
-- ./dataview-uniq.asn
T_UInt8 ::= INTEGER (0 .. 255)
-- ./dataview-uniq.asn
T_Boolean ::= BOOLEAN
END
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) function1.pr system_structure.pr
test-parse:
$(OPENGEODE) functin1.pr system_structure.pr --check
test-ada: function1.ali
test-llvm: function1.o
coverage:
coverage run -p $(OPENGEODE) function1.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
MyEnum ::= ENUMERATED { hello, world, howareyou }
MySeq ::= SEQUENCE {
a MyInteger,
b ENUMERATED { taste(1), welcomes(2), you(3) }
}
MySeq2 ::= MySeq
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq,
c MySeq2
}
MyChoice2 ::= MyChoice
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
MyOctStr ::= OCTET STRING (SIZE (3))
-- You can also declare variables (they will be visible in C, Ada and SDL)
myVar MySeqOf ::= { hello, world }
END
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
END
/* CIF PROCESS (250, 150), (150, 75) */
PROCESS function1;
/* CIF TEXT (671, 54), (375, 197) */
-- Declare your variables
-- Syntax: DCL <variable name> <type name>;
DCL test MyInteger;
DCL c1 MyChoice;
DCL c2 MyChoice2;
/* CIF ENDTEXT */
/* CIF START (320, 10), (70, 35) */
START;
/* CIF NEXTSTATE (319, 60), (72, 35) */
NEXTSTATE Wait;
/* CIF STATE (449, 10), (72, 35) */
STATE Wait;
/* CIF INPUT (432, 65), (105, 35) */
INPUT pi1(test);
/* CIF PROCEDURECALL (411, 115), (146, 35) */
CALL Writeln(test);
/* CIF TASK (376, 165), (217, 35) */
TASK c1 := b:{a 1, b taste};
/* CIF PROCEDURECALL (396, 215), (176, 35) */
CALL Writeln(c1!b!a);
/* CIF TASK (380, 265), (209, 35) */
TASK c1 := c:{a 1, b taste};
/* CIF PROCEDURECALL (396, 315), (176, 35) */
CALL Writeln(c1!c!a);
/* CIF NEXTSTATE (448, 365), (72, 35) */
NEXTSTATE Wait;
ENDSTATE;
ENDPROCESS function1;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM function1;
/* CIF Keep Specific Geode PARAMNAMES test */
SIGNAL PI1 (MyInteger);
CHANNEL c
FROM ENV TO function1 WITH PI1;
ENDCHANNEL;
BLOCK function1;
SIGNALROUTE r
FROM ENV TO function1 WITH PI1;
CONNECT c and r;
PROCESS function1 REFERENCED;
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