Verified Commit aef20aed authored by Camil Staps's avatar Camil Staps 🚀

Add framework for hyperstrict deserialization (#75)

parent c852721a
......@@ -3,8 +3,8 @@ definition module ABC.Interpreter
from StdMaybe import :: Maybe
:: DeserializationSettings =
{ heap_size :: !Int //* Heap size for the interpreter, in bytes
, stack_size :: !Int //* Stack size for the interpreter, in bytes
{ heap_size :: !Int //* Heap size for the interpreter, in bytes (default: 2M)
, stack_size :: !Int //* Stack size for the interpreter, in bytes (default: 1M in total; 500k for A and 500k for BC stack)
}
defaultDeserializationSettings :: DeserializationSettings
......@@ -14,8 +14,21 @@ defaultDeserializationSettings :: DeserializationSettings
:: InterpretedExpression
:: *InterpretationEnvironment
:: DeserializedValue a
= DV_ParseError
| DV_HeapFull
| DV_StackOverflow
| DV_Halt
| DV_IllegalInstruction
| DV_HostHeapFull
| DV_Ok a
serialize_for_interpretation :: a !String !*World -> *(!Maybe SerializedGraph, !*World)
deserialize :: !DeserializationSettings !SerializedGraph !String !*World -> *(Maybe a, !*World)
deserializeStrict :: !DeserializationSettings !SerializedGraph !String !*World
-> *(!DeserializedValue a, !*World)
get_start_rule_as_expression :: !DeserializationSettings !String !String !*World -> *(Maybe a, !*World)
graphToString :: !*SerializedGraph -> *(!.String, !*SerializedGraph)
......
......@@ -75,7 +75,16 @@ where
}
deserialize :: !DeserializationSettings !SerializedGraph !String !*World -> *(Maybe a, !*World)
deserialize dsets {graph,descinfo,modules,bytecode} thisexe w
deserialize dsets graph thisexe w = deserialize` False dsets graph thisexe w
deserializeStrict :: !DeserializationSettings !SerializedGraph !String !*World
-> *(!DeserializedValue a, !*World)
deserializeStrict dsets graph thisexe w = case deserialize` True dsets graph thisexe w of
(Nothing,w) -> (DV_ParseError,w)
(Just v,w) -> (v,w)
deserialize` :: !Bool !DeserializationSettings !SerializedGraph !String !*World -> *(Maybe a, !*World)
deserialize` strict dsets {graph,descinfo,modules,bytecode} thisexe w
# (host_syms,w) = accFiles (read_symbols thisexe) w
# pgm = parse host_syms bytecode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment