Safe Haskell | None |
---|
Names used in the Disciple Core Salt language profile.
- data Name
- data PrimTyCon
- primTyConIsIntegral :: PrimTyCon -> Bool
- primTyConIsFloating :: PrimTyCon -> Bool
- primTyConIsUnsigned :: PrimTyCon -> Bool
- primTyConIsSigned :: PrimTyCon -> Bool
- primTyConWidth :: Platform -> PrimTyCon -> Maybe Integer
- data PrimOp
- data PrimArith
- = PrimArithNeg
- | PrimArithAdd
- | PrimArithSub
- | PrimArithMul
- | PrimArithDiv
- | PrimArithRem
- | PrimArithEq
- | PrimArithNeq
- | PrimArithGt
- | PrimArithGe
- | PrimArithLt
- | PrimArithLe
- | PrimArithAnd
- | PrimArithOr
- | PrimArithShl
- | PrimArithShr
- | PrimArithBAnd
- | PrimArithBOr
- | PrimArithBXOr
- data PrimCast
- primCastPromoteIsValid :: Platform -> PrimTyCon -> PrimTyCon -> Bool
- primCastTruncateIsValid :: Platform -> PrimTyCon -> PrimTyCon -> Bool
- data PrimStore
- = PrimStoreSize
- | PrimStoreSize2
- | PrimStoreCreate
- | PrimStoreCheck
- | PrimStoreRecover
- | PrimStoreAlloc
- | PrimStoreRead
- | PrimStoreWrite
- | PrimStorePlusAddr
- | PrimStoreMinusAddr
- | PrimStorePeek
- | PrimStorePoke
- | PrimStorePlusPtr
- | PrimStoreMinusPtr
- | PrimStoreMakePtr
- | PrimStoreTakePtr
- | PrimStoreCastPtr
- data PrimCall = PrimCallTail Int
- data PrimControl
- readName :: String -> Maybe Name
- sanitizeName :: String -> String
- sanitizeGlobal :: String -> String
- sanitizeLocal :: String -> String
Documentation
Names of things used in Disciple Core Salt.
NameVar String | A type or value variable. |
NameCon String | Constructor names. |
NameObjTyCon | The abstract heap object type constructor. |
NamePrimTyCon PrimTyCon | A primitive type constructor. |
NamePrimOp PrimOp | A primitive operator. |
NameLitVoid | The void literal. |
NameLitBool Bool | A boolean literal. |
NameLitNat Integer | A natural number literal. |
NameLitInt Integer | An integer number literal. |
NameLitTag Integer | A constructor tag literal. |
NameLitWord Integer Int | A |
Primitive Type Constructors
Primitive type constructors.
PrimTyConVoid |
|
PrimTyConBool |
|
PrimTyConNat |
|
PrimTyConInt |
|
PrimTyConWord Int |
|
PrimTyConFloat Int |
|
PrimTyConTag |
|
PrimTyConAddr |
|
PrimTyConPtr |
|
PrimTyConString |
These are primitive until we can define our own unboxed types. |
primTyConIsFloating :: PrimTyCon -> BoolSource
Floating point constructors.
These are FloatN
.
primTyConIsUnsigned :: PrimTyCon -> BoolSource
Unsigned integral constructors.
These are Bool
Nat
WordN
Tag
.
primTyConIsSigned :: PrimTyCon -> BoolSource
Signed integral constructors.
This is just Int
.
primTyConWidth :: Platform -> PrimTyCon -> Maybe IntegerSource
Get the representation width of a primitive type constructor, in bits. This is how much space it takes up in an object payload.
Bools are representable with a single bit, but we unpack them into a whole word.
The abstract constructors Void
and String
have no width.
Primitive Operators
Primitive operators implemented directly by the machine or runtime system.
PrimArith PrimArith | Arithmetic, logic, comparison and bit-wise operators. |
PrimCast PrimCast | Casting between numeric types. |
PrimStore PrimStore | Raw store access. |
PrimCall PrimCall | Special function calling conventions. |
PrimControl PrimControl | Non-functional control flow. |
Primitive arithmetic, logic, and comparison opretors. We expect the backend/machine to be able to implement these directly.
For the Shift Right operator, the type that it is used at determines whether it is an arithmetic (with sign-extension) or logical (no sign-extension) shift.
PrimArithNeg | Negation |
PrimArithAdd | Addition |
PrimArithSub | Subtraction |
PrimArithMul | Multiplication |
PrimArithDiv | Division |
PrimArithRem | Remainder |
PrimArithEq | Equality |
PrimArithNeq | Negated Equality |
PrimArithGt | Greater Than |
PrimArithGe | Greater Than or Equal |
PrimArithLt | Less Than |
PrimArithLe | Less Than or Equal |
PrimArithAnd | Boolean And |
PrimArithOr | Boolean Or |
PrimArithShl | Shift Left |
PrimArithShr | Shift Right |
PrimArithBAnd | Bit-wise And |
PrimArithBOr | Bit-wise Or |
PrimArithBXOr | Bit-wise eXclusive Or |
Primitive cast between two types.
The exact set of available casts is determined by the target platform.
For example, you can only promote a Nat#
to a Word32#
on a 32-bit
system. On a 64-bit system the Nat#
type is 64-bits wide, so casting it
to a Word32#
would be a truncation.
PrimCastPromote | Promote a value to one of similar or larger width, without loss of precision. |
PrimCastTruncate | Truncate a value to a new width, possibly losing precision. |
Check for a valid promotion primop.
Check for valid truncation primop.
Raw access to the store.
PrimStoreSize | Number of bytes needed to store a value of a primitive type. |
PrimStoreSize2 | Log2 of number of bytes need to store a value of a primitive type. |
PrimStoreCreate | Create a heap of the given size.
This must be called before |
PrimStoreCheck | Check whether there are at least this many bytes still available on the heap. |
PrimStoreRecover | Force a garbage collection to recover at least this many bytes. |
PrimStoreAlloc | Allocate some space on the heap. There must be enough space available, else undefined. |
PrimStoreRead | Read a value from the store at the given address and offset. |
PrimStoreWrite | Write a value to the store at the given address and offset. |
PrimStorePlusAddr | Add an offset in bytes to an address. |
PrimStoreMinusAddr | Subtract an offset in bytes from an address. |
PrimStorePeek | Read a value from a pointer plus the given offset. |
PrimStorePoke | Write a value to a pointer plus the given offset. |
PrimStorePlusPtr | Add an offset in bytes to a pointer. |
PrimStoreMinusPtr | Subtract an offset in bytes from a pointer. |
PrimStoreMakePtr | Convert an raw address to a pointer. |
PrimStoreTakePtr | Convert a pointer to a raw address. |
PrimStoreCastPtr | Cast between pointer types. |
Primitive ways of invoking a function, where control flow returns back to the caller.
PrimCallTail Int | Tailcall a function |
data PrimControl Source
Primitive non-returning control flow.
PrimControlFail | Ungraceful failure -- just abort the program. This is called on internal errors in the runtime system. There is no further debugging info provided, so you'll need to look at the stack trace to debug it. |
PrimControlReturn | Return from the enclosing function with the given value. |
Name Parsing
Name Sanitisation
sanitizeName :: String -> StringSource
Rewrite the symbols in a name to make it safe to export as an external
symbol. For example, a names containing a &
is prefixed with _sym_
and the &
replzced by ZAn
. Literal Z
s in a symbolic name are doubled
to ZZ
.
sanitizeGlobal :: String -> StringSource
Like sanitizeGlobal
but indicate that the name is going to be visible
globally.
sanitizeLocal :: String -> StringSource
Like sanitizeName
but at add an extra '_' prefix.
This is used for function-local names so that they do not conflict
with globally-visible ones.