Commit e7191b88 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files
parents 61359321 a1f09b37
......@@ -1186,6 +1186,7 @@ def _append(expr):
ogAST.PrimConstant)) else '')
right = '{}{}'.format(right_str, string_payload(expr.right, right_str) if
isinstance(expr.right, (ogAST.PrimVariable,
ogAST.PrimConditional,
ogAST.PrimConstant)) else '')
ada_string = '(({}) & ({}))'.format(left, right)
......@@ -1375,15 +1376,27 @@ def _sequence_of(seqof):
stmts, local_decl = [], []
seqof_ty = seqof.exprType
try:
asn_type = TYPES[seqof_ty.ReferencedTypeName].type
asn_type = find_basic_type(TYPES[seqof_ty.ReferencedTypeName].type)
min_size = asn_type.Min
max_size = asn_type.Max
except AttributeError:
asn_type = None
min_size, max_size = seqof_ty.Min, seqof_ty.Max
if hasattr(seqof, 'expected_type'):
asn_type = find_basic_type(
TYPES[seqof.expected_type.ReferencedTypeName].type.type)
try:
min_size, max_size = asn_type.Min, asn_type.Max
except AttributeError:
pass
tab = []
for i in xrange(len(seqof.value)):
item_stmts, item_str, local_var = expression(seqof.value[i])
if isinstance(seqof.value[i],
(ogAST.PrimSequenceOf, ogAST.PrimStringLiteral)):
item_str = array_content(seqof.value[i], item_str, asn_type or
find_basic_type(seqof.value[i].exprType))
stmts.extend(item_stmts)
local_decl.extend(local_var)
tab.append(u'{i} => {value}'.format(i=i + 1, value=item_str))
......@@ -1710,8 +1723,12 @@ def array_content(prim, values, asnty):
else:
# Find a default value for the "others" field in case of SEQOF
_, df, _ = expression(prim.value[0])
return u"(Data => ({}, others => {}){})".format(values, df, rlen)
if isinstance(prim.value[0], (ogAST.PrimSequenceOf,
ogAST.PrimStringLiteral)):
df = array_content(prim.value[0], df, asnty)
return u"(Data => ({}{}others => {}){})".format(values,
', ' if values else '',
df, rlen)
def append_size(append):
......
......@@ -1760,6 +1760,7 @@ def variables(root, ta_ast, context):
else:
if def_value.exprType == UNKNOWN_TYPE:
def_value.exprType = asn1_sort
def_value.expected_type = asn1_sort
if not def_value.is_raw and \
not isinstance(def_value, ogAST.PrimConstant):
......@@ -3694,6 +3695,11 @@ def assign(root, context):
# this could cause a bug (and regression is OK)
if isinstance(expr.right, ogAST.ExprAppend):
expr.right.exprType = expr.left.exprType
if isinstance(expr.right, (ogAST.PrimSequenceOf,
ogAST.PrimStringLiteral)):
# Set the expected type on the right, this is needed to know
# if the expected size is variable or fixed in backends
expr.right.expected_type = expr.left.exprType
return expr, errors, warnings
......
......@@ -8,7 +8,7 @@ GNATLINK=gnatlink
O=0
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg \
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.so *.ali gnat.cfg \
examiner bin *.wrn *.gpr *.ll *.s dataview-uniq.c dataview-uniq.h \
real.c xer.c ber.c acn.c asn1crt.c asn1crt.h test_ada test_llvm \
*.autosave
......@@ -32,4 +32,4 @@ clean:
FORCE:
.PHONY: clean
\ No newline at end of file
.PHONY: clean
......@@ -15,6 +15,12 @@ test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
test-llvm: orchestrator.o
test-python: orchestrator.ali
$(GNATBIND) -n -Llibrorchestrator orchestrator
$(GNATMAKE) -c b~orchestrator.adb
$(CC) -shared -o liborchestrator.so b~orchestrator.o orchestrator.o taste_basictypes.o adaasn1rtl.o -lgnat
python -c "from ctypes import *; test=CDLL('./liborchestrator.so'); test.librorchestratorinit()"
coverage:
coverage run -p $(OPENGEODE) orchestrator.pr system_structure.pr --toAda
......
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) og.pr
test-parse:
$(OPENGEODE) og.pr --check
test-ada: dataview-uniq.o | test_ada.o
$(OPENGEODE) og.pr --toAda
$(ASN1SCC) -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -c *.adb
$(GNATBIND) -n og.ali
$(GNATLINK) -o test_ada test_ada.o og.ali -lgnat
./test_ada
test-llvm: test.o dataview-uniq.o | test_llvm.o
$(OPENGEODE) og.pr --llvm -O$(O)
$(LLC) *.ll
$(CC) -O$(O) -c *.s
$(CC) test.o dataview-uniq.o test_llvm.o -o test_llvm -lm
coverage:
coverage run -p $(OPENGEODE) og.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-Dataview DEFINITIONS ::=
BEGIN
List ::= SEQUENCE(SIZE(5)) OF OCTET STRING(SIZE(1..5))
OutStr ::= OCTET STRING (SIZE(0..255))
END
SYSTEM og;
/* CIF TEXT (279, 258), (356, 140) */
-- Text area for declarations and comments
use dv comment 'dataview-uniq.asn';
signal run;
/* CIF ENDTEXT */
CHANNEL c
FROM ENV TO og WITH run;
ENDCHANNEL;
BLOCK og;
SIGNALROUTE r
FROM ENV TO og WITH run;
CONNECT c AND r;
/* CIF PROCESS (253, 105), (150, 75) */
PROCESS og;
/* CIF TEXT (0, 33), (356, 143) */
-- Text area for declarations and comments
dcl a List := {'a', 'b', 'foo', 'bar
', ' baz'};
dcl result OutStr := '';
dcl sep OutStr := ', ';
dcl nosep OutStr := '';
/* CIF ENDTEXT */
/* CIF START (597, 63), (70, 35) */
START;
/* CIF TASK (539, 113), (185, 35) */
TASK result := result // 'Hello!';
/* CIF TASK (584, 163), (96, 35) */
TASK result := '';
/* CIF TASK (403, 213), (457, 78) */
TASK for each in a(2, length(a) - 1):
result := result // (if length(result) > 0 then sep else nosep fi) // each
endfor;
/* CIF PROCEDURECALL (567, 306), (129, 35) */
CALL writeln(result);
/* CIF NEXTSTATE (597, 356), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (286, 217), (70, 35) */
STATE wait;
ENDSTATE;
ENDPROCESS og;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
#include <stdio.h>
#include "dataview-uniq.h"
extern void adainit();
int main() {
adainit();
return 0;
}
#include <stdio.h>
#include "dataview-uniq.h"
extern void test_startup();
int main() {
test_startup();
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