blob: dd8bef187307ef932facfecf662ce3a68a6a7067 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
definition module Snug.Compile
from Control.Monad.State import :: StateT
from Data.Error import :: MaybeError
from Data.Map import :: Map
from MIPS.MIPS32 import :: Line
from Snug.Syntax import :: ConstructorDef, :: ConstructorIdent, :: Definition,
:: SymbolIdent, :: Type
:: Namespace :== String
:: Namespaced id =
{ ns :: !Namespace
, id :: !id
}
:: Globals =
{ constructors :: !Map (Namespaced ConstructorIdent) ConstructorDef
, functions :: !Map (Namespaced SymbolIdent) FunctionInfo
}
:: FunctionInfo =
{ arity :: !Int
, type :: !Type
}
:: CompileM a :== StateT CompileState (MaybeError String) a
:: CompileState
:: Locals :== Map SymbolIdent Symbol
:: Symbol
= LocalSymbol !LocalLocation
| FunctionSymbol !FunctionInfo
| ConstructorSymbol !ConstructorDef
:: LocalLocation
compile :: !Namespace ![Definition] -> MaybeError String [Line]
lookupConstructorM :: !ConstructorIdent -> CompileM ConstructorDef
|