aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/_aconcat.dcl33
-rw-r--r--frontend/_aconcat.icl40
-rw-r--r--frontend/check.dcl3
-rw-r--r--frontend/check.icl2
-rw-r--r--frontend/frontend.dcl2
-rw-r--r--frontend/frontend.icl2
-rw-r--r--frontend/syntax.dcl3
-rw-r--r--frontend/syntax.icl1
-rw-r--r--frontend/type.dcl2
-rw-r--r--frontend/type.icl44
-rw-r--r--frontend/utilities.dcl2
-rw-r--r--frontend/utilities.icl2
12 files changed, 118 insertions, 18 deletions
diff --git a/frontend/_aconcat.dcl b/frontend/_aconcat.dcl
new file mode 100644
index 0000000..3647358
--- /dev/null
+++ b/frontend/_aconcat.dcl
@@ -0,0 +1,33 @@
+system module _aconcat
+
+import _SystemArray,StdInt,StdEnum,StdList
+
+arrayConcat a1 a2
+ :==r2
+where
+ r2={r1 & [i+s1]=a2.[i] \\ i<-[0..s2-1]}
+ r1={r0 & [i]=a1.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc (s1+s2)
+ s1=size a1
+ s2=size a2
+
+arrayPlusList a l
+ :==r2
+where
+ r2={r1 & [i+s1]=e \\ i<-[0..s2-1] & e<-l}
+ r1={r0 & [i]=a.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc (s1+s2)
+ s1=size a
+ s2=length l
+
+
+arrayPlusRevList a l
+ :==r2
+where
+ r2={r1 & [sr-i]=e \\ i<-[1..s2] & e<-l}
+ r1={r0 & [i]=a.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc sr
+ sr=s1+s2
+ s2=length l
+ s1=size a
+
diff --git a/frontend/_aconcat.icl b/frontend/_aconcat.icl
new file mode 100644
index 0000000..67caf59
--- /dev/null
+++ b/frontend/_aconcat.icl
@@ -0,0 +1,40 @@
+implementation module _aconcat
+
+import _SystemArray,StdInt,StdEnum, StdList
+
+arrayConcat a1 a2
+ :==r2
+where
+ r2={r1 & [i+s1]=a2.[i] \\ i<-[0..s2-1]}
+ r1={r0 & [i]=a1.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc (s1+s2)
+ s1=size a1
+ s2=size a2
+
+arrayPlusList a l
+ :==r2
+where
+ r2={r1 & [i+s1]=e \\ i<-[0..s2-1] & e <- l}
+ r1={r0 & [i]=a.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc (s1+s2)
+ s1=size a
+ s2=length l
+/*
+ :== case l of
+ []
+ -> a
+ _
+ -> arrayConcat a { x \\ x <- l }
+*/
+
+arrayPlusRevList a l
+ :==r2
+where
+ r2={r1 & [sr-i]=e \\ i<-[1..s2] & e<-l}
+ r1={r0 & [i]=a.[i] \\ i<-[0..s1-1]}
+ r0=_createArrayc sr
+ sr=s1+s2
+ s1=size a
+ s2=length l
+
+
diff --git a/frontend/check.dcl b/frontend/check.dcl
index c91ac95..7da5d78 100644
--- a/frontend/check.dcl
+++ b/frontend/check.dcl
@@ -18,3 +18,6 @@ convertIndex :: !Index !Index !(Optional ConversionTable) -> !Index
determineTypeOfMemberInstance :: !SymbolType ![TypeVar] !InstanceType !Specials !*TypeHeaps -> (!SymbolType, !Specials, !*TypeHeaps)
+arrayFunOffsetToPD_IndexTable :: !{# MemberDef} !v:{# PredefinedSymbol} -> (!{# Index}, !{#MemberDef}, !v:{#PredefinedSymbol})
+
+makeElemTypeOfArrayFunctionStrict :: !SymbolType !Index !{# Index} -> SymbolType
diff --git a/frontend/check.icl b/frontend/check.icl
index 0c94832..5d1e6e5 100644
--- a/frontend/check.icl
+++ b/frontend/check.icl
@@ -2708,6 +2708,7 @@ check_needed_modules_are_imported mod_name extension e_info cs=:{cs_needed_modul
cs_error = popErrorAdmin cs_error
= (e_info, { cs & cs_error = cs_error })
+arrayFunOffsetToPD_IndexTable :: !{# MemberDef} !v:{# PredefinedSymbol} -> (!{# Index}, !{#MemberDef}, !v:{#PredefinedSymbol})
arrayFunOffsetToPD_IndexTable member_defs predef_symbols
# nr_of_array_functions = size member_defs
= iFoldSt offset_to_PD_index PD_CreateArrayFun (PD_CreateArrayFun + nr_of_array_functions)
@@ -2722,6 +2723,7 @@ elemTypeIsStrict [TA {type_index={glob_object,glob_module}} _ : _] predef_symbol
= glob_module == predef_symbols.[PD_PredefinedModule].pds_def &&
(glob_object == predef_symbols.[PD_StrictArrayType].pds_def || glob_object == predef_symbols.[PD_UnboxedArrayType].pds_def)
+makeElemTypeOfArrayFunctionStrict :: !SymbolType !Index !{# Index} -> SymbolType
makeElemTypeOfArrayFunctionStrict st=:{st_args,st_result} me_offset offset_table
# array_fun_kind = offset_table.[me_offset]
| array_fun_kind == PD_UnqArraySelectFun
diff --git a/frontend/frontend.dcl b/frontend/frontend.dcl
index c8653b6..2ada4a3 100644
--- a/frontend/frontend.dcl
+++ b/frontend/frontend.dcl
@@ -11,7 +11,7 @@ import checksupport, transform, overloading
, fe_varHeap :: !.VarHeap
, fe_dclIclConversions ::!Optional {# Index}
, fe_iclDclConversions ::!Optional {# Index}
- , fe_arrayInstances :: !{!(Index, SymbolType)}
+ , fe_arrayInstances :: !IndexRange
}
frontEndInterface :: !Ident !SearchPaths !*PredefinedSymbols !*HashTable !*Files !*File !*File !*File -> (!*PredefinedSymbols, !*HashTable, !*Files, !*File, !*File, !*File, !Optional *FrontEndSyntaxTree)
diff --git a/frontend/frontend.icl b/frontend/frontend.icl
index 627d0e3..60d2519 100644
--- a/frontend/frontend.icl
+++ b/frontend/frontend.icl
@@ -10,7 +10,7 @@ import RWSDebug
, fe_varHeap :: !.VarHeap
, fe_dclIclConversions ::!Optional {# Index}
, fe_iclDclConversions ::!Optional {# Index}
- , fe_arrayInstances :: !{!(Index, SymbolType)}
+ , fe_arrayInstances :: !IndexRange
}
// trace macro
diff --git a/frontend/syntax.dcl b/frontend/syntax.dcl
index d87478e..5ee4821 100644
--- a/frontend/syntax.dcl
+++ b/frontend/syntax.dcl
@@ -413,6 +413,7 @@ cIsNonCoercible :== 2
| TransformedBody !TransformedBody
| Expanding ![FreeVar] // the parameters of the newly generated function
| BackendBody ![BackendBody]
+ | NoBody
:: BackendBody =
{ bb_args :: ![FunctionPattern]
@@ -1148,7 +1149,7 @@ instance == ModuleKind, Ident
instance <<< Module a | <<< a, ParsedDefinition, InstanceType, AttributeVar, TypeVar, SymbolType, Expression, Type, Ident, Global object | <<< object,
Position, CaseAlt, AType, FunDef, ParsedExpr, TypeAttribute, Bind a b | <<< a & <<< b, ParsedConstructor, TypeDef a | <<< a, TypeVarInfo,
BasicValue, ATypeVar, TypeRhs, FunctionPattern, (Import from_symbol) | <<< from_symbol, ImportDeclaration, ImportedIdent, CasePatterns,
- Optional a | <<< a, ConsVariable, BasicType, Annotation, Selection
+ Optional a | <<< a, ConsVariable, BasicType, Annotation, Selection, SignClassification
instance == TypeAttribute
instance == Annotation
diff --git a/frontend/syntax.icl b/frontend/syntax.icl
index b0a1e9a..aed17ec 100644
--- a/frontend/syntax.icl
+++ b/frontend/syntax.icl
@@ -370,6 +370,7 @@ cMayBeNonCoercible :== 4
| TransformedBody !TransformedBody
| Expanding ![FreeVar] // the parameters of the newly generated function
| BackendBody ![BackendBody]
+ | NoBody
:: BackendBody =
{ bb_args :: ![FunctionPattern]
diff --git a/frontend/type.dcl b/frontend/type.dcl
index 259fb70..9fe9b24 100644
--- a/frontend/type.dcl
+++ b/frontend/type.dcl
@@ -4,5 +4,5 @@ import StdArray
import syntax, check
typeProgram ::!{! Group} !*{# FunDef} !IndexRange !CommonDefs ![Declaration] !{# DclModule} !*Heaps !*PredefinedSymbols !*File
- -> (!Bool, !*{# FunDef}, !{! (!Index, !SymbolType)}, {! GlobalTCType}, !{# CommonDefs}, !{# {# FunType} }, !*Heaps, !*PredefinedSymbols, !*File)
+ -> (!Bool, !*{# FunDef}, !IndexRange, {! GlobalTCType}, !{# CommonDefs}, !{# {# FunType} }, !*Heaps, !*PredefinedSymbols, !*File)
diff --git a/frontend/type.icl b/frontend/type.icl
index b0d2c31..63615a0 100644
--- a/frontend/type.icl
+++ b/frontend/type.icl
@@ -1370,7 +1370,7 @@ addLiftedArgumentsToSymbolType st=:{st_arity,st_args,st_vars,st_attr_vars} nr_of
}
typeProgram ::!{! Group} !*{# FunDef} !IndexRange !CommonDefs ![Declaration] !{# DclModule} !*Heaps !*PredefinedSymbols !*File
- -> (!Bool, !*{# FunDef}, !{! (!Index, !SymbolType)}, {! GlobalTCType}, !{# CommonDefs}, !{# {# FunType} }, !*Heaps, !*PredefinedSymbols, !*File)
+ -> (!Bool, !*{# FunDef}, !IndexRange, {! GlobalTCType}, !{# CommonDefs}, !{# {# FunType} }, !*Heaps, !*PredefinedSymbols, !*File)
typeProgram comps fun_defs specials icl_defs imports modules {hp_var_heap, hp_expression_heap, hp_type_heaps} predef_symbols file
#! fun_env_size = size fun_defs
# ts_error = {ea_file = file, ea_loc = [], ea_ok = True }
@@ -1396,10 +1396,10 @@ typeProgram comps fun_defs specials icl_defs imports modules {hp_var_heap, hp_ex
(type_error, fun_defs, predef_symbols, special_instances, {ts_fun_env,ts_error,ts_var_heap, ts_expr_heap, ts_type_heaps})
= type_instances specials.ir_from specials.ir_to class_instances ti (type_error, fun_defs, predef_symbols, special_instances,
{ ts & ts_fun_env = ts_fun_env })
- {si_array_instances, si_next_TC_member_index, si_TC_instances}= special_instances
- (array_inst_types, predef_symbols, ts_type_heaps) = convert_array_instances si_array_instances ti_common_defs predef_symbols ts_type_heaps
+ {si_array_instances, si_next_array_member_index, si_next_TC_member_index, si_TC_instances}= special_instances
+ (fun_defs, predef_symbols, ts_type_heaps) = convert_array_instances si_array_instances ti_common_defs fun_defs predef_symbols ts_type_heaps
type_code_instances = {createArray si_next_TC_member_index GTT_Function & [gtci_index] = gtci_type \\ {gtci_index, gtci_type} <- si_TC_instances}
- = (not type_error, fun_defs, { array_inst_type \\ array_inst_type <- array_inst_types }, type_code_instances, ti_common_defs, ti_functions,
+ = (not type_error, fun_defs, { ir_from = fun_env_size, ir_to = si_next_array_member_index }, type_code_instances, ti_common_defs, ti_functions,
{hp_var_heap = ts_var_heap, hp_expression_heap = ts_expr_heap, hp_type_heaps = ts_type_heaps }, predef_symbols, ts_error.ea_file)
where
@@ -1704,25 +1704,41 @@ where
type_of (UncheckedType tst) = tst
type_of (SpecifiedType _ _ tst) = tst
- convert_array_instances si_array_instances common_defs predef_symbols type_heaps
+ convert_array_instances si_array_instances common_defs fun_defs predef_symbols type_heaps
| isEmpty si_array_instances
- = ([], predef_symbols, type_heaps)
+ = (fun_defs, predef_symbols, type_heaps)
# ({pds_ident,pds_module,pds_def},predef_symbols) = predef_symbols![PD_UnboxedArrayType]
unboxed_array_type = TA (MakeTypeSymbIdent { glob_object = pds_def, glob_module = pds_module } pds_ident 0) []
({pds_module,pds_def},predef_symbols) = predef_symbols![PD_ArrayClass]
{class_members} = common_defs.[pds_module].com_class_defs.[pds_def]
array_members = common_defs.[pds_module].com_member_defs
- (rev_instances, type_heaps) = foldSt (convert_array_instance class_members array_members unboxed_array_type) si_array_instances ([], type_heaps)
- = (reverse rev_instances, predef_symbols, type_heaps)
+ (offset_table, _, predef_symbols) = arrayFunOffsetToPD_IndexTable array_members predef_symbols
+ (rev_instances, type_heaps) = foldSt (convert_array_instance class_members array_members unboxed_array_type offset_table) si_array_instances
+ ([], type_heaps)
+ = (arrayPlusRevList fun_defs rev_instances, predef_symbols, type_heaps)
where
- convert_array_instance class_members array_members unboxed_array_type {ai_record} types_and_heaps
- = iFoldSt (create_instance_type class_members array_members unboxed_array_type (TA ai_record [])) 0 (size class_members) types_and_heaps
+ convert_array_instance class_members array_members unboxed_array_type offset_table {ai_record} funs_and_heaps
+ = iFoldSt (create_instance_type class_members array_members unboxed_array_type offset_table (TA ai_record [])) 0 (size class_members) funs_and_heaps
- create_instance_type members array_members unboxed_array_type record_type member_index (inst_types, type_heaps)
- # {me_type,me_class_vars} = array_members.[members.[member_index].ds_index]
- # (instance_type, _, type_heaps) = determineTypeOfMemberInstance me_type me_class_vars {it_vars = [], it_attr_vars = [], it_context = [],
+ create_instance_type members array_members unboxed_array_type offset_table record_type member_index (array_defs, type_heaps)
+ # {me_type,me_symb,me_class_vars,me_pos} = array_members.[members.[member_index].ds_index]
+ (instance_type, _, type_heaps) = determineTypeOfMemberInstance me_type me_class_vars {it_vars = [], it_attr_vars = [], it_context = [],
it_types = [unboxed_array_type, record_type]} SP_None type_heaps
- = ([(member_index,instance_type) : inst_types], type_heaps)
+ instance_type = makeElemTypeOfArrayFunctionStrict instance_type member_index offset_table
+ fun =
+ { fun_symb = me_symb
+ , fun_arity = me_type.st_arity
+ , fun_priority = NoPrio
+ , fun_body = NoBody
+ , fun_type = Yes instance_type
+ , fun_pos = me_pos
+ , fun_index = member_index
+ , fun_kind = FK_Unknown
+ , fun_lifted = 0
+ , fun_info = EmptyFunInfo
+ }
+
+ = ([fun : array_defs], type_heaps)
create_erroneous_function_types group ts
= foldSt create_erroneous_function_type group ts
diff --git a/frontend/utilities.dcl b/frontend/utilities.dcl
index 2315a73..4d4cbb4 100644
--- a/frontend/utilities.dcl
+++ b/frontend/utilities.dcl
@@ -4,6 +4,8 @@ from StdString import String
from StdEnv import Eq, not, Ord, IncDec
import StdMisc, general
+import _aconcat
+
/*
For Strings
*/
diff --git a/frontend/utilities.icl b/frontend/utilities.icl
index 9c943fd..054776c 100644
--- a/frontend/utilities.icl
+++ b/frontend/utilities.icl
@@ -1,6 +1,8 @@
implementation module utilities
import StdEnv, general
+
+from _aconcat import arrayConcat
/*