diff --git a/app/elm/Compiler/Ast.elm b/app/elm/Compiler/Ast.elm index e973ff3..eaae38d 100644 --- a/app/elm/Compiler/Ast.elm +++ b/app/elm/Compiler/Ast.elm @@ -837,14 +837,14 @@ compile context node = [ Instruction.Raise error ] -compileProgram : Program -> CompiledProgram -compileProgram { functions, body } = +compileProgram : Context -> Program -> CompiledProgram +compileProgram context { functions, body } = let compiledFunctions = List.map compileFunction functions instructions = - List.concatMap (compileInContext Statement) body + List.concatMap (compileInContext context) body in { instructions = instructions , compiledFunctions = compiledFunctions diff --git a/app/elm/Logo.elm b/app/elm/Logo.elm index 890acdb..507d267 100644 --- a/app/elm/Logo.elm +++ b/app/elm/Logo.elm @@ -11,7 +11,7 @@ module Logo exposing , step ) -import Compiler.Ast as Ast +import Compiler.Ast as Ast exposing (Context(..)) import Compiler.Linker as Linker import Compiler.Parser as Parser import Dict @@ -73,7 +73,7 @@ compile program logo = program |> Parser.run parser |> Result.mapError ParseError - |> Result.map Ast.compileProgram + |> Result.map (Ast.compileProgram Statement) result = compiledProgram diff --git a/app/elm/StandardLibrary.elm b/app/elm/StandardLibrary.elm index 5989dca..ab1256b 100644 --- a/app/elm/StandardLibrary.elm +++ b/app/elm/StandardLibrary.elm @@ -1,6 +1,6 @@ module StandardLibrary exposing (compiledFunctions) -import Compiler.Ast as Ast exposing (CompiledFunction) +import Compiler.Ast as Ast exposing (CompiledFunction, Context(..)) import Compiler.Parser as Parser import Dict import Parser.Advanced as Parser @@ -45,7 +45,7 @@ compiledFunctions = compiledProgram = functions |> Parser.run parser - |> Result.map Ast.compileProgram + |> Result.map (Ast.compileProgram Statement) in compiledProgram |> Result.map .compiledFunctions diff --git a/app/elm/Vm/Vm.elm b/app/elm/Vm/Vm.elm index 98888be..fc8e88c 100644 --- a/app/elm/Vm/Vm.elm +++ b/app/elm/Vm/Vm.elm @@ -16,7 +16,7 @@ machine as well as functions for running it. -} import Array exposing (Array) -import Compiler.Ast as Ast exposing (CompiledFunction, CompiledProgram, Program) +import Compiler.Ast as Ast exposing (CompiledFunction, CompiledProgram, Context(..), Program) import Compiler.Linker as Linker exposing (LinkedProgram) import Compiler.Parser as Parser exposing (Parser) import Dict exposing (Dict) @@ -489,7 +489,7 @@ parseAndCompileProgram : Parser Program -> String -> Result Error CompiledProgra parseAndCompileProgram parser = Parser.run parser >> Result.mapError (always <| Internal ParsingFailed) - >> Result.map Ast.compileProgram + >> Result.map (Ast.compileProgram Statement) parseAndEvalInstructions : Vm -> List Type.Value -> Result Error Vm