diff --git a/bin/print_instructions.ml b/bin/print_instructions.ml index 9d0fd46..bef48fc 100644 --- a/bin/print_instructions.ml +++ b/bin/print_instructions.ml @@ -23,17 +23,16 @@ let main = Printexc.record_backtrace false; let directory = Sys.argv.(1) in - let root = Sys.argv.(2) in + let root = try Sys.argv.(2) with Invalid_argument _ -> "" in let sources = get_sources_from ~directory () in + let ast = sources |> Parser.get_ast ~include_stdlib:false in + let ast = + match root with + | "" -> ast + | root -> ast |> StringMap.find root |> StringMap.singleton root + in try - let bytecode = - sources - |> Parser.get_ast ~include_stdlib:false - |> StringMap.find root - |> StringMap.singleton root - |> Compiler.compile - |> Bytecode.deserialize - in + let bytecode = ast |> Compiler.compile |> Bytecode.deserialize in Bytecode.pp Format.std_formatter bytecode with Diagnostics.Pinc_error _ -> exit 1 ;; diff --git a/test/vm/array/array_instructions.t b/test/vm/array/array_instructions.t index 889eca3..97d9fd2 100644 --- a/test/vm/array/array_instructions.t +++ b/test/vm/array/array_instructions.t @@ -1,20 +1,4 @@ - $ NO_COLOR="1" print_instructions . EmptyArray - [ - [CONSTANTS] - 0x00000000 (00000000) : 0 - 0x00000001 (00000001) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Array - 0006 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000001 (00000001) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . Array + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -38,45 +22,6 @@ 0000 I_Closure 0x00000006 (00000006) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . ExpressionArray - [ - [CONSTANTS] - 0x00000000 (00000000) : 1 - 0x00000001 (00000001) : 2 - 0x00000002 (00000002) : 3 - 0x00000003 (00000003) : 4 - 0x00000004 (00000004) : 5 - 0x00000005 (00000005) : 6 - 0x00000006 (00000006) : 7 - 0x00000007 (00000007) : 8 - 0x00000008 (00000008) : 4 - 0x00000009 (00000009) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Add - 0011 I_Constant 0x00000002 (00000002) - 0016 I_Constant 0x00000003 (00000003) - 0021 I_Sub - 0022 I_Constant 0x00000004 (00000004) - 0027 I_Constant 0x00000005 (00000005) - 0032 I_Mul - 0033 I_Constant 0x00000006 (00000006) - 0038 I_Constant 0x00000007 (00000007) - 0043 I_Div - 0044 I_Constant 0x00000008 (00000008) - 0049 I_Array - 0050 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000009 (00000009) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . ArrayAccess [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -116,9 +61,6 @@ 0000 I_Closure 0x0000000B (00000011) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . ArrayRange [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -134,9 +76,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . ArrayRangeInclusive [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -152,3 +91,49 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] + [ + [CONSTANTS] + 0x00000000 (00000000) : 0 + 0x00000001 (00000001) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Array + 0006 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : 1 + 0x00000001 (00000001) : 2 + 0x00000002 (00000002) : 3 + 0x00000003 (00000003) : 4 + 0x00000004 (00000004) : 5 + 0x00000005 (00000005) : 6 + 0x00000006 (00000006) : 7 + 0x00000007 (00000007) : 8 + 0x00000008 (00000008) : 4 + 0x00000009 (00000009) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Add + 0011 I_Constant 0x00000002 (00000002) + 0016 I_Constant 0x00000003 (00000003) + 0021 I_Sub + 0022 I_Constant 0x00000004 (00000004) + 0027 I_Constant 0x00000005 (00000005) + 0032 I_Mul + 0033 I_Constant 0x00000006 (00000006) + 0038 I_Constant 0x00000007 (00000007) + 0043 I_Div + 0044 I_Constant 0x00000008 (00000008) + 0049 I_Array + 0050 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000009 (00000009) (free variables: 0) + ] + diff --git a/test/vm/bindings/bindings_instructions.t b/test/vm/bindings/bindings_instructions.t index 1a44536..91d29b1 100644 --- a/test/vm/bindings/bindings_instructions.t +++ b/test/vm/bindings/bindings_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Let + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -19,34 +19,6 @@ 0000 I_Closure 0x00000001 (00000001) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Shadowing - [ - [CONSTANTS] - 0x00000000 (00000000) : 1 - 0x00000001 (00000001) : 1 - 0x00000002 (00000002) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Set_Local 0x00000000 (00000000) - 0010 I_Null - 0011 I_Pop - 0012 I_Get_Local 0x00000000 (00000000) - 0017 I_Constant 0x00000001 (00000001) - 0022 I_Add - 0023 I_Set_Local 0x00000001 (00000001) - 0028 I_Null - 0029 I_Pop - 0030 I_Get_Local 0x00000001 (00000001) - 0035 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) - ] - - - $ NO_COLOR="1" print_instructions . LocalBindings [ [CONSTANTS] 0x00000000 (00000000) : 21 @@ -72,8 +44,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . MutableBindings [ [CONSTANTS] 0x00000000 (00000000) : "wrong" @@ -147,3 +117,26 @@ 0000 I_Closure 0x0000000A (00000010) (free variables: 0) ] + [ + [CONSTANTS] + 0x00000000 (00000000) : 1 + 0x00000001 (00000001) : 1 + 0x00000002 (00000002) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Set_Local 0x00000000 (00000000) + 0010 I_Null + 0011 I_Pop + 0012 I_Get_Local 0x00000000 (00000000) + 0017 I_Constant 0x00000001 (00000001) + 0022 I_Add + 0023 I_Set_Local 0x00000001 (00000001) + 0028 I_Null + 0029 I_Pop + 0030 I_Get_Local 0x00000001 (00000001) + 0035 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + ] + diff --git a/test/vm/bool/bool_instructions.t b/test/vm/bool/bool_instructions.t index ef95888..bde57b9 100644 --- a/test/vm/bool/bool_instructions.t +++ b/test/vm/bool/bool_instructions.t @@ -1,32 +1,4 @@ - $ NO_COLOR="1" print_instructions . True - [ - [CONSTANTS] - 0x00000000 (00000000) : [ - 0000 I_True - 0001 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000000 (00000000) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . False - [ - [CONSTANTS] - 0x00000000 (00000000) : [ - 0000 I_False - 0001 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000000 (00000000) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . And + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : [ @@ -40,25 +12,6 @@ 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Or - [ - [CONSTANTS] - 0x00000000 (00000000) : [ - 0000 I_False - 0001 I_True - 0002 I_Or - 0003 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000000 (00000000) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . Equal [ [CONSTANTS] 0x00000000 (00000000) : 3 @@ -74,27 +27,17 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . NotEqual - [ + [ [CONSTANTS] - 0x00000000 (00000000) : 3 - 0x00000001 (00000001) : 5 - 0x00000002 (00000002) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Not_Equal - 0011 I_Return + 0x00000000 (00000000) : [ + 0000 I_False + 0001 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Greater [ [CONSTANTS] 0x00000000 (00000000) : 3 @@ -110,9 +53,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . GreaterEqual [ [CONSTANTS] 0x00000000 (00000000) : 3 @@ -128,9 +68,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Less [ [CONSTANTS] 0x00000000 (00000000) : 3 @@ -146,9 +83,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . LessEqual [ [CONSTANTS] 0x00000000 (00000000) : 3 @@ -164,9 +98,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Not [ [CONSTANTS] 0x00000000 (00000000) : [ @@ -179,3 +110,42 @@ 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] + [ + [CONSTANTS] + 0x00000000 (00000000) : 3 + 0x00000001 (00000001) : 5 + 0x00000002 (00000002) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Not_Equal + 0011 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_False + 0001 I_True + 0002 I_Or + 0003 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_True + 0001 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + ] + diff --git a/test/vm/builtin_functions/builtin_functions_instructions.t b/test/vm/builtin_functions/builtin_functions_instructions.t index 149bbcd..9b80cc6 100644 --- a/test/vm/builtin_functions/builtin_functions_instructions.t +++ b/test/vm/builtin_functions/builtin_functions_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . BuiltinFunctionArrayLength + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -26,8 +26,6 @@ 0000 I_Closure 0x00000005 (00000005) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . BuiltinFunctionStringLength [ [CONSTANTS] 0x00000000 (00000000) : "Hello, World!" @@ -46,8 +44,6 @@ 0000 I_Closure 0x00000001 (00000001) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . BuiltinFunctionStringSub [ [CONSTANTS] 0x00000000 (00000000) : "Hello, World!" diff --git a/test/vm/char/char_instructions.t b/test/vm/char/char_instructions.t index ad680b1..83ef86d 100644 --- a/test/vm/char/char_instructions.t +++ b/test/vm/char/char_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Char + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 'c' diff --git a/test/vm/conditionals/conditionals_instructions.t b/test/vm/conditionals/conditionals_instructions.t index b1d9bb8..195fea2 100644 --- a/test/vm/conditionals/conditionals_instructions.t +++ b/test/vm/conditionals/conditionals_instructions.t @@ -1,8 +1,8 @@ - $ NO_COLOR="1" print_instructions . IfTrue - [ + $ NO_COLOR="1" print_instructions . + [ [CONSTANTS] 0x00000000 (00000000) : [ - 0000 I_True + 0000 I_False 0001 I_Jump_If_False 0x00000004 (00000004) 0006 I_True 0007 I_Jump 0x00000005 (00000005) @@ -14,13 +14,10 @@ 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . IfTrueElse - [ + [ [CONSTANTS] 0x00000000 (00000000) : [ - 0000 I_True + 0000 I_False 0001 I_Jump_If_False 0x00000004 (00000004) 0006 I_True 0007 I_Jump 0x00000005 (00000005) @@ -32,13 +29,28 @@ 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . IfFalse - [ + [ + [CONSTANTS] + 0x00000000 (00000000) : 3 + 0x00000001 (00000001) : [ + 0000 I_True + 0001 I_Jump_If_False 0x00000006 (00000006) + 0006 I_Constant 0x00000000 (00000000) + 0011 I_Set_Local 0x00000000 (00000000) + 0016 I_Null + 0017 I_Jump 0x00000007 (00000007) + 0022 I_Null + 0023 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + ] + + [ [CONSTANTS] 0x00000000 (00000000) : [ - 0000 I_False + 0000 I_True 0001 I_Jump_If_False 0x00000004 (00000004) 0006 I_True 0007 I_Jump 0x00000005 (00000005) @@ -50,13 +62,10 @@ 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . IfFalseElse - [ + [ [CONSTANTS] 0x00000000 (00000000) : [ - 0000 I_False + 0000 I_True 0001 I_Jump_If_False 0x00000004 (00000004) 0006 I_True 0007 I_Jump 0x00000005 (00000005) diff --git a/test/vm/functions/functions_instructions.t b/test/vm/functions/functions_instructions.t index e2dc710..2da69d6 100644 --- a/test/vm/functions/functions_instructions.t +++ b/test/vm/functions/functions_instructions.t @@ -1,27 +1,4 @@ - $ NO_COLOR="1" print_instructions . FunctionEmpty - [ - [CONSTANTS] - 0x00000000 (00000000) : [ - 0000 I_Null - 0001 I_Return - ] - 0x00000001 (00000001) : [ - 0000 I_Closure 0x00000000 (00000000) (free variables: 0) - 0009 I_Set_Local 0x00000000 (00000000) - 0014 I_Null - 0015 I_Pop - 0016 I_Get_Local 0x00000000 (00000000) - 0021 I_Call 0 - 0026 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000001 (00000001) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . Function + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -54,107 +31,6 @@ 0000 I_Closure 0x00000003 (00000003) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . FunctionCurried - [ - [CONSTANTS] - 0x00000000 (00000000) : 1 - 0x00000001 (00000001) : 2 - 0x00000002 (00000002) : [ - 0000 I_True - 0001 I_Jump_If_False 0x00000004 (00000004) - 0006 I_Constant 0x00000000 (00000000) - 0011 I_Jump 0x00000005 (00000005) - 0016 I_Constant 0x00000001 (00000001) - 0021 I_Return - ] - 0x00000003 (00000003) : [ - 0000 I_Get_Free 0x00000000 (00000000) - 0005 I_Return - ] - 0x00000004 (00000004) : [ - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) - 0009 I_Set_Local 0x00000000 (00000000) - 0014 I_Null - 0015 I_Pop - 0016 I_Get_Local 0x00000000 (00000000) - 0021 I_Closure 0x00000003 (00000003) (free variables: 1) - 0030 I_Set_Local 0x00000001 (00000001) - 0035 I_Null - 0036 I_Pop - 0037 I_Get_Local 0x00000001 (00000001) - 0042 I_Call 0 - 0047 I_Call 0 - 0052 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000004 (00000004) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . FunctionScope - [ - [CONSTANTS] - 0x00000000 (00000000) : "123" - 0x00000001 (00000001) : 50 - 0x00000002 (00000002) : 1 - 0x00000003 (00000003) : [ - 0000 I_Constant 0x00000002 (00000002) - 0005 I_Set_Local 0x00000000 (00000000) - 0010 I_Null - 0011 I_Pop - 0012 I_Get_Free 0x00000000 (00000000) - 0017 I_Get_Local 0x00000000 (00000000) - 0022 I_Sub - 0023 I_Return - ] - 0x00000004 (00000004) : 2 - 0x00000005 (00000005) : [ - 0000 I_Constant 0x00000004 (00000004) - 0005 I_Set_Local 0x00000000 (00000000) - 0010 I_Null - 0011 I_Pop - 0012 I_Get_Free 0x00000000 (00000000) - 0017 I_Get_Local 0x00000000 (00000000) - 0022 I_Sub - 0023 I_Return - ] - 0x00000006 (00000006) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Set_Local 0x00000000 (00000000) - 0010 I_Null - 0011 I_Pop - 0012 I_Constant 0x00000001 (00000001) - 0017 I_Set_Local 0x00000001 (00000001) - 0022 I_Null - 0023 I_Pop - 0024 I_Get_Local 0x00000001 (00000001) - 0029 I_Closure 0x00000003 (00000003) (free variables: 1) - 0038 I_Set_Local 0x00000002 (00000002) - 0043 I_Null - 0044 I_Pop - 0045 I_Get_Local 0x00000001 (00000001) - 0050 I_Closure 0x00000005 (00000005) (free variables: 1) - 0059 I_Set_Local 0x00000003 (00000003) - 0064 I_Null - 0065 I_Pop - 0066 I_Get_Local 0x00000002 (00000002) - 0071 I_Call 0 - 0076 I_Get_Local 0x00000003 (00000003) - 0081 I_Call 0 - 0086 I_Add - 0087 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000006 (00000006) (free variables: 0) - ] - - - $ NO_COLOR="1" print_instructions . FunctionArguments [ [CONSTANTS] 0x00000000 (00000000) : [ @@ -201,8 +77,6 @@ 0000 I_Closure 0x00000005 (00000005) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . FunctionClosure [ [CONSTANTS] 0x00000000 (00000000) : 221 @@ -281,8 +155,225 @@ 0000 I_Closure 0x00000009 (00000009) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . RecursiveFunction + [ + [CONSTANTS] + 0x00000000 (00000000) : 1 + 0x00000001 (00000001) : 2 + 0x00000002 (00000002) : [ + 0000 I_True + 0001 I_Jump_If_False 0x00000004 (00000004) + 0006 I_Constant 0x00000000 (00000000) + 0011 I_Jump 0x00000005 (00000005) + 0016 I_Constant 0x00000001 (00000001) + 0021 I_Return + ] + 0x00000003 (00000003) : [ + 0000 I_Get_Free 0x00000000 (00000000) + 0005 I_Return + ] + 0x00000004 (00000004) : [ + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + 0009 I_Set_Local 0x00000000 (00000000) + 0014 I_Null + 0015 I_Pop + 0016 I_Get_Local 0x00000000 (00000000) + 0021 I_Closure 0x00000003 (00000003) (free variables: 1) + 0030 I_Set_Local 0x00000001 (00000001) + 0035 I_Null + 0036 I_Pop + 0037 I_Get_Local 0x00000001 (00000001) + 0042 I_Call 0 + 0047 I_Call 0 + 0052 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000004 (00000004) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_Null + 0001 I_Return + ] + 0x00000001 (00000001) : [ + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + 0009 I_Set_Local 0x00000000 (00000000) + 0014 I_Null + 0015 I_Pop + 0016 I_Get_Local 0x00000000 (00000000) + 0021 I_Call 0 + 0026 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : "123" + 0x00000001 (00000001) : 50 + 0x00000002 (00000002) : 1 + 0x00000003 (00000003) : [ + 0000 I_Constant 0x00000002 (00000002) + 0005 I_Set_Local 0x00000000 (00000000) + 0010 I_Null + 0011 I_Pop + 0012 I_Get_Free 0x00000000 (00000000) + 0017 I_Get_Local 0x00000000 (00000000) + 0022 I_Sub + 0023 I_Return + ] + 0x00000004 (00000004) : 2 + 0x00000005 (00000005) : [ + 0000 I_Constant 0x00000004 (00000004) + 0005 I_Set_Local 0x00000000 (00000000) + 0010 I_Null + 0011 I_Pop + 0012 I_Get_Free 0x00000000 (00000000) + 0017 I_Get_Local 0x00000000 (00000000) + 0022 I_Sub + 0023 I_Return + ] + 0x00000006 (00000006) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Set_Local 0x00000000 (00000000) + 0010 I_Null + 0011 I_Pop + 0012 I_Constant 0x00000001 (00000001) + 0017 I_Set_Local 0x00000001 (00000001) + 0022 I_Null + 0023 I_Pop + 0024 I_Get_Local 0x00000001 (00000001) + 0029 I_Closure 0x00000003 (00000003) (free variables: 1) + 0038 I_Set_Local 0x00000002 (00000002) + 0043 I_Null + 0044 I_Pop + 0045 I_Get_Local 0x00000001 (00000001) + 0050 I_Closure 0x00000005 (00000005) (free variables: 1) + 0059 I_Set_Local 0x00000003 (00000003) + 0064 I_Null + 0065 I_Pop + 0066 I_Get_Local 0x00000002 (00000002) + 0071 I_Call 0 + 0076 I_Get_Local 0x00000003 (00000003) + 0081 I_Call 0 + 0086 I_Add + 0087 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000006 (00000006) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_Get_Local 0x00000000 (00000000) + 0005 I_Get_Local 0x00000001 (00000001) + 0010 I_Add + 0011 I_Return + ] + 0x00000001 (00000001) : 4 + 0x00000002 (00000002) : [ + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + 0009 I_Set_Local 0x00000000 (00000000) + 0014 I_Null + 0015 I_Pop + 0016 I_Get_Local 0x00000000 (00000000) + 0021 I_Constant 0x00000001 (00000001) + 0026 I_Call 1 + 0031 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_Get_Local 0x00000000 (00000000) + 0005 I_Get_Local 0x00000001 (00000001) + 0010 I_Add + 0011 I_Return + ] + 0x00000001 (00000001) : 4 + 0x00000002 (00000002) : 5 + 0x00000003 (00000003) : 6 + 0x00000004 (00000004) : [ + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + 0009 I_Set_Local 0x00000000 (00000000) + 0014 I_Null + 0015 I_Pop + 0016 I_Get_Local 0x00000000 (00000000) + 0021 I_Constant 0x00000001 (00000001) + 0026 I_Constant 0x00000002 (00000002) + 0031 I_Constant 0x00000003 (00000003) + 0036 I_Call 3 + 0041 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000004 (00000004) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : 0 + 0x00000001 (00000001) : 1 + 0x00000002 (00000002) : [ + 0000 I_Get_Local 0x00000000 (00000000) + 0005 I_Constant 0x00000000 (00000000) + 0010 I_Equal + 0011 I_Jump_If_False 0x00000006 (00000006) + 0016 I_True + 0017 I_Jump 0x0000000B (00000011) + 0022 I_Get_Global 0x00000001 (00000001) + 0027 I_Get_Local 0x00000000 (00000000) + 0032 I_Constant 0x00000001 (00000001) + 0037 I_Sub + 0038 I_Call 1 + 0043 I_Return + ] + 0x00000003 (00000003) : 0 + 0x00000004 (00000004) : 1 + 0x00000005 (00000005) : [ + 0000 I_Get_Local 0x00000000 (00000000) + 0005 I_Constant 0x00000003 (00000003) + 0010 I_Equal + 0011 I_Jump_If_False 0x00000006 (00000006) + 0016 I_False + 0017 I_Jump 0x0000000B (00000011) + 0022 I_Get_Global 0x00000000 (00000000) + 0027 I_Get_Local 0x00000000 (00000000) + 0032 I_Constant 0x00000004 (00000004) + 0037 I_Sub + 0038 I_Call 1 + 0043 I_Return + ] + 0x00000006 (00000006) : 2 + 0x00000007 (00000007) : [ + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + 0009 I_Set_Global 0x00000000 (00000000) + 0014 I_Null + 0015 I_Pop + 0016 I_Closure 0x00000005 (00000005) (free variables: 0) + 0025 I_Set_Global 0x00000001 (00000001) + 0030 I_Null + 0031 I_Pop + 0032 I_Get_Global 0x00000000 (00000000) + 0037 I_Constant 0x00000006 (00000006) + 0042 I_Call 1 + 0047 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000007 (00000007) (free variables: 0) + ] + [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -363,59 +454,3 @@ 0000 I_Closure 0x0000000B (00000011) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . MutuallyRecursiveFunction - [ - [CONSTANTS] - 0x00000000 (00000000) : 0 - 0x00000001 (00000001) : 1 - 0x00000002 (00000002) : [ - 0000 I_Get_Local 0x00000000 (00000000) - 0005 I_Constant 0x00000000 (00000000) - 0010 I_Equal - 0011 I_Jump_If_False 0x00000006 (00000006) - 0016 I_True - 0017 I_Jump 0x0000000B (00000011) - 0022 I_Get_Global 0x00000001 (00000001) - 0027 I_Get_Local 0x00000000 (00000000) - 0032 I_Constant 0x00000001 (00000001) - 0037 I_Sub - 0038 I_Call 1 - 0043 I_Return - ] - 0x00000003 (00000003) : 0 - 0x00000004 (00000004) : 1 - 0x00000005 (00000005) : [ - 0000 I_Get_Local 0x00000000 (00000000) - 0005 I_Constant 0x00000003 (00000003) - 0010 I_Equal - 0011 I_Jump_If_False 0x00000006 (00000006) - 0016 I_False - 0017 I_Jump 0x0000000B (00000011) - 0022 I_Get_Global 0x00000000 (00000000) - 0027 I_Get_Local 0x00000000 (00000000) - 0032 I_Constant 0x00000004 (00000004) - 0037 I_Sub - 0038 I_Call 1 - 0043 I_Return - ] - 0x00000006 (00000006) : 2 - 0x00000007 (00000007) : [ - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) - 0009 I_Set_Global 0x00000000 (00000000) - 0014 I_Null - 0015 I_Pop - 0016 I_Closure 0x00000005 (00000005) (free variables: 0) - 0025 I_Set_Global 0x00000001 (00000001) - 0030 I_Null - 0031 I_Pop - 0032 I_Get_Global 0x00000000 (00000000) - 0037 I_Constant 0x00000006 (00000006) - 0042 I_Call 1 - 0047 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000007 (00000007) (free variables: 0) - ] - diff --git a/test/vm/html/html_instructions.t b/test/vm/html/html_instructions.t index c5310f7..b0c7e5d 100644 --- a/test/vm/html/html_instructions.t +++ b/test/vm/html/html_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . HtmlElement + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : "div" @@ -16,8 +16,6 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . HtmlElementAttributes [ [CONSTANTS] 0x00000000 (00000000) : "div" @@ -39,35 +37,6 @@ 0000 I_Closure 0x00000004 (00000004) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . HtmlElementSelfClosingVoid - [ - [CONSTANTS] - 0x00000000 (00000000) : "link" - 0x00000001 (00000001) : "href" - 0x00000002 (00000002) : "rel" - 0x00000003 (00000003) : "main.css" - 0x00000004 (00000004) : "stylesheet" - 0x00000005 (00000005) : 0 - 0x00000006 (00000006) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Constant 0x00000002 (00000002) - 0015 I_Constant 0x00000003 (00000003) - 0020 I_Constant 0x00000004 (00000004) - 0025 I_Record 2 - 0030 I_Constant 0x00000005 (00000005) - 0035 I_Array - 0036 I_Html_Template - 0037 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000006 (00000006) (free variables: 0) - ] - - - $ NO_COLOR="1" print_instructions . HtmlElementChildren [ [CONSTANTS] 0x00000000 (00000000) : "div" @@ -124,8 +93,6 @@ 0000 I_Closure 0x00000011 (00000017) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . HtmlElementExpressions [ [CONSTANTS] 0x00000000 (00000000) : "let-binding" @@ -196,8 +163,31 @@ 0000 I_Closure 0x00000011 (00000017) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . HtmlFragment + [ + [CONSTANTS] + 0x00000000 (00000000) : "link" + 0x00000001 (00000001) : "href" + 0x00000002 (00000002) : "rel" + 0x00000003 (00000003) : "main.css" + 0x00000004 (00000004) : "stylesheet" + 0x00000005 (00000005) : 0 + 0x00000006 (00000006) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Constant 0x00000002 (00000002) + 0015 I_Constant 0x00000003 (00000003) + 0020 I_Constant 0x00000004 (00000004) + 0025 I_Record 2 + 0030 I_Constant 0x00000005 (00000005) + 0035 I_Array + 0036 I_Html_Template + 0037 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000006 (00000006) (free variables: 0) + ] + [ [CONSTANTS] 0x00000000 (00000000) : "\n" diff --git a/test/vm/library/library_instructions.t b/test/vm/library/library_instructions.t index 07d9734..400559d 100644 --- a/test/vm/library/library_instructions.t +++ b/test/vm/library/library_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Library + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 3.141500 diff --git a/test/vm/loop/loop_instructions.t b/test/vm/loop/loop_instructions.t index 0b3a52e..bc2c6c0 100644 --- a/test/vm/loop/loop_instructions.t +++ b/test/vm/loop/loop_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Loop + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -59,192 +59,6 @@ 0000 I_Closure 0x0000000A (00000010) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . LoopNested - [ - [CONSTANTS] - 0x00000000 (00000000) : 1 - 0x00000001 (00000001) : 2 - 0x00000002 (00000002) : 2 - 0x00000003 (00000003) : 3 - 0x00000004 (00000004) : 4 - 0x00000005 (00000005) : 2 - 0x00000006 (00000006) : 5 - 0x00000007 (00000007) : 6 - 0x00000008 (00000008) : 2 - 0x00000009 (00000009) : 3 - 0x0000000A (00000010) : 0 - 0x0000000B (00000011) : 0 - 0x0000000C (00000012) : 0 - 0x0000000D (00000013) : 0 - 0x0000000E (00000014) : 1 - 0x0000000F (00000015) : 1 - 0x00000010 (00000016) : 1 - 0x00000011 (00000017) : 1 - 0x00000012 (00000018) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Constant 0x00000002 (00000002) - 0015 I_Array - 0016 I_Constant 0x00000003 (00000003) - 0021 I_Constant 0x00000004 (00000004) - 0026 I_Constant 0x00000005 (00000005) - 0031 I_Array - 0032 I_Constant 0x00000006 (00000006) - 0037 I_Constant 0x00000007 (00000007) - 0042 I_Constant 0x00000008 (00000008) - 0047 I_Array - 0048 I_Constant 0x00000009 (00000009) - 0053 I_Array - 0054 I_Set_Local 0x00000000 (00000000) - 0059 I_Null - 0060 I_Pop - 0061 I_Constant 0x0000000A (00000010) - 0066 I_Set_Local 0x00000003 (00000003) - 0071 I_Constant 0x0000000B (00000011) - 0076 I_Set_Local 0x00000004 (00000004) - 0081 I_Get_Local 0x00000000 (00000000) - 0086 I_Set_Local 0x00000005 (00000005) - 0091 I_Get_Local 0x00000005 (00000005) - 0096 I_Length - 0097 I_Set_Local 0x00000002 (00000002) - 0102 I_Get_Local 0x00000005 (00000005) - 0107 I_Get_Local 0x00000003 (00000003) - 0112 I_Index - 0113 I_Set_Local 0x00000001 (00000001) - 0118 I_Constant 0x0000000C (00000012) - 0123 I_Set_Local 0x00000008 (00000008) - 0128 I_Constant 0x0000000D (00000013) - 0133 I_Set_Local 0x00000009 (00000009) - 0138 I_Get_Local 0x00000001 (00000001) - 0143 I_Set_Local 0x0000000A (00000010) - 0148 I_Get_Local 0x0000000A (00000010) - 0153 I_Length - 0154 I_Set_Local 0x00000007 (00000007) - 0159 I_Get_Local 0x0000000A (00000010) - 0164 I_Get_Local 0x00000008 (00000008) - 0169 I_Index - 0170 I_Set_Local 0x00000006 (00000006) - 0175 I_Get_Local 0x00000003 (00000003) - 0180 I_Get_Local 0x00000008 (00000008) - 0185 I_Add - 0186 I_Get_Local 0x00000006 (00000006) - 0191 I_Add - 0192 I_Constant 0x0000000E (00000014) - 0197 I_Get_Local 0x00000009 (00000009) - 0202 I_Add - 0203 I_Set_Local 0x00000009 (00000009) - 0208 I_Constant 0x0000000F (00000015) - 0213 I_Get_Local 0x00000008 (00000008) - 0218 I_Add - 0219 I_Set_Local 0x00000008 (00000008) - 0224 I_Get_Local 0x00000008 (00000008) - 0229 I_Get_Local 0x00000007 (00000007) - 0234 I_Greater_Equal - 0235 I_Jump_If_False 0x00000027 (00000039) - 0240 I_Get_Local 0x00000009 (00000009) - 0245 I_Array - 0246 I_Constant 0x00000010 (00000016) - 0251 I_Get_Local 0x00000004 (00000004) - 0256 I_Add - 0257 I_Set_Local 0x00000004 (00000004) - 0262 I_Constant 0x00000011 (00000017) - 0267 I_Get_Local 0x00000003 (00000003) - 0272 I_Add - 0273 I_Set_Local 0x00000003 (00000003) - 0278 I_Get_Local 0x00000003 (00000003) - 0283 I_Get_Local 0x00000002 (00000002) - 0288 I_Greater_Equal - 0289 I_Jump_If_False 0x0000001A (00000026) - 0294 I_Get_Local 0x00000004 (00000004) - 0299 I_Array - 0300 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000012 (00000018) (free variables: 0) - ] - - - $ NO_COLOR="1" print_instructions . LoopContinue - [ - [CONSTANTS] - 0x00000000 (00000000) : 1 - 0x00000001 (00000001) : 2 - 0x00000002 (00000002) : 3 - 0x00000003 (00000003) : 4 - 0x00000004 (00000004) : 5 - 0x00000005 (00000005) : 6 - 0x00000006 (00000006) : 7 - 0x00000007 (00000007) : 8 - 0x00000008 (00000008) : 8 - 0x00000009 (00000009) : 0 - 0x0000000A (00000010) : 0 - 0x0000000B (00000011) : 2 - 0x0000000C (00000012) : 0 - 0x0000000D (00000013) : 1 - 0x0000000E (00000014) : 1 - 0x0000000F (00000015) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Constant 0x00000002 (00000002) - 0015 I_Constant 0x00000003 (00000003) - 0020 I_Constant 0x00000004 (00000004) - 0025 I_Constant 0x00000005 (00000005) - 0030 I_Constant 0x00000006 (00000006) - 0035 I_Constant 0x00000007 (00000007) - 0040 I_Constant 0x00000008 (00000008) - 0045 I_Array - 0046 I_Set_Local 0x00000000 (00000000) - 0051 I_Null - 0052 I_Pop - 0053 I_Constant 0x00000009 (00000009) - 0058 I_Set_Local 0x00000003 (00000003) - 0063 I_Constant 0x0000000A (00000010) - 0068 I_Set_Local 0x00000004 (00000004) - 0073 I_Get_Local 0x00000000 (00000000) - 0078 I_Set_Local 0x00000005 (00000005) - 0083 I_Get_Local 0x00000005 (00000005) - 0088 I_Length - 0089 I_Set_Local 0x00000002 (00000002) - 0094 I_Get_Local 0x00000005 (00000005) - 0099 I_Get_Local 0x00000003 (00000003) - 0104 I_Index - 0105 I_Set_Local 0x00000001 (00000001) - 0110 I_Get_Local 0x00000001 (00000001) - 0115 I_Constant 0x0000000B (00000011) - 0120 I_Mod - 0121 I_Constant 0x0000000C (00000012) - 0126 I_Not_Equal - 0127 I_Jump_If_False 0x00000022 (00000034) - 0132 I_Jump 0x00000029 (00000041) - 0137 I_Jump 0x00000023 (00000035) - 0142 I_Null - 0143 I_Pop - 0144 I_Get_Local 0x00000001 (00000001) - 0149 I_Constant 0x0000000D (00000013) - 0154 I_Get_Local 0x00000004 (00000004) - 0159 I_Add - 0160 I_Set_Local 0x00000004 (00000004) - 0165 I_Constant 0x0000000E (00000014) - 0170 I_Get_Local 0x00000003 (00000003) - 0175 I_Add - 0176 I_Set_Local 0x00000003 (00000003) - 0181 I_Get_Local 0x00000003 (00000003) - 0186 I_Get_Local 0x00000002 (00000002) - 0191 I_Greater_Equal - 0192 I_Jump_If_False 0x00000016 (00000022) - 0197 I_Get_Local 0x00000004 (00000004) - 0202 I_Array - 0203 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x0000000F (00000015) (free variables: 0) - ] - - - $ NO_COLOR="1" print_instructions . LoopBreak [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -318,8 +132,6 @@ 0000 I_Closure 0x0000000E (00000014) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . LoopBreakNested [ [CONSTANTS] 0x00000000 (00000000) : 1 @@ -442,3 +254,183 @@ 0000 I_Closure 0x00000016 (00000022) (free variables: 0) ] + [ + [CONSTANTS] + 0x00000000 (00000000) : 1 + 0x00000001 (00000001) : 2 + 0x00000002 (00000002) : 3 + 0x00000003 (00000003) : 4 + 0x00000004 (00000004) : 5 + 0x00000005 (00000005) : 6 + 0x00000006 (00000006) : 7 + 0x00000007 (00000007) : 8 + 0x00000008 (00000008) : 8 + 0x00000009 (00000009) : 0 + 0x0000000A (00000010) : 0 + 0x0000000B (00000011) : 2 + 0x0000000C (00000012) : 0 + 0x0000000D (00000013) : 1 + 0x0000000E (00000014) : 1 + 0x0000000F (00000015) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Constant 0x00000002 (00000002) + 0015 I_Constant 0x00000003 (00000003) + 0020 I_Constant 0x00000004 (00000004) + 0025 I_Constant 0x00000005 (00000005) + 0030 I_Constant 0x00000006 (00000006) + 0035 I_Constant 0x00000007 (00000007) + 0040 I_Constant 0x00000008 (00000008) + 0045 I_Array + 0046 I_Set_Local 0x00000000 (00000000) + 0051 I_Null + 0052 I_Pop + 0053 I_Constant 0x00000009 (00000009) + 0058 I_Set_Local 0x00000003 (00000003) + 0063 I_Constant 0x0000000A (00000010) + 0068 I_Set_Local 0x00000004 (00000004) + 0073 I_Get_Local 0x00000000 (00000000) + 0078 I_Set_Local 0x00000005 (00000005) + 0083 I_Get_Local 0x00000005 (00000005) + 0088 I_Length + 0089 I_Set_Local 0x00000002 (00000002) + 0094 I_Get_Local 0x00000005 (00000005) + 0099 I_Get_Local 0x00000003 (00000003) + 0104 I_Index + 0105 I_Set_Local 0x00000001 (00000001) + 0110 I_Get_Local 0x00000001 (00000001) + 0115 I_Constant 0x0000000B (00000011) + 0120 I_Mod + 0121 I_Constant 0x0000000C (00000012) + 0126 I_Not_Equal + 0127 I_Jump_If_False 0x00000022 (00000034) + 0132 I_Jump 0x00000029 (00000041) + 0137 I_Jump 0x00000023 (00000035) + 0142 I_Null + 0143 I_Pop + 0144 I_Get_Local 0x00000001 (00000001) + 0149 I_Constant 0x0000000D (00000013) + 0154 I_Get_Local 0x00000004 (00000004) + 0159 I_Add + 0160 I_Set_Local 0x00000004 (00000004) + 0165 I_Constant 0x0000000E (00000014) + 0170 I_Get_Local 0x00000003 (00000003) + 0175 I_Add + 0176 I_Set_Local 0x00000003 (00000003) + 0181 I_Get_Local 0x00000003 (00000003) + 0186 I_Get_Local 0x00000002 (00000002) + 0191 I_Greater_Equal + 0192 I_Jump_If_False 0x00000016 (00000022) + 0197 I_Get_Local 0x00000004 (00000004) + 0202 I_Array + 0203 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x0000000F (00000015) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : 1 + 0x00000001 (00000001) : 2 + 0x00000002 (00000002) : 2 + 0x00000003 (00000003) : 3 + 0x00000004 (00000004) : 4 + 0x00000005 (00000005) : 2 + 0x00000006 (00000006) : 5 + 0x00000007 (00000007) : 6 + 0x00000008 (00000008) : 2 + 0x00000009 (00000009) : 3 + 0x0000000A (00000010) : 0 + 0x0000000B (00000011) : 0 + 0x0000000C (00000012) : 0 + 0x0000000D (00000013) : 0 + 0x0000000E (00000014) : 1 + 0x0000000F (00000015) : 1 + 0x00000010 (00000016) : 1 + 0x00000011 (00000017) : 1 + 0x00000012 (00000018) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Constant 0x00000002 (00000002) + 0015 I_Array + 0016 I_Constant 0x00000003 (00000003) + 0021 I_Constant 0x00000004 (00000004) + 0026 I_Constant 0x00000005 (00000005) + 0031 I_Array + 0032 I_Constant 0x00000006 (00000006) + 0037 I_Constant 0x00000007 (00000007) + 0042 I_Constant 0x00000008 (00000008) + 0047 I_Array + 0048 I_Constant 0x00000009 (00000009) + 0053 I_Array + 0054 I_Set_Local 0x00000000 (00000000) + 0059 I_Null + 0060 I_Pop + 0061 I_Constant 0x0000000A (00000010) + 0066 I_Set_Local 0x00000003 (00000003) + 0071 I_Constant 0x0000000B (00000011) + 0076 I_Set_Local 0x00000004 (00000004) + 0081 I_Get_Local 0x00000000 (00000000) + 0086 I_Set_Local 0x00000005 (00000005) + 0091 I_Get_Local 0x00000005 (00000005) + 0096 I_Length + 0097 I_Set_Local 0x00000002 (00000002) + 0102 I_Get_Local 0x00000005 (00000005) + 0107 I_Get_Local 0x00000003 (00000003) + 0112 I_Index + 0113 I_Set_Local 0x00000001 (00000001) + 0118 I_Constant 0x0000000C (00000012) + 0123 I_Set_Local 0x00000008 (00000008) + 0128 I_Constant 0x0000000D (00000013) + 0133 I_Set_Local 0x00000009 (00000009) + 0138 I_Get_Local 0x00000001 (00000001) + 0143 I_Set_Local 0x0000000A (00000010) + 0148 I_Get_Local 0x0000000A (00000010) + 0153 I_Length + 0154 I_Set_Local 0x00000007 (00000007) + 0159 I_Get_Local 0x0000000A (00000010) + 0164 I_Get_Local 0x00000008 (00000008) + 0169 I_Index + 0170 I_Set_Local 0x00000006 (00000006) + 0175 I_Get_Local 0x00000003 (00000003) + 0180 I_Get_Local 0x00000008 (00000008) + 0185 I_Add + 0186 I_Get_Local 0x00000006 (00000006) + 0191 I_Add + 0192 I_Constant 0x0000000E (00000014) + 0197 I_Get_Local 0x00000009 (00000009) + 0202 I_Add + 0203 I_Set_Local 0x00000009 (00000009) + 0208 I_Constant 0x0000000F (00000015) + 0213 I_Get_Local 0x00000008 (00000008) + 0218 I_Add + 0219 I_Set_Local 0x00000008 (00000008) + 0224 I_Get_Local 0x00000008 (00000008) + 0229 I_Get_Local 0x00000007 (00000007) + 0234 I_Greater_Equal + 0235 I_Jump_If_False 0x00000027 (00000039) + 0240 I_Get_Local 0x00000009 (00000009) + 0245 I_Array + 0246 I_Constant 0x00000010 (00000016) + 0251 I_Get_Local 0x00000004 (00000004) + 0256 I_Add + 0257 I_Set_Local 0x00000004 (00000004) + 0262 I_Constant 0x00000011 (00000017) + 0267 I_Get_Local 0x00000003 (00000003) + 0272 I_Add + 0273 I_Set_Local 0x00000003 (00000003) + 0278 I_Get_Local 0x00000003 (00000003) + 0283 I_Get_Local 0x00000002 (00000002) + 0288 I_Greater_Equal + 0289 I_Jump_If_False 0x0000001A (00000026) + 0294 I_Get_Local 0x00000004 (00000004) + 0299 I_Array + 0300 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000012 (00000018) (free variables: 0) + ] + diff --git a/test/vm/math/math_instructions.t b/test/vm/math/math_instructions.t index 59fee4e..520c610 100644 --- a/test/vm/math/math_instructions.t +++ b/test/vm/math/math_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Add + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : 7 @@ -14,17 +14,14 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Sub - [ + [ [CONSTANTS] 0x00000000 (00000000) : 7 0x00000001 (00000001) : 5 0x00000002 (00000002) : [ 0000 I_Constant 0x00000000 (00000000) 0005 I_Constant 0x00000001 (00000001) - 0010 I_Sub + 0010 I_Div 0011 I_Return ] @@ -32,45 +29,66 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Div - [ + [ [CONSTANTS] - 0x00000000 (00000000) : 7 - 0x00000001 (00000001) : 5 - 0x00000002 (00000002) : [ + 0x00000000 (00000000) : 5 + 0x00000001 (00000001) : 3 + 0x00000002 (00000002) : 2 + 0x00000003 (00000003) : 6 + 0x00000004 (00000004) : 4 + 0x00000005 (00000005) : 8 + 0x00000006 (00000006) : 10 + 0x00000007 (00000007) : 10 + 0x00000008 (00000008) : [ 0000 I_Constant 0x00000000 (00000000) 0005 I_Constant 0x00000001 (00000001) - 0010 I_Div - 0011 I_Return + 0010 I_Mul + 0011 I_Constant 0x00000002 (00000002) + 0016 I_Constant 0x00000003 (00000003) + 0021 I_Constant 0x00000004 (00000004) + 0026 I_Constant 0x00000005 (00000005) + 0031 I_Mul + 0032 I_Add + 0033 I_Constant 0x00000006 (00000006) + 0038 I_Pow + 0039 I_Div + 0040 I_Add + 0041 I_Constant 0x00000007 (00000007) + 0046 I_Minus + 0047 I_Add + 0048 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + 0000 I_Closure 0x00000008 (00000008) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Mul - [ + [ [CONSTANTS] - 0x00000000 (00000000) : 7 - 0x00000001 (00000001) : 5 - 0x00000002 (00000002) : [ + 0x00000000 (00000000) : 3.140000 + 0x00000001 (00000001) : [ 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Mul - 0011 I_Return + 0005 I_Minus + 0006 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000002 (00000002) (free variables: 0) + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : 5 + 0x00000001 (00000001) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Minus + 0006 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Mod [ [CONSTANTS] 0x00000000 (00000000) : 7 @@ -86,17 +104,14 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Pow - [ + [ [CONSTANTS] 0x00000000 (00000000) : 7 0x00000001 (00000001) : 5 0x00000002 (00000002) : [ 0000 I_Constant 0x00000000 (00000000) 0005 I_Constant 0x00000001 (00000001) - 0010 I_Pow + 0010 I_Mul 0011 I_Return ] @@ -104,72 +119,33 @@ 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . MinusInt - [ - [CONSTANTS] - 0x00000000 (00000000) : 5 - 0x00000001 (00000001) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Minus - 0006 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000001 (00000001) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . MinusFloat - [ + [ [CONSTANTS] - 0x00000000 (00000000) : 3.140000 - 0x00000001 (00000001) : [ + 0x00000000 (00000000) : 7 + 0x00000001 (00000001) : 5 + 0x00000002 (00000002) : [ 0000 I_Constant 0x00000000 (00000000) - 0005 I_Minus - 0006 I_Return + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Pow + 0011 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . Math - [ + [ [CONSTANTS] - 0x00000000 (00000000) : 5 - 0x00000001 (00000001) : 3 - 0x00000002 (00000002) : 2 - 0x00000003 (00000003) : 6 - 0x00000004 (00000004) : 4 - 0x00000005 (00000005) : 8 - 0x00000006 (00000006) : 10 - 0x00000007 (00000007) : 10 - 0x00000008 (00000008) : [ + 0x00000000 (00000000) : 7 + 0x00000001 (00000001) : 5 + 0x00000002 (00000002) : [ 0000 I_Constant 0x00000000 (00000000) 0005 I_Constant 0x00000001 (00000001) - 0010 I_Mul - 0011 I_Constant 0x00000002 (00000002) - 0016 I_Constant 0x00000003 (00000003) - 0021 I_Constant 0x00000004 (00000004) - 0026 I_Constant 0x00000005 (00000005) - 0031 I_Mul - 0032 I_Add - 0033 I_Constant 0x00000006 (00000006) - 0038 I_Pow - 0039 I_Div - 0040 I_Add - 0041 I_Constant 0x00000007 (00000007) - 0046 I_Minus - 0047 I_Add - 0048 I_Return + 0010 I_Sub + 0011 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000008 (00000008) (free variables: 0) + 0000 I_Closure 0x00000002 (00000002) (free variables: 0) ] diff --git a/test/vm/record/record_instructions.t b/test/vm/record/record_instructions.t index d9fdba5..4c4c92e 100644 --- a/test/vm/record/record_instructions.t +++ b/test/vm/record/record_instructions.t @@ -1,4 +1,4 @@ - $ NO_COLOR="1" print_instructions . Record + $ NO_COLOR="1" print_instructions . [ [CONSTANTS] 0x00000000 (00000000) : "a" @@ -25,80 +25,81 @@ 0000 I_Closure 0x00000007 (00000007) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . RecordEmpty - [ + [ [CONSTANTS] - 0x00000000 (00000000) : [ - 0000 I_Record 0 - 0005 I_Return + 0x00000000 (00000000) : "a" + 0x00000001 (00000001) : "c" + 0x00000002 (00000002) : 1 + 0x00000003 (00000003) : "e" + 0x00000004 (00000004) : "123" + 0x00000005 (00000005) : "c" + 0x00000006 (00000006) : "e" + 0x00000007 (00000007) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Constant 0x00000001 (00000001) + 0010 I_Constant 0x00000002 (00000002) + 0015 I_Constant 0x00000003 (00000003) + 0020 I_Constant 0x00000004 (00000004) + 0025 I_Record 1 + 0030 I_Record 2 + 0035 I_Set_Local 0x00000000 (00000000) + 0040 I_Null + 0041 I_Pop + 0042 I_Get_Local 0x00000000 (00000000) + 0047 I_Constant 0x00000005 (00000005) + 0052 I_Index + 0053 I_Constant 0x00000006 (00000006) + 0058 I_Index + 0059 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000000 (00000000) (free variables: 0) + 0000 I_Closure 0x00000007 (00000007) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . RecordNested - [ + [ [CONSTANTS] 0x00000000 (00000000) : "a" - 0x00000001 (00000001) : "b" - 0x00000002 (00000002) : "c" - 0x00000003 (00000003) : "d" - 0x00000004 (00000004) : 1 - 0x00000005 (00000005) : "foo" + 0x00000001 (00000001) : "c" + 0x00000002 (00000002) : 1 + 0x00000003 (00000003) : "e" + 0x00000004 (00000004) : "123" + 0x00000005 (00000005) : "c" 0x00000006 (00000006) : "e" - 0x00000007 (00000007) : "f" - 0x00000008 (00000008) : "g" - 0x00000009 (00000009) : "123" - 0x0000000A (00000010) : 321 - 0x0000000B (00000011) : 1 - 0x0000000C (00000012) : 2 - 0x0000000D (00000013) : 3 - 0x0000000E (00000014) : 4 - 0x0000000F (00000015) : 5 - 0x00000010 (00000016) : 6 - 0x00000011 (00000017) : 7 - 0x00000012 (00000018) : 8 - 0x00000013 (00000019) : 8 - 0x00000014 (00000020) : [ + 0x00000007 (00000007) : [ 0000 I_Constant 0x00000000 (00000000) 0005 I_Constant 0x00000001 (00000001) 0010 I_Constant 0x00000002 (00000002) 0015 I_Constant 0x00000003 (00000003) 0020 I_Constant 0x00000004 (00000004) - 0025 I_Constant 0x00000005 (00000005) - 0030 I_Constant 0x00000006 (00000006) - 0035 I_Constant 0x00000007 (00000007) - 0040 I_Constant 0x00000008 (00000008) - 0045 I_Constant 0x00000009 (00000009) - 0050 I_Constant 0x0000000A (00000010) - 0055 I_Constant 0x0000000B (00000011) - 0060 I_Constant 0x0000000C (00000012) - 0065 I_Constant 0x0000000D (00000013) - 0070 I_Constant 0x0000000E (00000014) - 0075 I_Constant 0x0000000F (00000015) - 0080 I_Constant 0x00000010 (00000016) - 0085 I_Constant 0x00000011 (00000017) - 0090 I_Constant 0x00000012 (00000018) - 0095 I_Constant 0x00000013 (00000019) - 0100 I_Array - 0101 I_Record 3 - 0106 I_True - 0107 I_Record 4 - 0112 I_Return + 0025 I_Record 1 + 0030 I_Record 2 + 0035 I_Set_Local 0x00000000 (00000000) + 0040 I_Null + 0041 I_Pop + 0042 I_Get_Local 0x00000000 (00000000) + 0047 I_Constant 0x00000005 (00000005) + 0052 I_Dot_Index + 0053 I_Constant 0x00000006 (00000006) + 0058 I_Dot_Index + 0059 I_Return ] [INSTRUCTIONS] - 0000 I_Closure 0x00000014 (00000020) (free variables: 0) + 0000 I_Closure 0x00000007 (00000007) (free variables: 0) + ] + + [ + [CONSTANTS] + 0x00000000 (00000000) : [ + 0000 I_Record 0 + 0005 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000000 (00000000) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . RecordNested [ [CONSTANTS] 0x00000000 (00000000) : "a" @@ -153,73 +154,3 @@ 0000 I_Closure 0x00000014 (00000020) (free variables: 0) ] - - - $ NO_COLOR="1" print_instructions . RecordAccessDot - [ - [CONSTANTS] - 0x00000000 (00000000) : "a" - 0x00000001 (00000001) : "c" - 0x00000002 (00000002) : 1 - 0x00000003 (00000003) : "e" - 0x00000004 (00000004) : "123" - 0x00000005 (00000005) : "c" - 0x00000006 (00000006) : "e" - 0x00000007 (00000007) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Constant 0x00000002 (00000002) - 0015 I_Constant 0x00000003 (00000003) - 0020 I_Constant 0x00000004 (00000004) - 0025 I_Record 1 - 0030 I_Record 2 - 0035 I_Set_Local 0x00000000 (00000000) - 0040 I_Null - 0041 I_Pop - 0042 I_Get_Local 0x00000000 (00000000) - 0047 I_Constant 0x00000005 (00000005) - 0052 I_Dot_Index - 0053 I_Constant 0x00000006 (00000006) - 0058 I_Dot_Index - 0059 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000007 (00000007) (free variables: 0) - ] - - - - $ NO_COLOR="1" print_instructions . RecordAccessBracket - [ - [CONSTANTS] - 0x00000000 (00000000) : "a" - 0x00000001 (00000001) : "c" - 0x00000002 (00000002) : 1 - 0x00000003 (00000003) : "e" - 0x00000004 (00000004) : "123" - 0x00000005 (00000005) : "c" - 0x00000006 (00000006) : "e" - 0x00000007 (00000007) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Constant 0x00000001 (00000001) - 0010 I_Constant 0x00000002 (00000002) - 0015 I_Constant 0x00000003 (00000003) - 0020 I_Constant 0x00000004 (00000004) - 0025 I_Record 1 - 0030 I_Record 2 - 0035 I_Set_Local 0x00000000 (00000000) - 0040 I_Null - 0041 I_Pop - 0042 I_Get_Local 0x00000000 (00000000) - 0047 I_Constant 0x00000005 (00000005) - 0052 I_Index - 0053 I_Constant 0x00000006 (00000006) - 0058 I_Index - 0059 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000007 (00000007) (free variables: 0) - ] - diff --git a/test/vm/strings/strings_instructions.t b/test/vm/strings/strings_instructions.t index 676f893..f39bed7 100644 --- a/test/vm/strings/strings_instructions.t +++ b/test/vm/strings/strings_instructions.t @@ -1,4 +1,16 @@ - $ NO_COLOR="1" print_instructions . String + $ NO_COLOR="1" print_instructions . + [ + [CONSTANTS] + 0x00000000 (00000000) : "" + 0x00000001 (00000001) : [ + 0000 I_Constant 0x00000000 (00000000) + 0005 I_Return + ] + + [INSTRUCTIONS] + 0000 I_Closure 0x00000001 (00000001) (free variables: 0) + ] + [ [CONSTANTS] 0x00000000 (00000000) : "Hello!" @@ -11,8 +23,6 @@ 0000 I_Closure 0x00000001 (00000001) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . StringConcat [ [CONSTANTS] 0x00000000 (00000000) : "Hello " @@ -31,8 +41,6 @@ 0000 I_Closure 0x00000003 (00000003) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . StringInterpolation [ [CONSTANTS] 0x00000000 (00000000) : "World" @@ -55,17 +63,3 @@ 0000 I_Closure 0x00000003 (00000003) (free variables: 0) ] - - $ NO_COLOR="1" print_instructions . EmptyString - [ - [CONSTANTS] - 0x00000000 (00000000) : "" - 0x00000001 (00000001) : [ - 0000 I_Constant 0x00000000 (00000000) - 0005 I_Return - ] - - [INSTRUCTIONS] - 0000 I_Closure 0x00000001 (00000001) (free variables: 0) - ] -