-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Commands.Dev.Casm.FromCairo where | ||
|
||
import Commands.Base | ||
import Commands.Dev.Casm.FromCairo.Options | ||
import Data.Aeson | ||
import Data.ByteString.Lazy qualified as BS | ||
import Juvix.Compiler.Backend.Cairo.Extra.Deserialization qualified as Cairo | ||
import Juvix.Compiler.Casm.Data.Result qualified as Casm | ||
import Juvix.Compiler.Casm.Pretty qualified as Casm | ||
import Juvix.Compiler.Casm.Translation.FromCairo qualified as Casm | ||
|
||
runCommand :: forall r. (Members '[EmbedIO, App] r) => CasmFromCairoOptions -> Sem r () | ||
runCommand opts = do | ||
afile :: Path Abs File <- fromAppPathFile file | ||
bs <- liftIO $ BS.readFile (toFilePath afile) | ||
case decode bs of | ||
Just r -> do | ||
let Casm.Result {..} = Casm.fromCairo (Cairo.deserialize r) | ||
renderStdOut (Casm.ppProgram _resultCode) | ||
Nothing -> | ||
exitMsg (ExitFailure 1) "error reading input file" | ||
where | ||
file :: AppPath File | ||
file = opts ^. casmFromCairoInputFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Commands.Dev.Casm.FromCairo.Options where | ||
|
||
import CommonOptions | ||
|
||
newtype CasmFromCairoOptions = CasmFromCairoOptions | ||
{ _casmFromCairoInputFile :: AppPath File | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''CasmFromCairoOptions | ||
|
||
parseCasmFromCairoOptions :: Parser CasmFromCairoOptions | ||
parseCasmFromCairoOptions = do | ||
_casmFromCairoInputFile <- parseInputFile FileExtJson | ||
pure CasmFromCairoOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters