diff --git a/implement/elm-time/ElmTime/compile-elm-program/src/ElmCompiler.elm b/implement/elm-time/ElmTime/compile-elm-program/src/ElmCompiler.elm index 740f15d5..acf34266 100644 --- a/implement/elm-time/ElmTime/compile-elm-program/src/ElmCompiler.elm +++ b/implement/elm-time/ElmTime/compile-elm-program/src/ElmCompiler.elm @@ -22,7 +22,6 @@ import FirCompiler , Expression(..) , ModuleImports , countListElementsExpression - , emitExpressionInDeclarationBlock , emitWrapperForPartialApplication , equalCondition , equalCondition_Pine @@ -1807,35 +1806,90 @@ getDeclarationValueFromCompilation ( localModuleName, nameInModule ) compilation canonicalModuleName = Dict.get localModuleName compilation.moduleAliases |> Maybe.withDefault localModuleName - in - case compilation.availableModules |> Dict.get canonicalModuleName of - Nothing -> - Err - ("Did not find module '" - ++ String.join "." canonicalModuleName - ++ "'. There are " - ++ (String.fromInt (Dict.size compilation.availableModules) - ++ " declarations in this scope: " - ++ String.join ", " (List.map (String.join ".") (Dict.keys compilation.availableModules)) - ) - ) - Just moduleValue -> - case Dict.get nameInModule moduleValue.declarations of + continueWithDefault () = + case compilation.availableModules |> Dict.get canonicalModuleName of Nothing -> Err - ("Did not find '" - ++ nameInModule - ++ "' in module '" + ("Did not find module '" ++ String.join "." canonicalModuleName ++ "'. There are " - ++ String.fromInt (Dict.size moduleValue.declarations) - ++ " names available in that module: " - ++ String.join ", " (Dict.keys moduleValue.declarations) + ++ (String.fromInt (Dict.size compilation.availableModules) + ++ " declarations in this scope: " + ++ String.join ", " (List.map (String.join ".") (Dict.keys compilation.availableModules)) + ) ) - Just declarationValue -> - Ok declarationValue + Just moduleValue -> + case Dict.get nameInModule moduleValue.declarations of + Nothing -> + Err + ("Did not find '" + ++ nameInModule + ++ "' in module '" + ++ String.join "." canonicalModuleName + ++ "'. There are " + ++ String.fromInt (Dict.size moduleValue.declarations) + ++ " names available in that module: " + ++ String.join ", " (Dict.keys moduleValue.declarations) + ) + + Just declarationValue -> + Ok declarationValue + in + case Dict.get canonicalModuleName getDeclarationValueFromCompilationOverrides of + Nothing -> + continueWithDefault () + + Just overrides -> + case Dict.get nameInModule overrides of + Just overrideValue -> + overrideValue + + Nothing -> + continueWithDefault () + + +getDeclarationValueFromCompilationOverrides : Dict.Dict (List String) (Dict.Dict String (Result String Pine.Value)) +getDeclarationValueFromCompilationOverrides = + [ ( [ "Debug" ] + , [ ( "log" + -- TODO: mapping for Debug.log so we can get messages. + , FunctionExpression + [ [ ( "message", [] ) ], [ ( "payload", [] ) ] ] + (ReferenceExpression "payload") + |> FirCompiler.emitExpression + { moduleImports = + { importedModules = Dict.empty + , importedDeclarations = Dict.empty + } + , declarationsDependencies = Dict.empty + , environmentFunctions = [] + , environmentDeconstructions = Dict.empty + } + |> Result.andThen evaluateAsIndependentExpression + ) + , ( "toString" + -- TODO: mapping for Debug.toString + , FunctionExpression + [ [ ( "elm_value", [] ) ] ] + (LiteralExpression (valueFromString "Debug.toString is not implemented yet")) + |> FirCompiler.emitExpression + { moduleImports = + { importedModules = Dict.empty + , importedDeclarations = Dict.empty + } + , declarationsDependencies = Dict.empty + , environmentFunctions = [] + , environmentDeconstructions = Dict.empty + } + |> Result.andThen evaluateAsIndependentExpression + ) + ] + |> Dict.fromList + ) + ] + |> Dict.fromList compileLookupForInlineableDeclaration : ( List String, String ) -> Pine.Value -> Expression @@ -1886,7 +1940,7 @@ emitModuleDeclarations : emitModuleDeclarations stackBefore declarations = declarations.supportingDeclarations |> Dict.union declarations.exposedDeclarations - |> emitExpressionInDeclarationBlock stackBefore + |> FirCompiler.emitExpressionInDeclarationBlock stackBefore |> (\builder -> declarations.exposedDeclarations |> Dict.toList diff --git a/implement/elm-time/Program.cs b/implement/elm-time/Program.cs index 129fc17d..a77c648f 100644 --- a/implement/elm-time/Program.cs +++ b/implement/elm-time/Program.cs @@ -18,7 +18,7 @@ namespace ElmTime; public class Program { - public static string AppVersionId => "2023-12-31"; + public static string AppVersionId => "2024-01-01"; private static int AdminInterfaceDefaultPort => 4000; diff --git a/implement/elm-time/elm-time.csproj b/implement/elm-time/elm-time.csproj index 37a62640..95681706 100644 --- a/implement/elm-time/elm-time.csproj +++ b/implement/elm-time/elm-time.csproj @@ -5,8 +5,8 @@ net8.0 ElmTime elm-time - 2023.1231.0.0 - 2023.1231.0.0 + 2024.0101.0.0 + 2024.0101.0.0 enable true diff --git a/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/expected-value.txt b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/expected-value.txt new file mode 100644 index 00000000..b43f14c4 --- /dev/null +++ b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/expected-value.txt @@ -0,0 +1 @@ +"payload" \ No newline at end of file diff --git a/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/submission.txt b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/submission.txt new file mode 100644 index 00000000..6bbcbc7c --- /dev/null +++ b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/110/submission.txt @@ -0,0 +1 @@ +Debug.log "testing debug message" "payload" \ No newline at end of file diff --git a/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/expected-value.txt b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/expected-value.txt new file mode 100644 index 00000000..26d5a365 --- /dev/null +++ b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/expected-value.txt @@ -0,0 +1 @@ +"Debug.toString is not implemented yet" \ No newline at end of file diff --git a/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/submission.txt b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/submission.txt new file mode 100644 index 00000000..8ec113de --- /dev/null +++ b/implement/test-and-train/elm-interactive-scenarios-core/elm-core-debug/steps/210/submission.txt @@ -0,0 +1 @@ +Debug.toString [ 11, 13, 17, 19 ] \ No newline at end of file