const func type: array [ (in integer: minIdx) .. (in integer: maxIdx) ] (in type: baseType) is func
result
var type: arrayType is void;
local
var type: tupleType is void;
var type: sliceType is void;
begin
global
arrayType := newtype;
IN_PARAM_IS_REFERENCE(arrayType);
tupleType := tuple(baseType);
sliceType := newtype;
const creator: (ref arrayType: dest) ::= (in arrayType: source) is action "ARR_CREATE";
const destroyer: destroy (ref arrayType: aValue) is action "ARR_DESTR";
const proc: (inout arrayType: dest) := (in arrayType: source) is action "ARR_CPY";
const func arrayType: ARRLIT3 (in integer: minIdx, in integer: maxIdx,
in tupleType: aTuple, attr arrayType) is action "ARR_ARRLIT3";
const func arrayType: BASELIT3 (in integer: minIdx, in integer: maxIdx,
in baseType: anElement, attr arrayType) is action "ARR_BASELIT3";
const func arrayType: SET_MIN_IDX (paren1, in integer: start, paren2,
in arrayType: arr) is action "ARR_ARRLIT2";
const func arrayType: TIMES (in integer: factor, times,
in baseType: element, attr arrayType) is action "ARR_TIMES";
const arrayType: (attr arrayType) . value is
SET_MIN_IDX(paren1, minIdx, paren2,
TIMES(succ(maxIdx - minIdx), times, baseType.value, arrayType));
const func arrayType: (attr arrayType) [] (in tupleType: aTuple) is
return ARRLIT3(minIdx, maxIdx, aTuple, arrayType);
const func arrayType: (attr arrayType) [] (in baseType: anElement) is
return BASELIT3(minIdx, maxIdx, anElement, arrayType);
const func arrayType: (attr arrayType) times (in baseType: element) is
return SET_MIN_IDX(paren1, minIdx, paren2,
TIMES(succ(maxIdx - minIdx), times, element, arrayType));
const integer: length (attr arrayType) is succ(maxIdx - minIdx);
const integer: minIdx (attr arrayType) is minIdx;
const integer: maxIdx (attr arrayType) is maxIdx;
const integer: length (in arrayType: arr) is succ(maxIdx - minIdx);
const integer: minIdx (in arrayType: arr) is minIdx;
const integer: maxIdx (in arrayType: arr) is maxIdx;
const func baseType: (in arrayType: arr) [ (in integer: index) ] is action "ARR_IDX";
const varfunc baseType: (inout arrayType: arr) [ (in integer: index) ] is action "ARR_IDX";
const creator: (ref sliceType: dest) ::= (ref sliceType: source) is action "ARR_CREATE";
const destroyer: destroy (ref sliceType: aValue) is action "ARR_DESTR";
const proc: (inout sliceType: dest) := (ref sliceType: source) is action "ARR_CPY";
const proc: (inout arrayType: destination) @:=
[ (in integer: position) ] (ref sliceType: source) is action "ARR_POSCPY";
const func sliceType: (in arrayType: arr) [ (in integer: start) .. ] is action "ARR_TAIL";
const func sliceType: (in arrayType: arr) [ .. (in integer: stop) ] is action "ARR_HEAD";
const func sliceType: (in arrayType: arr) [ (in integer: start) ..
(in integer: length) ] is action "ARR_RANGE";
const func sliceType: (in arrayType: arr) [ (in integer: start) len
(in integer: length) ] is action "ARR_SUBARR";
const func sliceType: (in arrayType: arr) [ (in integer: start) fixLen
(in integer: length) ] is action "ARR_SUBARR_FIXLEN";
const proc: for (inout baseType: forVar) range (in arrayType: arr) do
(in proc: statements)
end for is func
local
var integer: number is 0;
begin
for number range minIdx to maxIdx do
forVar := arr[number];
statements;
end for;
end func;
const proc: for key (inout integer: keyVar) range (in arrayType: arr) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx to maxIdx do
statements;
end for;
end func;
const proc: for (inout baseType: forVar) key (inout integer: keyVar) range (in arrayType: arr) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx to maxIdx do
forVar := arr[keyVar];
statements;
end for;
end func;
const proc: for (inout baseType: forVar)
range (in arrayType: arr)
until (ref func boolean: condition) do
(in proc: statements)
end for is func
local
var integer: index is 0;
begin
index := minIdx;
if index <= maxIdx then
forVar := arr[index];
while index <= maxIdx and not condition do
statements;
incr(index);
if index <= maxIdx then
forVar := arr[index];
end if;
end while;
end if;
end func;
const proc: for (inout baseType: forVar)
range (in arrayType: arr)
until (ref boolean: condition) do
(in proc: statements)
end for is func
local
var integer: index is 0;
begin
index := minIdx;
if index <= maxIdx then
forVar := arr[index];
while index <= maxIdx and not condition do
statements;
incr(index);
if index <= maxIdx then
forVar := arr[index];
end if;
end while;
end if;
end func;
const proc: for key (inout integer: keyVar)
range (in arrayType: arr)
until (ref func boolean: condition) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx to maxIdx until condition do
statements;
end for;
end func;
const proc: for key (inout integer: keyVar)
range (in arrayType: arr)
until (ref boolean: condition) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx to maxIdx until condition do
statements;
end for;
end func;
const proc: for (inout baseType: forVar)
key (inout integer: keyVar)
range (in arrayType: arr)
until (ref func boolean: condition) do
(in proc: statements)
end for is func
begin
keyVar := minIdx;
if keyVar <= maxIdx then
forVar := arr[keyVar];
while keyVar <= maxIdx and not condition do
statements;
incr(keyVar);
if keyVar <= maxIdx then
forVar := arr[keyVar];
end if;
end while;
end if;
end func;
const proc: for (inout baseType: forVar)
key (inout integer: keyVar)
range (in arrayType: arr)
until (ref boolean: condition) do
(in proc: statements)
end for is func
begin
keyVar := minIdx;
if keyVar <= maxIdx then
forVar := arr[keyVar];
while keyVar <= maxIdx and not condition do
statements;
incr(keyVar);
if keyVar <= maxIdx then
forVar := arr[keyVar];
end if;
end while;
end if;
end func;
if getobj((in baseType: element1) = (in baseType: element2)) <> NIL and
getobj((in baseType: element1) <> (in baseType: element2)) <> NIL then
const func boolean: (in arrayType: arr1) = (in arrayType: arr2) is func
result
var boolean: isEqual is TRUE;
local
var integer: number is 1;
begin
number := minIdx;
while number <= maxIdx and isEqual do
isEqual := arr1[number] = arr2[number];
incr(number);
end while;
end func;
const func boolean: (in arrayType: arr1) <> (in arrayType: arr2) is func
result
var boolean: isNotEqual is FALSE;
local
var integer: number is 1;
begin
number := minIdx;
while number <= maxIdx and not isNotEqual do
isNotEqual := arr1[number] <> arr2[number];
incr(number);
end while;
end func;
end if;
end global;
end func;
const func type: array [ (in integer: maxIdx) ] (in type: baseType) is
return array[1 .. maxIdx] baseType;