{-|
Module      : Htcc.Asm
Description : The modules of C Rules
Copyright   : (c) roki, 2019
License     : MIT
Maintainer  : falgon53@yahoo.co.jp
Stability   : experimental
Portability : POSIX

The executable module for compilation
-}
module Htcc.Asm (
    -- * Export modules
    module Htcc.Asm.Generate,
    casm
) where

import           Data.Tuple.Extra                                      (uncurry3)

import           Htcc.Asm.Generate
import qualified Htcc.Asm.Intrinsic.Operand                            as O
import qualified Htcc.Asm.Intrinsic.Structure.Internal                 as SI
import qualified Htcc.Asm.Intrinsic.Structure.Section.Text.Instruction as TI
import           Htcc.Parser                                           (ASTs)
import           Htcc.Parser.ConstructionData.Scope.Var                (GlobalVars,
                                                                        Literals)

-- | Generate full assembly code from string of C source code
casm :: (O.IsOperand i, TI.UnaryInstruction i, TI.BinaryInstruction i, Integral i) => (ASTs i, GlobalVars i, Literals i) -> IO ()
casm :: (ASTs i, GlobalVars i, Literals i) -> IO ()
casm = Asm AsmCodeCtx Integer () -> IO ()
forall e a. (Num e, Enum e) => Asm AsmCodeCtx e a -> IO a
SI.runAsm (Asm AsmCodeCtx Integer () -> IO ())
-> ((ASTs i, GlobalVars i, Literals i)
    -> Asm AsmCodeCtx Integer ())
-> (ASTs i, GlobalVars i, Literals i)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ASTs i -> GlobalVars i -> Literals i -> Asm AsmCodeCtx Integer ())
-> (ASTs i, GlobalVars i, Literals i) -> Asm AsmCodeCtx Integer ()
forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 ASTs i -> GlobalVars i -> Literals i -> Asm AsmCodeCtx Integer ()
forall e i.
(Integral e, Show e, Integral i, IsOperand i, UnaryInstruction i,
 BinaryInstruction i) =>
ASTs i -> GlobalVars i -> Literals i -> Asm AsmCodeCtx e ()
casm'