Commit 268197f7 authored by dbarbera's avatar dbarbera
Browse files

Fixed for loop variable type generation

parent e2fb00c5
......@@ -389,7 +389,7 @@ def generate_write(params):
basic_ty = find_basic_type(param.exprType)
expr_val = expression(param)
if basic_ty.kind == 'IntegerType':
if basic_ty.kind in ['IntegerType', 'Integer32Type']:
fmt_val = get_string_cons('% d')
fmt_ptr = g.builder.gep(fmt_val, [zero, zero])
g.builder.call(g.funcs['printf'], [fmt_ptr, expr_val])
......@@ -1085,7 +1085,7 @@ def _inner_procedure(proc):
def generate_type(ty):
''' Generate the equivalent LLVM type of a ASN.1 type '''
basic_ty = find_basic_type(ty)
if basic_ty.kind == 'IntegerType':
if basic_ty.kind in ['IntegerType', 'Integer32Type']:
return g.i32
elif basic_ty.kind == 'BooleanType':
return g.i1
......
/* CIF PROCESS (152, 148), (150, 75) */
PROCESS controlflow;
/* CIF TEXT (373, 97), (303, 168) */
-- Declare your variables
/* CIF TEXT (373, 97), (303, 168) */
-- Declare your variables
-- Syntax: DCL <variable name> <type name>;
DCL n Int32;
DCL b Bool;
DCL l List;
/* CIF ENDTEXT */
/* CIF START (0, 0), (70, 35) */
START;
/* CIF TASK (0, 50), (70, 35) */
TASK n := 0;
/* CIF TASK (-10, 100), (90, 35) */
TASK l := {1, 2};
/* CIF NEXTSTATE (0, 150), (70, 35) */
NEXTSTATE Wait;
/* CIF LABEL (470, 571), (78, 35) */
CONNECTION label1:
/* CIF PROCEDURECALL (438, 621), (141, 35) */
CALL writeln('label1');
/* CIF JOIN (491, 671), (35, 35) */
JOIN label2;
/* CIF End Label */
ENDCONNECTION;
/* CIF LABEL (490, 793), (75, 35) */
CONNECTION label2:
/* CIF PROCEDURECALL (459, 843), (136, 35) */
CALL writeln('label2');
/* CIF LABEL (490, 893), (75, 35) */
label3:
/* CIF PROCEDURECALL (459, 943), (136, 35) */
CALL writeln('label3');
/* CIF NEXTSTATE (493, 993), (70, 35) */
NEXTSTATE wait;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (0, 150), (70, 35) */
STATE Wait;
/* CIF INPUT (0, 205), (70, 35) */
INPUT run;
/* CIF DECISION (0, 255), (70, 50) */
DECISION b;
/* CIF ANSWER (-61, 325), (73, 24) */
(true):
/* CIF PROCEDURECALL (-83, 364), (118, 35) */
CALL writeln(true);
/* CIF ANSWER (65, 325), (78, 24) */
(false):
/* CIF PROCEDURECALL (42, 364), (122, 35) */
CALL writeln(false);
ENDDECISION;
/* CIF DECISION (0, 414), (70, 50) */
DECISION n;
/* CIF ANSWER (-32, 454), (70, 24) */
(2):
/* CIF PROCEDURECALL (-47, 493), (100, 35) */
CALL writeln(2);
/* CIF ANSWER (-143, 455), (70, 24) */
(1):
/* CIF PROCEDURECALL (-158, 494), (100, 35) */
CALL writeln(1);
/* CIF ANSWER (90, 454), (70, 24) */
else:
/* CIF PROCEDURECALL (62, 493), (124, 35) */
CALL writeln('else');
ENDDECISION;
/* CIF TASK (-48, 544), (167, 56) */
TASK for x in range(10):
n := (n + x) mod 255
/* CIF ENDTEXT */
/* CIF START (0, 0), (70, 35) */
START;
/* CIF TASK (0, 50), (70, 35) */
TASK n := 0;
/* CIF TASK (-10, 100), (90, 35) */
TASK l := {1, 2};
/* CIF NEXTSTATE (0, 150), (70, 35) */
NEXTSTATE Wait;
/* CIF LABEL (470, 571), (78, 35) */
CONNECTION label1:
/* CIF PROCEDURECALL (438, 621), (141, 35) */
CALL writeln('label1');
/* CIF JOIN (491, 671), (35, 35) */
JOIN label2;
/* CIF End Label */
ENDCONNECTION;
/* CIF LABEL (490, 793), (75, 35) */
CONNECTION label2:
/* CIF PROCEDURECALL (459, 843), (136, 35) */
CALL writeln('label2');
/* CIF LABEL (490, 893), (75, 35) */
label3:
/* CIF PROCEDURECALL (459, 943), (136, 35) */
CALL writeln('label3');
/* CIF NEXTSTATE (493, 993), (70, 35) */
NEXTSTATE wait;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (0, 150), (70, 35) */
STATE Wait;
/* CIF INPUT (0, 205), (70, 35) */
INPUT run;
/* CIF DECISION (0, 255), (70, 50) */
DECISION b;
/* CIF ANSWER (-61, 325), (73, 24) */
(true):
/* CIF PROCEDURECALL (-83, 364), (118, 35) */
CALL writeln(true);
/* CIF ANSWER (65, 325), (78, 24) */
(false):
/* CIF PROCEDURECALL (42, 364), (122, 35) */
CALL writeln(false);
ENDDECISION;
/* CIF DECISION (0, 414), (70, 50) */
DECISION n;
/* CIF ANSWER (-32, 444), (70, 24) */
(2):
/* CIF PROCEDURECALL (-47, 483), (100, 35) */
CALL writeln(2);
/* CIF ANSWER (-143, 445), (70, 24) */
(1):
/* CIF PROCEDURECALL (-158, 484), (100, 35) */
CALL writeln(1);
/* CIF ANSWER (90, 444), (70, 24) */
else:
/* CIF PROCEDURECALL (62, 483), (124, 35) */
CALL writeln('else');
ENDDECISION;
/* CIF TASK (-48, 534), (167, 56) */
TASK for x in range(3):
call writeln(x);
endfor;
/* CIF PROCEDURECALL (-15, 615), (100, 35) */
CALL writeln(n)
/* CIF COMMENT (105, 600), (70, 35) */
COMMENT '45';
/* CIF TASK (0, 665), (70, 35) */
TASK n := 0;
/* CIF TASK (-55, 715), (181, 56) */
TASK for x in range(2, 10, 2):
/* CIF TASK (0, 605), (70, 35) */
TASK n := 0;
/* CIF TASK (-55, 655), (181, 56) */
TASK for x in range(2, 10, 2):
n := (n + x) mod 255
endfor;
/* CIF PROCEDURECALL (-15, 786), (100, 35) */
CALL writeln(n)
/* CIF COMMENT (105, 771), (70, 35) */
COMMENT '20';
/* CIF JOIN (17, 836), (35, 35) */
JOIN label1;
ENDSTATE;
/* CIF PROCEDURECALL (-15, 726), (100, 35) */
CALL writeln(n)
/* CIF COMMENT (105, 701), (70, 35) */
COMMENT '20';
/* CIF JOIN (17, 776), (35, 35) */
JOIN label1;
ENDSTATE;
ENDPROCESS controlflow;
\ No newline at end of file
FALSE
else
45
0
1
2
20
label1
label2
......
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