Commit 473a07e2 authored by Vincent Zweije's avatar Vincent Zweije
Browse files

Convert Symbol Type to own data structures (no strictness)

parent 750c7ae8
......@@ -14,6 +14,7 @@ Basic types and functions.
*/
from general import Optional
import StdOverloaded
import StdString
......@@ -26,7 +27,8 @@ Implementation
// The optional type of type t is a type like t
// where the actual t value may be present or absent.
:: Optional t = Absent | Present t
//:: Optional t = Absent | Present t
//Now using Optional from cocl's general module
// Adjust a function for a single argument
......
......@@ -23,7 +23,9 @@ Implementation
*/
:: Optional t = Absent | Present t
//:: Optional t = Absent | Present t
// Now using Optional type from cocl's general module
from general import Optional,No,Yes
// Adjust a function for a single argument
......@@ -91,8 +93,8 @@ foldmap f d
where foldmap` (x,y) g v = if (x==v) (f y) (g v)
foldoptional :: .res .(.t -> .res) !(Optional .t) -> .res
foldoptional absent present Absent = absent
foldoptional absent present (Present x) = present x
foldoptional no yes No = no
foldoptional no yes (Yes x) = yes x
forget :: val -> .(![.(val,res)] -> .[(val,res)]) | == val
forget x = filter (neq x o fst)
......@@ -161,8 +163,8 @@ power n f
= f o power (n-1) f
printoptional :: .(.t -> String) !(Optional .t) -> String
printoptional printa Absent = ""
printoptional printa (Present a) = printa a
printoptional printa No = ""
printoptional printa (Yes a) = printa a
proc :: .((w:elem -> .(.res -> .res)) -> v:(![w:elem] -> u:(.res -> .res))), [u <= v, u <= w]
proc = flip o foldr
......@@ -178,8 +180,8 @@ maphd f [] = []
maphd f [x:xs] = [f x:xs]
mapoptional :: .(.a -> .b) !(Optional .a) -> Optional .b
mapoptional f Absent = Absent
mapoptional f (Present x) = Present (f x)
mapoptional f No = No
mapoptional f (Yes x) = Yes (f x)
mappair :: .(.a -> .b) .(.c -> .d) !(.a,.c) -> (.b,.d)
mappair f g (x,y) = (f x,g y)
......@@ -219,8 +221,8 @@ showbool :: .(!.Bool -> a) | fromBool a
showbool = fromBool
showoptional :: .(.a -> .String) !(Optional .a) -> String
showoptional showa Absent = "Absent"
showoptional showa (Present a) = "(Present "+++showa a+++")"
showoptional showa No = "No"
showoptional showa (Yes a) = "(Yes "+++showa a+++")"
showpair :: !.(.a -> .String) !.(.b -> .String) !(.a,.b) -> String
showpair showa showb (a,b) = "("+++showa a+++","+++showb b+++")"
......
......@@ -4,6 +4,8 @@ implementation module convert
import coreclean
import rule
import graph
import basic
import syntax
import StdEnv
......@@ -46,13 +48,70 @@ convert_fundef fundef (typerulemap,strictsmap,rulesmap,kindmap)
kind = convert_kind fun_kind
convert_symboltype :: SymbolType -> (Rule SuclTypeSymbol SuclTypeVariable,[Bool])
convert_symboltype _ = abort "convert: convert_symboltype: not implemented"
convert_symboltype {st_vars,st_args,st_arity,st_result,st_context,st_attr_vars,st_attr_env}
= (mkrule typeargs typeroot graph``,nostricts)
where (heap`,(graph``,typeargs)) = convert_atypes (sucltypeheap,graph`) st_args
(_,(graph`,[typeroot:_])) = convert_atype st_result (heap`,(emptygraph,[]))
nostricts = abort "convert_symboltype: strictness info not implemented"
convert_atypes
:: ( ([SuclTypeVariable])
, (Graph SuclTypeSymbol SuclTypeVariable)
)
[AType]
-> ( ([SuclTypeVariable])
, (Graph SuclTypeSymbol SuclTypeVariable,[SuclTypeVariable])
)
convert_atypes (heap,graph) atypes
= foldlr convert_atype (heap,(graph,[])) atypes
convert_atype
:: AType
( ([SuclTypeVariable])
, (Graph SuclTypeSymbol SuclTypeVariable,[SuclTypeVariable])
)
-> ( ([SuclTypeVariable])
, (Graph SuclTypeSymbol SuclTypeVariable,[SuclTypeVariable])
)
convert_atype atype (heap,(graph,rest))
= case atype.at_type
of TA typename atypes
-> (heap``,(updategraph typevar (typesym,typeargs) graph`,[typevar:rest]))
where (heap``,(graph`,typeargs)) = convert_atypes (heap`,graph) atypes
[typevar:heap`] = heap
typesym = SuclUSER typename
functype --> argtype
-> (heap```,(graph```,[suclrestype:rest]))
where (heap``,(graph``,fnargs)) = convert_atype functype (heap`,(graph`,suclargtype))
(heap```,(graph`,suclargtype)) = convert_atype argtype (heap``,(graph,[]))
[suclrestype:heap`] = heap
graph``` = updategraph suclrestype (SuclFN,fnargs) graph``
TB basictype
-> (heap`,(graph`,[suclbasictype:rest]))
where [suclbasictype:heap`] = heap
graph` = updategraph suclbasictype (convert_btype basictype,[]) graph
TV tvname
-> (heap,(graph,[sucltypevar:rest]))
where sucltypevar = SuclNAMED tvname
_
-> (heap`,(graph`,[typevar:rest]))
where [typevar:heap`] = heap
graph` = updategraph typevar notimpl graph
notimpl = abort "convert_atype: unknown form of Type"
convert_btype :: BasicType -> SuclTypeSymbol
convert_btype BT_Int = SuclINT
convert_btype BT_Char = SuclCHAR
convert_btype BT_Real = SuclREAL
convert_btype BT_Bool = SuclBOOL
convert_btype BT_Dynamic = SuclDYNAMIC
convert_btype BT_File = SuclFILE
convert_btype BT_World = SuclWORLD
convert_btype _ = abort "convert: convert_btype: unhandled basic type"
convert_functionbody :: FunctionBody -> [Rule SuclSymbol SuclVariable]
convert_functionbody _ = abort "convert: convert_functionbody: not implemented"
convert_kind :: DefOrImpFunKind -> SuclSymbolKind
convert_kind _ = abort "convert: convert_kind: not implemented"
foldoptional no yes No = no
foldoptional no yes (Yes value) = yes value
......@@ -2,16 +2,30 @@ definition module coreclean
// $Id$
from syntax import Ident
from syntax import TypeSymbIdent,Ident,TypeVar
// Transitive necessities
from syntax import SymbolPtr,SymbolTableEntry,STE_Kind,Index,Level
from syntax import SymbolPtr,SymbolTableEntry,STE_Kind,Index,Level,Global,TypeSymbProperties,SignClassification,PropClassification,TypeVarInfoPtr,TypeVarInfo
from general import BITVECT
from Heap import Ptr,PtrN,HeapN
from StdString import String
:: SuclTypeSymbol
= SuclUSER TypeSymbIdent
| SuclFN
| SuclINT
| SuclCHAR
| SuclREAL
| SuclBOOL
| SuclDYNAMIC
| SuclFILE
| SuclWORLD
:: SuclTypeVariable
= SuclANONYMOUS Int
| SuclNAMED TypeVar
sucltypeheap :: [SuclTypeVariable]
:: SuclSymbol
= SuclUser Ident
......
......@@ -5,10 +5,22 @@ implementation module coreclean
import syntax
:: SuclTypeSymbol
= SuclINT
= SuclUSER TypeSymbIdent
| SuclFN
| SuclINT
| SuclCHAR
| SuclREAL
| SuclBOOL
| SuclDYNAMIC
| SuclFILE
| SuclWORLD
:: SuclTypeVariable
= SuclANONYMOUS Int
| SuclNAMED TypeVar
sucltypeheap :: [SuclTypeVariable]
sucltypeheap =: map SuclANONYMOUS [0..]
:: SuclSymbol
= SuclUser Ident
......
......@@ -11,6 +11,7 @@ import rule
import graph
import pfun
import basic
from general import Yes,No
import StdEnv
/*
......@@ -134,14 +135,14 @@ transform
| == var
& == pvar
transform anode sargs (Present spine)
transform anode sargs (Yes spine)
= selectfromtip (spinetip spine)
where selectfromtip (nid,Open rgraph) = tryinstantiate nid rgraph anode sargs
selectfromtip (nid,Redex rule matching) = tryunfold nid rule matching spine
selectfromtip (nid,Strict) = tryannotate nid sargs
selectfromtip spine = dostop
transform anode sargs Absent
transform anode sargs No
= dostop
// ==== ATTEMPT TO INSTANTIATE A FREE VARIABLE WITH A PATTERN ====
......
......@@ -4,7 +4,7 @@ definition module spine
from rule import Rgraph,Rule
from pfun import Pfun
from basic import Optional
from general import Optional
/*
......
......@@ -9,6 +9,7 @@ import rule
import graph
import pfun
import basic
from general import No,Yes
import StdEnv
/*
......@@ -110,8 +111,8 @@ makernfstrategy
makernfstrategy hist strat rnfnodes node graph
= substrat [] spinecont rnfanswer node
where spinecont spine = Present spine
rnfanswer = Absent
where spinecont spine = Yes spine
rnfanswer = No
substrat spinenodes spinecont rnfanswer node
| isMember node spinenodes
......
!_DUMMY tags // ;" $Id$
!_DUMMY tags // ;" vi:set ts=32 noet:
CheckedTypeDef ../compiler/syntax.dcl /::\tCheckedTypeDef/
CommonDefs ../compiler/checksupport.dcl /::\tCommonDefs/
Expression ../compiler/syntax.dcl /::\tExpression/
ExpressionHeap ../compiler/syntax.dcl /::\tExpressionHeap/
FunDef ../compiler/syntax.dcl /::\tFunDef/
FunType ../compiler/syntax.dcl /::\tFunType/
Group ../compiler/transform.dcl /::\tGroup/
Ident ../compiler/syntax.dcl /::\tIdent/
ImportedConstructors ../compiler/trans.dcl /::\tImportedConstructors/
ImportedFunctions ../compiler/trans.dcl /::\tImportedFunctions/
Index ../compiler/syntax.dcl /:: Index/
IndexRange ../compiler/syntax.dcl /::\tIndexRange/
TypeDefInfos ../compiler/syntax.dcl /::\tTypeDefInfos/
TypeHeaps ../compiler/syntax.dcl /::\tTypeHeaps/
VarHeap ../compiler/checksupport.dcl /::\tVarHeap/
supercompile supercompile.icl /^supercompile/
AType ../compiler/syntax.dcl /::\tAType\>/
ATypeVar ../compiler/syntax.dcl /::\tATypeVar\>/
ActiveCaseInfo ../compiler/syntax.dcl /::\tActiveCaseInfo\>/
AlgebraicPattern ../compiler/syntax.dcl /::\tAlgebraicPattern\>/
Annotation ../compiler/syntax.dcl /::\tAnnotation\>/
App ../compiler/syntax.dcl /::\tApp\>/
ApplicationKind ../compiler/syntax.dcl /::\tApplicationKind\>/
ArgumentPosition ../compiler/syntax.dcl /::\tArgumentPosition\>/
ArraySelector ../compiler/syntax.dcl /::\tArraySelector\>/
AttrInequality ../compiler/syntax.dcl /::\tAttrInequality\>/
AttrVarHeap ../compiler/syntax.dcl /::\tAttrVarHeap\>/
AttrVarInfo ../compiler/syntax.dcl /::\tAttrVarInfo\>/
AttrVarInfoPtr ../compiler/syntax.dcl /::\tAttrVarInfoPtr\>/
AttributeVar ../compiler/syntax.dcl /::\tAttributeVar\>/
BackendBody ../compiler/syntax.dcl /::\tBackendBody\>/
BasicPattern ../compiler/syntax.dcl /::\tBasicPattern\>/
BasicType ../compiler/syntax.dcl /::\tBasicType\>/
BasicValue ../compiler/syntax.dcl /::\tBasicValue\>/
BoundExpr ../compiler/syntax.dcl /::\tBoundExpr\>/
BoundVar ../compiler/syntax.dcl /::\tBoundVar\>/
Case ../compiler/syntax.dcl /::\tCase\>/
CaseAlt ../compiler/syntax.dcl /::\tCaseAlt\>/
CasePatterns ../compiler/syntax.dcl /::\tCasePatterns\>/
CaseType ../compiler/syntax.dcl /::\tCaseType\>/
CheckedAlternative ../compiler/syntax.dcl /::\tCheckedAlternative\>/
CheckedBody ../compiler/syntax.dcl /::\tCheckedBody\>/
CheckedTypeDef ../compiler/syntax.dcl /::\tCheckedTypeDef\>/
ClassDef ../compiler/syntax.dcl /::\tClassDef\>/
ClassInstance ../compiler/syntax.dcl /::\tClassInstance\>/
CodeBinding ../compiler/syntax.dcl /::\tCodeBinding\>/
CoercionPosition ../compiler/syntax.dcl /::\tCoercionPosition\>/
CollectedDefinitions ../compiler/syntax.dcl /::\tCollectedDefinitions\>/
CollectedLocalDefs ../compiler/syntax.dcl /::\tCollectedLocalDefs\>/
CommonDefs ../compiler/checksupport.dcl /::\tCommonDefs\>/
ComponentNrAndIndex ../compiler/syntax.dcl /::\tComponentNrAndIndex\>/
Condition ../compiler/syntax.dcl /::\tCondition\>/
Conditional ../compiler/syntax.dcl /::\tConditional\>/
ConsClass ../compiler/syntax.dcl /::\tConsClass\>/
ConsClasses ../compiler/syntax.dcl /::\tConsClasses\>/
ConsDef ../compiler/syntax.dcl /::\tConsDef\>/
ConsVariable ../compiler/syntax.dcl /::\tConsVariable\>/
CountedVariable ../compiler/syntax.dcl /::\tCountedVariable\>/
Declaration ../compiler/syntax.dcl /::\tDeclaration\>/
DeclarationRecord ../compiler/syntax.dcl /::\tDeclarationRecord\>/
DefOrImpFunKind ../compiler/syntax.dcl /::\tDefOrImpFunKind\>/
DefinedSymbol ../compiler/syntax.dcl /::\tDefinedSymbol\>/
DynamicExpr ../compiler/syntax.dcl /::\tDynamicExpr\>/
DynamicPattern ../compiler/syntax.dcl /::\tDynamicPattern\>/
DynamicPtr ../compiler/syntax.dcl /::\tDynamicPtr\>/
DynamicType ../compiler/syntax.dcl /::\tDynamicType\>/
ElemAssignment ../compiler/syntax.dcl /::\tElemAssignment\>/
Export ../compiler/syntax.dcl /::\tExport\>/
ExprInfo ../compiler/syntax.dcl /::\tExprInfo\>/
ExprInfoPtr ../compiler/syntax.dcl /::\tExprInfoPtr\>/
ExprWithLocalDefs ../compiler/syntax.dcl /::\tExprWithLocalDefs\>/
Expression ../compiler/syntax.dcl /::\tExpression\>/
ExpressionHeap ../compiler/syntax.dcl /::\tExpressionHeap\>/
ExtendedExprInfo ../compiler/syntax.dcl /::\tExtendedExprInfo\>/
ExtendedVarInfo ../compiler/syntax.dcl /::\tExtendedVarInfo\>/
FieldAssignment ../compiler/syntax.dcl /::\tFieldAssignment\>/
FieldSymbol ../compiler/syntax.dcl /::\tFieldSymbol\>/
FreeVar ../compiler/syntax.dcl /::\tFreeVar\>/
FunCall ../compiler/syntax.dcl /::\tFunCall\>/
FunDef ../compiler/syntax.dcl /::\tFunDef\>/
FunInfo ../compiler/syntax.dcl /::\tFunInfo\>/
FunKind ../compiler/syntax.dcl /::\tFunKind\>/
FunType ../compiler/syntax.dcl /::\tFunType\>/
FunctionBody ../compiler/syntax.dcl /::\tFunctionBody\>/
FunctionHeap ../compiler/syntax.dcl /::\tFunctionHeap\>/
FunctionInfo ../compiler/syntax.dcl /::\tFunctionInfo\>/
FunctionInfoPtr ../compiler/syntax.dcl /::\tFunctionInfoPtr\>/
FunctionPattern ../compiler/syntax.dcl /::\tFunctionPattern\>/
GeneratedFunction ../compiler/syntax.dcl /::\tGeneratedFunction\>/
Generator ../compiler/syntax.dcl /::\tGenerator\>/
GeneratorKind ../compiler/syntax.dcl /::\tGeneratorKind\>/
GenericDef ../compiler/syntax.dcl /::\tGenericDef\>/
Global ../compiler/syntax.dcl /::\tGlobal\>/
GlobalTCType ../compiler/syntax.dcl /::\tGlobalTCType\>/
Group ../compiler/transform.dcl /::\tGroup\>/
GuardPattern ../compiler/syntax.dcl /::\tGuardPattern\>/
GuardedExpr ../compiler/syntax.dcl /::\tGuardedExpr\>/
Ident ../compiler/syntax.dcl /::\tIdent\>/
IdentPos ../compiler/syntax.dcl /::\tIdentPos\>/
Import ../compiler/syntax.dcl /::\tImport\>/
ImportDeclaration ../compiler/syntax.dcl /::\tImportDeclaration\>/
ImportedConstructors ../compiler/trans.dcl /::\tImportedConstructors\>/
ImportedFunctions ../compiler/trans.dcl /::\tImportedFunctions\>/
ImportedIdent ../compiler/syntax.dcl /::\tImportedIdent\>/
Index ../compiler/syntax.dcl /:: Index\>/
IndexRange ../compiler/syntax.dcl /::\tIndexRange\>/
InstanceInfo ../compiler/syntax.dcl /::\tInstanceInfo\>/
InstanceType ../compiler/syntax.dcl /::\tInstanceType\>/
KindHeap ../compiler/syntax.dcl /::\tKindHeap\>/
KindInfo ../compiler/syntax.dcl /::\tKindInfo\>/
KindInfoPtr ../compiler/syntax.dcl /::\tKindInfoPtr\>/
Let ../compiler/syntax.dcl /::\tLet\>/
LetBind ../compiler/syntax.dcl /::\tLetBind\>/
LetExpressionInfo ../compiler/syntax.dcl /::\tLetExpressionInfo\>/
LetExpressionStatus ../compiler/syntax.dcl /::\tLetExpressionStatus\>/
LetOccurrences ../compiler/syntax.dcl /::\tLetOccurrences\>/
LetVarInfo ../compiler/syntax.dcl /::\tLetVarInfo\>/
LocalDefs ../compiler/syntax.dcl /::\tLocalDefs\>/
MemberDef ../compiler/syntax.dcl /::\tMemberDef\>/
Module ../compiler/syntax.dcl /::\tModule\>/
ModuleKind ../compiler/syntax.dcl /::\tModuleKind\>/
NodeDef ../compiler/syntax.dcl /::\tNodeDef\>/
NodeDefWithLocals ../compiler/syntax.dcl /::\tNodeDefWithLocals\>/
Occurrence ../compiler/syntax.dcl /::\tOccurrence\>/
OccurrenceBinding ../compiler/syntax.dcl /::\tOccurrenceBinding\>/
OptGuardedAlts ../compiler/syntax.dcl /::\tOptGuardedAlts\>/
OptionalVariable ../compiler/syntax.dcl /::\tOptionalVariable\>/
OverloadedCall ../compiler/syntax.dcl /::\tOverloadedCall\>/
ParsedBody ../compiler/syntax.dcl /::\tParsedBody\>/
ParsedConstructor ../compiler/syntax.dcl /::\tParsedConstructor\>/
ParsedDefinition ../compiler/syntax.dcl /::\tParsedDefinition\>/
ParsedExpr ../compiler/syntax.dcl /::\tParsedExpr\>/
ParsedImport ../compiler/syntax.dcl /::\tParsedImport\>/
ParsedInstance ../compiler/syntax.dcl /::\tParsedInstance\>/
ParsedModule ../compiler/syntax.dcl /::\tParsedModule\>/
ParsedSelection ../compiler/syntax.dcl /::\tParsedSelection\>/
ParsedSelector ../compiler/syntax.dcl /::\tParsedSelector\>/
ParsedTypeDef ../compiler/syntax.dcl /::\tParsedTypeDef\>/
PatternExpression ../compiler/syntax.dcl /::\tPatternExpression\>/
PreviousLetVarInfo ../compiler/syntax.dcl /::\tPreviousLetVarInfo\>/
Producer ../compiler/syntax.dcl /::\tProducer\>/
Qualifier ../compiler/syntax.dcl /::\tQualifier\>/
RecordType ../compiler/syntax.dcl /::\tRecordType\>/
RefCountsInCase ../compiler/syntax.dcl /::\tRefCountsInCase\>/
ReferenceCount ../compiler/syntax.dcl /::\tReferenceCount\>/
Rhs ../compiler/syntax.dcl /::\tRhs\>/
RhsDefsOfType ../compiler/syntax.dcl /::\tRhsDefsOfType\>/
ScannedModule ../compiler/syntax.dcl /::\tScannedModule\>/
Selection ../compiler/syntax.dcl /::\tSelection\>/
SelectiveUse ../compiler/syntax.dcl /::\tSelectiveUse\>/
SelectorDef ../compiler/syntax.dcl /::\tSelectorDef\>/
SelectorKind ../compiler/syntax.dcl /::\tSelectorKind\>/
Sequence ../compiler/syntax.dcl /::\tSequence\>/
Special ../compiler/syntax.dcl /::\tSpecial\>/
SpecialSubstitution ../compiler/syntax.dcl /::\tSpecialSubstitution\>/
Specials ../compiler/syntax.dcl /::\tSpecials\>/
SymbIdent ../compiler/syntax.dcl /::\tSymbIdent\>/
SymbKind ../compiler/syntax.dcl /::\tSymbKind\>/
SymbolPtr ../compiler/syntax.dcl /::\tSymbolPtr\>/
SymbolTable ../compiler/syntax.dcl /::\tSymbolTable\>/
SymbolTableEntry ../compiler/syntax.dcl /::\tSymbolTableEntry\>/
SymbolType ../compiler/syntax.dcl /::\tSymbolType\>/
TempAttrId ../compiler/syntax.dcl /::\tTempAttrId\>/
TempLocalVar ../compiler/syntax.dcl /::\tTempLocalVar\>/
TempVarId ../compiler/syntax.dcl /::\tTempVarId\>/
TransformedBody ../compiler/syntax.dcl /::\tTransformedBody\>/
Type ../compiler/syntax.dcl /::\tType\>/
TypeAttribute ../compiler/syntax.dcl /::\tTypeAttribute\>/
TypeCase ../compiler/syntax.dcl /::\tTypeCase\>/
TypeCodeExpression ../compiler/syntax.dcl /::\tTypeCodeExpression\>/
TypeContext ../compiler/syntax.dcl /::\tTypeContext\>/
TypeDef ../compiler/syntax.dcl /::\tTypeDef\>/
TypeDefInfo ../compiler/syntax.dcl /::\tTypeDefInfo\>/
TypeDefInfos ../compiler/syntax.dcl /::\tTypeDefInfos\>/
TypeHeaps ../compiler/syntax.dcl /::\tTypeHeaps\>/
TypeKind ../compiler/syntax.dcl /::\tTypeKind\>/
TypeRhs ../compiler/syntax.dcl /::\tTypeRhs\>/
TypeSymbIdent ../compiler/syntax.dcl /::\tTypeSymbIdent\>/
TypeSymbProperties ../compiler/syntax.dcl /::\tTypeSymbProperties\>/
TypeVar ../compiler/syntax.dcl /::\tTypeVar\>/
TypeVarHeap ../compiler/syntax.dcl /::\tTypeVarHeap\>/
TypeVarInfo ../compiler/syntax.dcl /::\tTypeVarInfo\>/
TypeVarInfoPtr ../compiler/syntax.dcl /::\tTypeVarInfoPtr\>/
UnboundVariable ../compiler/syntax.dcl /::\tUnboundVariable\>/
VarHeap ../compiler/checksupport.dcl /::\tVarHeap\>/
VarInfo ../compiler/syntax.dcl /::\tVarInfo\>/
VarInfoPtr ../compiler/syntax.dcl /::\tVarInfoPtr\>/
supercompile supercompile.icl /^supercompile\>/
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