const func type: array [ (in type: indexType) ] (in type: baseType) is func
result
var type: arrayType is void;
local
var type: stdArrayType is void;
var type: tupleType is void;
begin
arrayType := get_type(getfunc(array [ (attr indexType) ] (attr baseType)));
if arrayType = void then
global
arrayType := newtype;
IN_PARAM_IS_REFERENCE(arrayType);
stdArrayType := array baseType;
tupleType := tuple(baseType);
const type: array [ (attr indexType) ] (attr baseType) is arrayType;
const type: base_type (attr arrayType) is baseType;
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 integer: length (in arrayType: arr) is action "ARR_LNG";
const func integer: minIntIdx (in arrayType: arr) is action "ARR_MINIDX";
const func integer: maxIntIdx (in arrayType: arr) is action "ARR_MAXIDX";
const func stdArrayType: (attr stdArrayType) conv (in arrayType: arr) is action "ARR_CONV";
const func arrayType: (attr arrayType) conv (in stdArrayType: arr) is action "ARR_CONV";
const func tupleType: (attr tupleType) conv (in arrayType: arr) is action "ARR_CONV";
const varfunc stdArrayType: (attr stdArrayType) conv (inout arrayType: arr) is action "TYP_VARCONV";
const func arrayType: (attr arrayType) . _GENERATE_EMPTY_ARRAY is action "ARR_EMPTY";
const arrayType: (attr arrayType) . value is arrayType._GENERATE_EMPTY_ARRAY;
const func arrayType: [ (attr indexType) ] (in tupleType: arr_tuple) is
return arrayType conv ([ord(indexType.value)] arr_tuple);
const func arrayType: [ (attr indexType) ] (in baseType: base_elem) is
return arrayType conv ([ord(indexType.value)] base_elem);
const func arrayType: [ (in indexType: startIndex) ] (in tupleType: arr_tuple) is
return arrayType conv ([ord(startIndex)] arr_tuple);
const func arrayType: [ (in indexType: startIndex) ] (in baseType: base_elem) is
return arrayType conv ([ord(startIndex)] base_elem);
const func baseType: (in arrayType: an_array) [ (in indexType: index) ] is
baseType return stdArrayType conv an_array[ord(index)];
const varfunc baseType: (inout arrayType: an_array) [ (in indexType: index) ] is
baseType return var stdArrayType conv an_array[ord(index)];
const func arrayType: (in arrayType: an_array) [ (in indexType: start) .. ] is
return arrayType conv (stdArrayType conv an_array[ord(start) .. ]);
const func arrayType: (in arrayType: an_array) [ .. (in indexType: stop) ] is
return arrayType conv (stdArrayType conv an_array[ .. ord(stop)]);
const func arrayType: (in arrayType: an_array) [ (in indexType: start) .. (in indexType: stop) ] is
return arrayType conv (stdArrayType conv an_array[ord(start) .. ord(stop)]);
const func arrayType: (in arrayType: an_array) [ (in indexType: start) len (in indexType: stop) ] is
return arrayType conv (stdArrayType conv an_array[ord(start) len ord(stop)]);
const func indexType: minIdx (in arrayType: arr) is
return indexType conv minIntIdx(arr);
const func indexType: maxIdx (in arrayType: arr) is
return indexType conv maxIntIdx(arr);
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 minIntIdx(arr) to maxIntIdx(arr) do
forVar := stdArrayType conv arr[number];
statements;
end for;
end func;
const proc: for key (inout indexType: keyVar) range (in arrayType: arr) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx(arr) to maxIdx(arr) do
statements;
end for;
end func;
const proc: for (inout baseType: forVar) key (inout indexType: keyVar) range (in arrayType: arr) do
(in proc: statements)
end for is func
begin
for keyVar range minIdx(arr) to maxIdx(arr) do
forVar := stdArrayType conv arr[ord(keyVar)];
statements;
end for;
end func;
if getobj((attr indexType) . first) <> NIL and
getobj((attr indexType) . last) <> NIL then
const func arrayType: (attr indexType) times (in baseType: base_value) is func
result
var arrayType: anArray is arrayType.value;
begin
anArray := arrayType conv (succ(ord(indexType.last) - ord(indexType.first)) times base_value);
anArray := arrayType conv ([ord(indexType.first)] (tupleType conv anArray));
end func;
end if;
end global;
end if;
end func;
const func type: array [ (attr integer) ] (in type: baseType) is
return array baseType;