Commit a22c3cf6 authored by John van Groningen's avatar John van Groningen
Browse files

added ArrayAndListInstances,OverloadedListPatterns and OverloadedListType

replaced PE_Compr by PE_ListCompr and PE_ArrayCompr
parent e0ded202
...@@ -113,6 +113,13 @@ instance toString Ident ...@@ -113,6 +113,13 @@ instance toString Ident
:: IndexRange = { ir_from :: !Index, ir_to :: !Index } :: IndexRange = { ir_from :: !Index, ir_to :: !Index }
:: ArrayAndListInstances = {
ali_array_first_instance_indices :: ![Int],
ali_list_first_instance_indices :: ![Int],
ali_tail_strict_list_first_instance_indices :: ![Int],
ali_instances_range :: !IndexRange
}
:: Index :== Int :: Index :== Int
NoIndex :== -1 NoIndex :== -1
...@@ -541,7 +548,6 @@ cIsALocalVar :== False ...@@ -541,7 +548,6 @@ cIsALocalVar :== False
| VI_Labelled_Empty {#Char} // RWS debugging | VI_Labelled_Empty {#Char} // RWS debugging
| VI_LocalLetVar // RWS, mark Let vars during case transformation | VI_LocalLetVar // RWS, mark Let vars during case transformation
:: ExtendedVarInfo = EVI_VarType !AType :: ExtendedVarInfo = EVI_VarType !AType
:: ArgumentPosition :== Int :: ArgumentPosition :== Int
...@@ -686,8 +692,7 @@ cNonRecursiveAppl :== False ...@@ -686,8 +692,7 @@ cNonRecursiveAppl :== False
| EI_Attribute !Int | EI_Attribute !Int
/* EI_DictionaryType is used to store the instance type of a class. This type is used during fusion to generate proper types for
/* EI_DictionaryType is used to store the instance type of a class. This type are used during fusion to generate proper types for
the fusion result (i.e. the resulting function after elimination of dictionaries) */ the fusion result (i.e. the resulting function after elimination of dictionaries) */
| EI_DictionaryType !Type | EI_DictionaryType !Type
...@@ -1010,7 +1015,8 @@ cNonUniqueSelection :== False ...@@ -1010,7 +1015,8 @@ cNonUniqueSelection :== False
| PE_Case !Ident !ParsedExpr [CaseAlt] | PE_Case !Ident !ParsedExpr [CaseAlt]
| PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr | PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr
| PE_Let !Bool !LocalDefs !ParsedExpr | PE_Let !Bool !LocalDefs !ParsedExpr
| PE_Compr !GeneratorKind !ParsedExpr ![Qualifier] | PE_ListCompr /*predef_cons_index:*/ !Int /*predef_nil_index:*/ !Int !ParsedExpr ![Qualifier]
| PE_ArrayCompr !ParsedExpr ![Qualifier]
| PE_Sequ Sequence | PE_Sequ Sequence
| PE_WildCard | PE_WildCard
| PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */ | PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */
...@@ -1165,10 +1171,17 @@ cIsNotStrict :== False ...@@ -1165,10 +1171,17 @@ cIsNotStrict :== False
, dyn_type_code :: !TypeCodeExpression /* filled after type checking */ , dyn_type_code :: !TypeCodeExpression /* filled after type checking */
} }
:: CasePatterns = AlgebraicPatterns !(Global Index) ![AlgebraicPattern] :: CasePatterns= AlgebraicPatterns !(Global Index) ![AlgebraicPattern]
| BasicPatterns !BasicType [BasicPattern] | BasicPatterns !BasicType [BasicPattern]
| DynamicPatterns [DynamicPattern] /* auxiliary */ | DynamicPatterns [DynamicPattern] /* auxiliary */
| NoPattern /* auxiliary */ | OverloadedListPatterns !OverloadedListType !Expression ![AlgebraicPattern]
| NoPattern /* auxiliary */
:: OverloadedListType = UnboxedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_u index, nil_u index
| UnboxedTailStrictList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_uts index, nil_uts index
| OverloadedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons index, nil index
instance == OverloadedListType
:: Selection = RecordSelection !(Global DefinedSymbol) !Int :: Selection = RecordSelection !(Global DefinedSymbol) !Int
| ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression | ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression
......
...@@ -111,6 +111,13 @@ where toString {import_module} = toString import_module ...@@ -111,6 +111,13 @@ where toString {import_module} = toString import_module
:: IndexRange = { ir_from :: !Index, ir_to :: !Index } :: IndexRange = { ir_from :: !Index, ir_to :: !Index }
:: ArrayAndListInstances = {
ali_array_first_instance_indices :: ![Int],
ali_list_first_instance_indices :: ![Int],
ali_tail_strict_list_first_instance_indices :: ![Int],
ali_instances_range :: !IndexRange
}
:: Index :== Int :: Index :== Int
NoIndex :== -1 NoIndex :== -1
...@@ -526,7 +533,6 @@ cIsALocalVar :== False ...@@ -526,7 +533,6 @@ cIsALocalVar :== False
| VI_Labelled_Empty {#Char} // RWS debugging | VI_Labelled_Empty {#Char} // RWS debugging
| VI_LocalLetVar // RWS, mark Let vars during case transformation | VI_LocalLetVar // RWS, mark Let vars during case transformation
:: ExtendedVarInfo = EVI_VarType !AType :: ExtendedVarInfo = EVI_VarType !AType
:: ArgumentPosition :== Int :: ArgumentPosition :== Int
...@@ -985,7 +991,8 @@ cNonUniqueSelection :== False ...@@ -985,7 +991,8 @@ cNonUniqueSelection :== False
| PE_Case !Ident !ParsedExpr [CaseAlt] | PE_Case !Ident !ParsedExpr [CaseAlt]
| PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr | PE_If !Ident !ParsedExpr !ParsedExpr !ParsedExpr
| PE_Let !Bool !LocalDefs !ParsedExpr | PE_Let !Bool !LocalDefs !ParsedExpr
| PE_Compr !GeneratorKind !ParsedExpr ![Qualifier] | PE_ListCompr /*predef_cons_index:*/ !Int /*predef_nil_index:*/ !Int !ParsedExpr ![Qualifier]
| PE_ArrayCompr !ParsedExpr ![Qualifier]
| PE_Sequ Sequence | PE_Sequ Sequence
| PE_WildCard | PE_WildCard
| PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */ | PE_Field !ParsedExpr !(Global FieldSymbol) /* Auxiliary, used during checking */
...@@ -1114,10 +1121,15 @@ cIsNotStrict :== False ...@@ -1114,10 +1121,15 @@ cIsNotStrict :== False
, dyn_type_code :: !TypeCodeExpression /* filled after type checking */ , dyn_type_code :: !TypeCodeExpression /* filled after type checking */
} }
:: CasePatterns = AlgebraicPatterns !(Global Index) ![AlgebraicPattern] :: CasePatterns= AlgebraicPatterns !(Global Index) ![AlgebraicPattern]
| BasicPatterns !BasicType [BasicPattern] | BasicPatterns !BasicType [BasicPattern]
| DynamicPatterns [DynamicPattern] /* auxiliary */ | DynamicPatterns [DynamicPattern] /* auxiliary */
| NoPattern /* auxiliary */ | OverloadedListPatterns !OverloadedListType !Expression ![AlgebraicPattern]
| NoPattern /* auxiliary */
:: OverloadedListType = UnboxedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_u index, nil_u index
| UnboxedTailStrictList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons_uts index, nil_uts index
| OverloadedList !(Global Index) !Index !Index !Index // list_type_symbol StdStrictLists module index, decons index, nil index
:: Selection = RecordSelection !(Global DefinedSymbol) !Int :: Selection = RecordSelection !(Global DefinedSymbol) !Int
| ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression | ArraySelection !(Global DefinedSymbol) !ExprInfoPtr !Expression
...@@ -1458,6 +1470,7 @@ where ...@@ -1458,6 +1470,7 @@ where
(<<<) file (BasicPatterns type patterns) = file <<< " " <<<patterns (<<<) file (BasicPatterns type patterns) = file <<< " " <<<patterns
(<<<) file (AlgebraicPatterns type patterns) = file <<< patterns (<<<) file (AlgebraicPatterns type patterns) = file <<< patterns
(<<<) file (DynamicPatterns patterns) = file <<< patterns (<<<) file (DynamicPatterns patterns) = file <<< patterns
(<<<) file (OverloadedListPatterns type decons_expr patterns) = file <<< decons_expr <<< " " <<< patterns
(<<<) file NoPattern = file (<<<) file NoPattern = file
instance <<< CheckedAlternative instance <<< CheckedAlternative
...@@ -1501,7 +1514,7 @@ where ...@@ -1501,7 +1514,7 @@ where
write_binds x file [] write_binds x file []
= file = file
write_binds x file [bind : binds] write_binds x file [bind : binds]
= write_binds x (file <<< x <<< " " <<< bind <<< '\n') binds = write_binds x (file <<< x <<< " " <<< bind) binds
(<<<) file (Case {case_expr,case_guards,case_default=No}) (<<<) file (Case {case_expr,case_guards,case_default=No})
//= file <<< "case " <<< case_expr <<< " of\n" <<< case_guards //= file <<< "case " <<< case_expr <<< " of\n" <<< case_guards
= file <<< "case " <<< case_expr <<< " of" <<< case_guards = file <<< "case " <<< case_expr <<< " of" <<< case_guards
...@@ -1628,8 +1641,8 @@ where ...@@ -1628,8 +1641,8 @@ where
(<<<) file (PE_Update expr1 selections expr2) = file <<< '{' <<< expr1 <<< " & " <<< selections <<< " = " <<< expr2 <<< '}' (<<<) file (PE_Update expr1 selections expr2) = file <<< '{' <<< expr1 <<< " & " <<< selections <<< " = " <<< expr2 <<< '}'
(<<<) file (PE_Record PE_Empty _ fields) = file <<< '{' <<< fields <<< '}' (<<<) file (PE_Record PE_Empty _ fields) = file <<< '{' <<< fields <<< '}'
(<<<) file (PE_Record rec _ fields) = file <<< '{' <<< rec <<< " & " <<< fields <<< '}' (<<<) file (PE_Record rec _ fields) = file <<< '{' <<< rec <<< " & " <<< fields <<< '}'
(<<<) file (PE_Compr True expr quals) = file <<< '[' <<< expr <<< " \\ " <<< quals <<< ']' (<<<) file (PE_ListCompr _ _ expr quals) = file <<< '[' <<< expr <<< " \\ " <<< quals <<< ']'
(<<<) file (PE_Compr False expr quals) = file <<< '{' <<< expr <<< " \\ " <<< quals <<< '}' (<<<) file (PE_ArrayCompr expr quals) = file <<< '{' <<< expr <<< " \\ " <<< quals <<< '}'
(<<<) file (PE_Sequ seq) = file <<< '[' <<< seq <<< ']' (<<<) file (PE_Sequ seq) = file <<< '[' <<< seq <<< ']'
(<<<) file PE_Empty = file <<< "** E **" (<<<) file PE_Empty = file <<< "** E **"
(<<<) file (PE_Ident symb) = file <<< symb (<<<) file (PE_Ident symb) = file <<< symb
...@@ -1694,22 +1707,23 @@ instance <<< FunDef ...@@ -1694,22 +1707,23 @@ instance <<< FunDef
where where
(<<<) file {fun_symb,fun_body=ParsedBody bodies} = file <<< fun_symb <<< '.' <<< ' ' <<< bodies (<<<) file {fun_symb,fun_body=ParsedBody bodies} = file <<< fun_symb <<< '.' <<< ' ' <<< bodies
(<<<) file {fun_symb,fun_body=CheckedBody {cb_args,cb_rhs},fun_info={fi_free_vars,fi_def_level,fi_calls}} = file <<< fun_symb <<< '.' (<<<) file {fun_symb,fun_body=CheckedBody {cb_args,cb_rhs},fun_info={fi_free_vars,fi_def_level,fi_calls}} = file <<< fun_symb <<< '.'
<<< "C " <<< cb_args <<< "\n= " <<< cb_rhs <<< "C " <<< cb_args <<< " = " <<< cb_rhs <<< '\n'
// <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< cb_args <<< " = " <<< cb_rhs // <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< cb_args <<< " = " <<< cb_rhs
(<<<) file {fun_symb,fun_index,fun_body=TransformedBody {tb_args,tb_rhs},fun_info={fi_free_vars,fi_def_level,fi_calls}} (<<<) file {fun_symb,fun_index,fun_body=TransformedBody {tb_args,tb_rhs},fun_info={fi_free_vars,fi_local_vars,fi_def_level,fi_calls}}
= file <<< fun_symb <<< '@' <<< fun_index <<< '.' = file <<< fun_symb <<< '@' <<< fun_index <<< '.' <<< "T "
<<< "T " <<< tb_args <<< '[' <<< fi_calls <<< ']' <<< "\n= " <<< tb_rhs // <<< '[' <<< fi_free_vars <<< "] [" <<< fi_local_vars <<< ']'
<<< tb_args <<< '[' <<< fi_calls <<< ']' <<< " = " <<< tb_rhs <<< '\n'
// <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< tb_args <<< " = " <<< tb_rhs // <<< '.' <<< fi_def_level <<< ' ' <<< '[' <<< fi_free_vars <<< ']' <<< tb_args <<< " = " <<< tb_rhs
(<<<) file {fun_symb,fun_index,fun_body=BackendBody body,fun_type=Yes type} = file <<< type <<< '\n' <<< fun_symb <<< '@' <<< fun_index <<< '.' (<<<) file {fun_symb,fun_index,fun_body=BackendBody body,fun_type=Yes type} = file // <<< type <<< '\n'
<<< body <<< '\n' <<< fun_symb <<< '@' <<< fun_index <<< '.' <<< body <<< '\n'
(<<<) file {fun_symb,fun_body=NoBody,fun_type=Yes type} = file <<< type <<< '\n' <<< fun_symb <<< '.' (<<<) file {fun_symb,fun_body=NoBody,fun_type=Yes type} = file // <<< type <<< '\n'
<<< "Array function\n" <<< fun_symb <<< '.' <<< "Array function\n"
instance <<< FunctionBody instance <<< FunctionBody
where where
(<<<) file (ParsedBody bodies) = file <<< bodies (<<<) file (ParsedBody bodies) = file <<< bodies
(<<<) file (CheckedBody {cb_args,cb_rhs}) = file <<< "C " <<< cb_args <<< "\n= " <<< cb_rhs (<<<) file (CheckedBody {cb_args,cb_rhs}) = file <<< "C " <<< cb_args <<< " = " <<< cb_rhs <<< '\n'
(<<<) file (TransformedBody {tb_args,tb_rhs}) = file <<< "T " <<< tb_args <<< "\n= " <<< tb_rhs (<<<) file (TransformedBody {tb_args,tb_rhs}) = file <<< "T " <<< tb_args <<< " = " <<< tb_rhs <<< '\n'
(<<<) file (BackendBody body) = file <<< body <<< '\n' (<<<) file (BackendBody body) = file <<< body <<< '\n'
(<<<) file NoBody = file <<< "Array function\n" (<<<) file NoBody = file <<< "Array function\n"
...@@ -1890,7 +1904,7 @@ where ...@@ -1890,7 +1904,7 @@ where
instance <<< Rhs instance <<< Rhs
where where
(<<<) file {rhs_alts,rhs_locals} = file <<< rhs_alts <<< rhs_locals (<<<) file {rhs_alts,rhs_locals} = file <<< rhs_alts <<< rhs_locals <<< '\n'
instance <<< OptGuardedAlts instance <<< OptGuardedAlts
where where
...@@ -2049,10 +2063,20 @@ where ...@@ -2049,10 +2063,20 @@ where
readable :: !Ident -> String // somewhat hacky readable :: !Ident -> String // somewhat hacky
readable {id_name} readable {id_name}
| id_name=="_cons" || id_name=="_nil"
= "list constructor"
| size id_name>0 && id_name.[0]=='_' | size id_name>0 && id_name.[0]=='_'
= id_name%(1, size id_name-1) | id_name=="_Cons" || id_name=="_Nil"
= "list constructor"
| id_name=="_!Cons" || id_name=="_!Nil"
= "! list constructor"
| id_name=="_#Cons" || id_name=="_#Nil"
= "# list constructor"
| id_name=="_Cons!" || id_name=="_Nil!"
= "list constructor !"
| id_name=="_!Cons!" || id_name=="_!Nil!"
= "! list constructor !"
| id_name=="_#Cons!" || id_name=="_#Nil!"
= "# list constructor !"
= id_name%(1, size id_name-1)
= id_name = id_name
instance <<< ImportedIdent instance <<< ImportedIdent
...@@ -2071,6 +2095,10 @@ instance == Annotation ...@@ -2071,6 +2095,10 @@ instance == Annotation
where where
(==) a1 a2 = equal_constructor a1 a2 (==) a1 a2 = equal_constructor a1 a2
instance == OverloadedListType
where
(==) a1 a2 = equal_constructor a1 a2
EmptySymbolTableEntry :== EmptySymbolTableEntryCAF.boxed_symbol_table_entry EmptySymbolTableEntry :== EmptySymbolTableEntryCAF.boxed_symbol_table_entry
::BoxedSymbolTableEntry = {boxed_symbol_table_entry::!SymbolTableEntry} ::BoxedSymbolTableEntry = {boxed_symbol_table_entry::!SymbolTableEntry}
......
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