const func type: array [ (in integer: minIdx) .. ] (in type: baseType) is func
result
var type: arrayType is void;
local
var type: tupleType is void;
var type: maxIndexType is void;
begin
global
arrayType := newtype;
IN_PARAM_IS_REFERENCE(arrayType);
tupleType := tuple(baseType);
maxIndexType := newtype;
IN_PARAM_IS_VALUE(maxIndexType);
const proc: (ref arrayType: dest) ::= (in arrayType: source) is action "ARR_CREATE";
const proc: destroy (ref arrayType: aValue) is action "ARR_DESTR";
const proc: (inout arrayType: dest) := (in arrayType: source) is action "ARR_CPY";
const proc: (inout arrayType: arr) &:= (in arrayType: extension) is action "ARR_APPEND";
const proc: (inout arrayType: arr) &:= (in baseType: element) is action "ARR_PUSH";
const func arrayType: (in arrayType: arr1) & (in arrayType: arr2) is action "ARR_CAT";
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 func arrayType: (in arrayType: arr) [ (in integer: start) .. ] is action "ARR_TAIL";
const func arrayType: (in arrayType: arr) [ .. (in integer: stop) ] is action "ARR_HEAD";
const func arrayType: (in arrayType: arr) [ (in integer: start) ..
(in integer: stop) ] is action "ARR_RANGE";
const func arrayType: (in arrayType: arr) [ (in integer: start) len
(in integer: length) ] is action "ARR_SUBARR";
const proc: insert (inout arrayType: arr, in integer: index,
in baseType: element) is action "ARR_INSERT";
const proc: insert (inout arrayType: arr, in integer: index,
in arrayType: elements) is action "ARR_INSERT_ARRAY";
const func baseType: remove (inout arrayType: arr, in integer: index) is action "ARR_REMOVE";
const func arrayType: remove (inout arrayType: arr, in integer: index,
in integer: length) is action "ARR_REMOVE_ARRAY";
const func integer: length (in arrayType: arr) is action "ARR_LNG";
const integer: minIdx (attr arrayType) is minIdx;
const integer: minIdx (in arrayType: arr) is minIdx;
const func integer: maxIdx (in arrayType: arr) is action "ARR_MAXIDX";
const func arrayType: SET_MIN_IDX (paren1, in integer: start, paren2,
in tupleType: aTuple, attr arrayType) is action "ARR_ARRLIT2";
const func arrayType: SET_MIN_IDX (paren1, in integer: start, paren2,
in baseType: anElement, attr arrayType) is action "ARR_BASELIT2";
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(0, times, baseType.value, arrayType));
const func arrayType: (attr arrayType) [] (in tupleType: aTuple) is
return SET_MIN_IDX(paren1, minIdx, paren2, aTuple, arrayType);
const func arrayType: (attr arrayType) [] (in baseType: anElement) is
return SET_MIN_IDX(paren1, minIdx, paren2, anElement, arrayType);
const proc: (ref maxIndexType: dest) ::= (ref maxIndexType: source) is action "INT_CREATE";
const proc: (inout maxIndexType: dest) := (in maxIndexType: source) is action "INT_CPY";
const proc: destroy (ref maxIndexType: aValue) is action "GEN_DESTR";
const func integer: ord (in maxIndexType: maxIndex) is action "INT_ICONV1";
const func maxIndexType: (attr maxIndexType) conv (in integer: number) is action "INT_ICONV3";
const func maxIndexType: (attr arrayType) [ .. (in integer: maxIdx) ] is
return maxIndexType conv maxIdx;
const func arrayType: (in maxIndexType: maxIndex) times (in baseType: element) is
return SET_MIN_IDX(paren1, minIdx, paren2,
TIMES(succ(ord(maxIndex) - minIdx), times, element, arrayType));
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(arr) 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(arr) 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(arr) 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;
var integer: maxIdx is 0;
begin
index := minIdx;
maxIdx := maxIdx(arr);
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;
var integer: maxIdx is 0;
begin
index := minIdx;
maxIdx := maxIdx(arr);
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(arr) 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(arr) 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
local
var integer: maxIdx is 0;
begin
keyVar := minIdx;
maxIdx := maxIdx(arr);
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
local
var integer: maxIdx is 0;
begin
keyVar := minIdx;
maxIdx := maxIdx(arr);
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 func baseType: rand (in arrayType: arr) is
return arr[rand(minIdx, maxIdx(arr))];
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 FALSE;
local
var integer: number is 1;
begin
if maxIdx(arr1) = maxIdx(arr2) then
isEqual := TRUE;
while number <= maxIdx(arr1) and isEqual do
isEqual := arr1[number] = arr2[number];
incr(number);
end while;
end if;
end func;
const func boolean: (in arrayType: arr1) <> (in arrayType: arr2) is func
result
var boolean: isNotEqual is TRUE;
local
var integer: number is 1;
begin
if maxIdx(arr1) = maxIdx(arr2) then
isNotEqual := FALSE;
while number <= maxIdx(arr1) and not isNotEqual do
isNotEqual := arr1[number] <> arr2[number];
incr(number);
end while;
end if;
end func;
end if;
end global;
end func;