YhcSource codeContentsIndex
DotNet.IL
Description
The IL module declares all the data structures necessary for generating and writing IL code.
Synopsis
data ILDecl
= Namespace {
ilName :: ILName
nsDecls :: [ILDecl]
}
| Class {
ilName :: ILName
classBase :: TypeSignature
classDecls :: [ILClassDecl]
}
| Prim {
pName :: Id
pPos :: Pos
}
| External {
xName :: Id
xPos :: Pos
xArity :: Int
xCName :: String
xCallConv :: CallConv
xType :: NewType
}
type ILName = String
data ILAccess
= ILPublic
| ILPrivate
data ILStorage
= ILStatic
| ILInstance
| ILVirtual
data ILClassDecl
= ILClassField ILAccess ILStorage TypeSignature ILName
| ILClassConstr ILAccess ILStorage [ILMethodArg] [TypeSignature] [ILInstruction]
| ILClassMethod ILAccess ILStorage TypeSignature ILName [ILMethodArg] [TypeSignature] [ILInstruction]
data ILMethodArg = ILMethodArg TypeSignature ILName
data GType
= GCAF
| GFUN
| GFUN0
| GCON
| GZCON
| GPRIM
| GEXT
type CRef = Int
data Code
= CLinear [(ILInstruction, UseSet)]
| CGraph GLabel Graph Jumpers
| CWrites [Write]
data GraphNode
= GLinear [UseIns] Bool GLabel
| GCase Bool [(Tag, GLabel)] (Maybe GLabel)
| GIf GLabel GLabel
| GReturn
| GDead
type Graph = Map GLabel GraphNode
type Jumpers = Map GLabel (Set GLabel)
data GLabel = GLabel Label
data Write
= WUByte Int
| WUShort Int
| WLabel Int Label
| WByte Int
| WShort Int
data UseSet = UseSet {
useDepth :: Int
useGive :: [Id]
useNeed :: (Set Id)
}
emptyUS :: UseSet
type Tag = Int
type Label = Int
data TypeSignature
= ClassSignature String String
| ValueSignature String String
| Int32Signature
| CharSignature
| DoubleSignature
| FloatSignature
| BoolSignature
| VoidSignature
data ILInstruction
= LDC_I4 Int
| LDC_R4 Float
| LDC_R8 Double
| LDSTR String
| LDTOKEN TypeSignature
| LDTOKEN_METHOD TypeSignature TypeSignature String [TypeSignature]
| LDLOC Int
| STLOC Int
| LDARG Int
| STARG Int
| LDSFLD TypeSignature TypeSignature String
| STSFLD TypeSignature TypeSignature String
| LDFLD TypeSignature TypeSignature String
| STFLD TypeSignature TypeSignature String
| NEWOBJ TypeSignature [TypeSignature]
| BEQ Label
| BNE Label
| BRTRUE Label
| BRFALSE Label
| BR Label
| CALL TypeSignature TypeSignature String [TypeSignature]
| CALLCLASS TypeSignature TypeSignature String [TypeSignature]
| CALLVIRT TypeSignature TypeSignature String [TypeSignature]
| TAIL
| RET
| THROW
| LABEL Label
| ISINST TypeSignature
| DUP
| POP
| ADD
| SUB
| MUL
| DIV
| REM
| CEQ
| CLT
| CGT
| NEG
| NOT
data PrimOp
= OpWord
| OpFloat
| OpDouble
type UseIns = (ILInstruction, UseSet)
Documentation
data ILDecl
A Declaration is a top level IL entry
Constructors
Namespace
ilName :: ILName
nsDecls :: [ILDecl]
Class
ilName :: ILName
classBase :: TypeSignature
classDecls :: [ILClassDecl]
Prim
pName :: Id
pPos :: Pos
External
xName :: Id
xPos :: Pos
xArity :: Int
xCName :: String
xCallConv :: CallConv
xType :: NewType
type ILName = String
data ILAccess
Constructors
ILPublic
ILPrivate
show/hide Instances
data ILStorage
Constructors
ILStatic
ILInstance
ILVirtual
show/hide Instances
data ILClassDecl
Constructors
ILClassField ILAccess ILStorage TypeSignature ILName
ILClassConstr ILAccess ILStorage [ILMethodArg] [TypeSignature] [ILInstruction]
ILClassMethod ILAccess ILStorage TypeSignature ILName [ILMethodArg] [TypeSignature] [ILInstruction]
data ILMethodArg
Constructors
ILMethodArg TypeSignature ILName
data GType
common applicative form, function info, node for non-CAF, constructor info, node for zero arity constructor, primitive function info
Constructors
GCAF
GFUN
GFUN0
GCON
GZCON
GPRIM
GEXT
show/hide Instances
Eq GType
Ord GType
Show GType
type CRef = Int
A constant table maps constant references to constant items
data Code
code can be several things: either a simple list of instructions or a code flow graph
Constructors
CLinear [(ILInstruction, UseSet)]
CGraph GLabel Graph Jumpers
CWrites [Write]
data GraphNode
Constructors
GLinear [UseIns] Bool GLabel
GCase Bool [(Tag, GLabel)] (Maybe GLabel)
GIf GLabel GLabel
GReturn
GDead
type Graph = Map GLabel GraphNode
a graph associates labels with graph nodes
type Jumpers = Map GLabel (Set GLabel)
Jumpers lists for each label all the graph nodes that might jump to it
data GLabel
a graph label, just wraps a label, helps with typechecking and we can sort the other way round
Constructors
GLabel Label
show/hide Instances
Eq GLabel
Ord GLabel
Show GLabel
data Write
a write is a data section that should be written to the final bytecode file, Label is used as a placeholder
Constructors
WUByte Int
WUShort Int
WLabel Int Label
WByte Int
WShort Int
data UseSet
the use set for an instruction lists the variables that the instructions gives as well as those that it needs, from this we can calculate what should be zapped.
Constructors
UseSet
useDepth :: Int
useGive :: [Id]
useNeed :: (Set Id)
emptyUS :: UseSet
type Tag = Int
type Label = Int
data TypeSignature
Constructors
ClassSignature String String
ValueSignature String String
Int32Signature
CharSignature
DoubleSignature
FloatSignature
BoolSignature
VoidSignature
show/hide Instances
data ILInstruction
The instructions
Constructors
LDC_I4 Int
LDC_R4 Float
LDC_R8 Double
LDSTR String
LDTOKEN TypeSignature
LDTOKEN_METHOD TypeSignature TypeSignature String [TypeSignature]
LDLOC Int
STLOC Int
LDARG Int
STARG Int
LDSFLD TypeSignature TypeSignature String
STSFLD TypeSignature TypeSignature String
LDFLD TypeSignature TypeSignature String
STFLD TypeSignature TypeSignature String
NEWOBJ TypeSignature [TypeSignature]
BEQ Label
BNE Label
BRTRUE Label
BRFALSE Label
BR Label
CALL TypeSignature TypeSignature String [TypeSignature]
CALLCLASS TypeSignature TypeSignature String [TypeSignature]
CALLVIRT TypeSignature TypeSignature String [TypeSignature]
TAIL
RET
THROW
LABEL Label
ISINST TypeSignature
DUP
POP
ADD
SUB
MUL
DIV
REM
CEQ
CLT
CGT
NEG
NOT
show/hide Instances
data PrimOp
Constructors
OpWord
OpFloat
OpDouble
show/hide Instances
Eq PrimOp
Ord PrimOp
Show PrimOp
type UseIns = (ILInstruction, UseSet)
Produced by Haddock version 0.8