diff --git a/docs/language.js b/docs/language.js index 2cd7784e..3655252a 100644 --- a/docs/language.js +++ b/docs/language.js @@ -663,11 +663,18 @@ var data = [ "description" : "Like target, but evaluates to the resulting node of the previous iteration for applicable opcodes.", "example" : "(while (< (target_index) 3) (print (previous_result)) (target_index))" }, + + { + "parameter" : "opcode_stack", + "output" : "list of *", + "description" : "Evaluates to the list of opcodes that include the call stack.", + "example" : "(print (opcode_stack))" + }, { "parameter" : "stack", - "output" : "*", - "description" : "Evaluates to the current execution context, also known as the scope stack.", + "output" : "list of assoc", + "description" : "Evaluates to the current execution context, also known as the scope stack, containing all of the variables for each layer of the stack.", "example" : "(print (stack))" }, diff --git a/src/Amalgam/Opcodes.cpp b/src/Amalgam/Opcodes.cpp index 832b7832..12e1edda 100644 --- a/src/Amalgam/Opcodes.cpp +++ b/src/Amalgam/Opcodes.cpp @@ -49,6 +49,7 @@ void StringInternPool::InitializeStaticStrings() EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_CURRENT_INDEX), "current_index"); EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_CURRENT_VALUE), "current_value"); EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_PREVIOUS_RESULT), "previous_result"); + EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_OPCODE_STACK), "opcode_stack"); EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_STACK), "stack"); EmplaceStaticString(GetStringIdFromNodeTypeFromString(ENT_ARGS), "args"); diff --git a/src/Amalgam/Opcodes.h b/src/Amalgam/Opcodes.h index 8f816d3f..926e0387 100644 --- a/src/Amalgam/Opcodes.h +++ b/src/Amalgam/Opcodes.h @@ -41,6 +41,7 @@ enum EvaluableNodeType : uint8_t ENT_CURRENT_INDEX, ENT_CURRENT_VALUE, ENT_PREVIOUS_RESULT, + ENT_OPCODE_STACK, ENT_STACK, ENT_ARGS, @@ -374,7 +375,7 @@ constexpr OrderedChildNodeType GetInstructionOrderedChildNodeType(EvaluableNodeT case ENT_RETRIEVE: case ENT_GET: case ENT_TARGET: case ENT_CURRENT_INDEX: case ENT_CURRENT_VALUE: case ENT_PREVIOUS_RESULT: - case ENT_STACK: case ENT_ARGS: + case ENT_OPCODE_STACK: case ENT_STACK: case ENT_ARGS: case ENT_RAND: case ENT_WEIGHTED_RAND: case ENT_GET_RAND_SEED: case ENT_SET_RAND_SEED: case ENT_SYSTEM_TIME: case ENT_GET_DIGITS: case ENT_SET_DIGITS: diff --git a/src/Amalgam/amlg_code/full_test.amlg b/src/Amalgam/amlg_code/full_test.amlg index f9929c46..ed2df25e 100644 --- a/src/Amalgam/amlg_code/full_test.amlg +++ b/src/Amalgam/amlg_code/full_test.amlg @@ -868,6 +868,9 @@ (current_index) ) + (print "--opcode_stack--\n") + (print (size (opcode_stack)) "\n") + (print "--stack--\n") (print (stack)) diff --git a/src/Amalgam/evaluablenode/EvaluableNodeTreeManipulation.cpp b/src/Amalgam/evaluablenode/EvaluableNodeTreeManipulation.cpp index 141255e8..d27a1f00 100644 --- a/src/Amalgam/evaluablenode/EvaluableNodeTreeManipulation.cpp +++ b/src/Amalgam/evaluablenode/EvaluableNodeTreeManipulation.cpp @@ -1917,6 +1917,7 @@ CompactHashMap EvaluableNodeTreeManipulation::evaluab {ENT_CURRENT_INDEX, 0.1}, {ENT_CURRENT_VALUE, 0.1}, {ENT_PREVIOUS_RESULT, 0.05}, + {ENT_OPCODE_STACK, 0.01}, {ENT_STACK, 0.05}, {ENT_ARGS, 0.08}, diff --git a/src/Amalgam/interpreter/Interpreter.cpp b/src/Amalgam/interpreter/Interpreter.cpp index a8dd6542..a94d0d1b 100644 --- a/src/Amalgam/interpreter/Interpreter.cpp +++ b/src/Amalgam/interpreter/Interpreter.cpp @@ -62,6 +62,7 @@ std::array Interpreter &Interpreter::InterpretNode_ENT_CURRENT_INDEX, // ENT_CURRENT_INDEX &Interpreter::InterpretNode_ENT_CURRENT_VALUE, // ENT_CURRENT_VALUE &Interpreter::InterpretNode_ENT_PREVIOUS_RESULT, // ENT_PREVIOUS_RESULT + &Interpreter::InterpretNode_ENT_OPCODE_STACK, // ENT_OPCODE_STACK &Interpreter::InterpretNode_ENT_STACK, // ENT_STACK &Interpreter::InterpretNode_ENT_ARGS, // ENT_ARGS diff --git a/src/Amalgam/interpreter/Interpreter.h b/src/Amalgam/interpreter/Interpreter.h index 1fe950e7..5aa06451 100644 --- a/src/Amalgam/interpreter/Interpreter.h +++ b/src/Amalgam/interpreter/Interpreter.h @@ -813,6 +813,7 @@ class Interpreter EvaluableNodeReference InterpretNode_ENT_CURRENT_INDEX(EvaluableNode *en, bool immediate_result); EvaluableNodeReference InterpretNode_ENT_CURRENT_VALUE(EvaluableNode *en, bool immediate_result); EvaluableNodeReference InterpretNode_ENT_PREVIOUS_RESULT(EvaluableNode *en, bool immediate_result); + EvaluableNodeReference InterpretNode_ENT_OPCODE_STACK(EvaluableNode *en, bool immediate_result); EvaluableNodeReference InterpretNode_ENT_STACK(EvaluableNode *en, bool immediate_result); EvaluableNodeReference InterpretNode_ENT_ARGS(EvaluableNode *en, bool immediate_result); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp index 19fc4a3c..a2dbb627 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp @@ -1319,6 +1319,15 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_PREVIOUS_RESULT(EvaluableN return GetAndClearPreviousResultInConstructionStack(depth); } +EvaluableNodeReference Interpreter::InterpretNode_ENT_OPCODE_STACK(EvaluableNode *en, bool immediate_result) +{ + //can create this node on the stack because will be making a copy + EvaluableNode stack_top_holder(ENT_LIST); + stack_top_holder.SetNeedCycleCheck(true); + stack_top_holder.SetOrderedChildNodes(*interpreterNodeStackNodes); + return evaluableNodeManager->DeepAllocCopy(&stack_top_holder); +} + EvaluableNodeReference Interpreter::InterpretNode_ENT_STACK(EvaluableNode *en, bool immediate_result) { #ifdef MULTITHREAD_SUPPORT diff --git a/src/Amalgam/out.txt b/src/Amalgam/out.txt index 9acb7bff..23d1b156 100644 --- a/src/Amalgam/out.txt +++ b/src/Amalgam/out.txt @@ -129,6 +129,7 @@ notakeyword not 0.75 null 0.75 number 8 + opcode_stack 0.01 or 0.75 parallel 0.5 parse 0.05 @@ -233,11 +234,11 @@ notakeyword (print "hello") (list .nan .nan .infinity -.infinity) -(assoc c (list "alpha" "beta" "gamma") b 2 a 1) +(assoc b 2 a 1 c (list "alpha" "beta" "gamma")) (assoc - c (list "alpha" "beta" "gamma") b 2 a 1 + c (list "alpha" "beta" "gamma") ) --if-- @@ -612,10 +613,10 @@ a e 5 f 6 ) -(assoc a 1 e 5) +(assoc d 4 e 5) (assoc a 1 - b 2 + d 4 e 5 f 6 ) @@ -661,10 +662,10 @@ c e 5 f 6 ) -(assoc a 1 e 5) +(assoc d 4 e 5) (assoc a 1 - b 2 + d 4 e 5 f 6 ) @@ -1012,7 +1013,7 @@ abcdef "2020-06-08 lunes 11.33.48" ) --indices-- -(list "c" "b" "a" "4") +(list "b" "a" "c" "4") (list 0 1 @@ -1024,7 +1025,7 @@ abcdef 7 ) --values-- -(list 3 2 1 "d") +(list 2 1 3 "d") (list "a" 1 @@ -1045,7 +1046,7 @@ abcdef 4 "d" ) -(list 3 2 1 "d" 0) +(list 3 2 1 0 "d") (list 1 2 @@ -1218,6 +1219,8 @@ current_index: 1 0 current_index: 2 1 +--opcode_stack-- +4 --stack-- (list (assoc @@ -1240,7 +1243,7 @@ current_index: 2 8 ) accum_string "abcdef" - argv (list "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") + argv (list "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") bar (declare (assoc x 6) (+ x 2) @@ -1253,10 +1256,10 @@ current_index: 2 A (assoc B 2) B 2 ) - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1711389109.212087 + start_time 1711636958.8531 www 1 x 12 zz 10 @@ -1283,7 +1286,7 @@ current_index: 2 8 ) accum_string "abcdef" - argv (list "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") + argv (list "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") bar (declare (assoc x 6) (+ x 2) @@ -1296,10 +1299,10 @@ current_index: 2 A (assoc B 2) B 2 ) - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1711389109.212087 + start_time 1711636958.8531 www 1 x 12 zz 10 @@ -1325,7 +1328,7 @@ current_index: 2 8 ) accum_string "abcdef" - argv (list "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") + argv (list "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\src\\Amalgam\\./amlg_code/full_test.amlg") bar (declare (assoc x 6) (+ x 2) @@ -1338,10 +1341,10 @@ current_index: 2 A (assoc B 2) B 2 ) - interpreter "C:\\Users\\Chris Hazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" + interpreter "C:\\Users\\ChristopherHazard\\Desktop\\Howso_repos\\amalgam\\x64\\MT_Release_EXE\\Amalgam.exe" raaa 2 rwww 1 - start_time 1711389109.212087 + start_time 1711636958.8531 www 1 x 12 zz 10 @@ -1485,11 +1488,11 @@ infinity test c or d: (list "d" "d" "d" "c") infinity test c or d: (list "c" @(get (target 0) 0) "d" @(get (target 0) 0)) -(assoc a 24 b 51 c 25) +(assoc a 30 b 46 c 24) (assoc a 29 b 44 c 27) -(list "10" "3" "1") +(list "5" "1" "3") --get_rand_seed-- °³È¼¿\¨KOaVÆT zÿ @@ -1589,7 +1592,6 @@ string 21: [{"b":4,"a":3},{"c":"c","d":null}] 22: [{"a":3,"b":4},{"c":"c","d":null}] 23: c: 3 -d: 4 b: 2 a: 1 e: @@ -1597,6 +1599,7 @@ e: - b - .nan - .inf +d: 4 24: a: 1 b: 2 @@ -1609,7 +1612,7 @@ e: - .inf 25: (assoc a 1) -current date-time in epoch: 2024-03-25-13.51.49.6960750 +current date-time in epoch: 2024-03-28-10.42.38.9032070 2020-06-07 00:22:59 1391230800 1391230800 @@ -1659,7 +1662,7 @@ domingo, jun. 07, 2020 ) ) (assoc - labelA #labelQ #labelA + labelA #labelA #labelQ (lambda #labelB (true) ) @@ -1676,7 +1679,7 @@ domingo, jun. 07, 2020 ) ) (assoc - labelA #labelQ #labelA + labelA #labelA #labelQ (lambda #labelB (true) ) @@ -1885,30 +1888,33 @@ decrypted: hello --mutate-- (list 1 - -2.781487486378118 - 3 - 10 - 5 - (call) + (parallel) + (+) + 4 + (clone_entities) + 6 7 - (query_min) - (last) + 8 + 9 10 11 - 12 - 13 + (if) + -3.6673445641690456 14 - "b" + (associate) ) (list 1 2 - 3 - (-) - (associate "alpha" (*) (*) 6) + (+) + (+) + (associate) (associate "nest" - (associate "count" (list)) + (associate + "count" + (list 7 8 9) + ) "end" (list 10 11 12) ) @@ -2345,7 +2351,15 @@ decrypted: hello ) ) --mix-- -(list 2 3.5 8 9.5 11.5 13.5) +(list + 2 + 3.5 + 5 + 7.5 + 9.5 + 11.5 + 13.5 +) (list ;comment 1 @@ -2353,8 +2367,8 @@ decrypted: hello ;comment 3 ;comment 4 1 - 3.5 - 5 + 4 + 5.5 7.5 9.5 11.5 @@ -2362,6 +2376,7 @@ decrypted: hello ) (list 1 + 5 2.5 (associate "a" 3 "b" 4) (lambda @@ -2371,7 +2386,7 @@ decrypted: hello (parallel (get_entity_comments) 1 - (lambda (null)) + (lambda (print)) ) ) ) @@ -2379,9 +2394,8 @@ decrypted: hello ) (list 1 - 5 2.5 - (assoc b 4) + (associate "a" 3 "b" 4) (lambda (if true @@ -2397,17 +2411,16 @@ decrypted: hello ) ) ) - (list 5 6) ) (list 3.5 5.5 7.5 9.5 11.5 13.5) -(list 2 4 7) -1 +(list 5 8 10 12 11 13) +4 4 2.5 2.5 -abcdoxyz abcmxyz abcmxyz +abcdmxyz --mix_labels-- (list 1 @@ -2674,55 +2687,55 @@ flatten restore with parallel (list 1 2 - 8 + 3 4 5 a 7 - 3 - (call) + 8 + (query_within_generalized_distance) 10 11 12 - (floor) - -6.182472379158481 - (associate (call) 1 (retrieve_from_entity) "a") + "b" + 14 + (associate "a" 1 (round) a) ) (list - (trunc) - (list) + 1 + 2 3 - 4 - (dot_product) - 6 - (null) - 8 + (abs) + 5 + (log) + (values) + 17 9 - (query_not_exists) - 11 + 10 + (total_size) 12 - 13 - (>) - (associate "a" 1) + "b" + (and) + (associate (let) 1 0.14034045403278178 (call)) ) (list 1 - (+) + (*) 3 - 4 - (+) + (-) + 5 6 - 7 + (+) 8 9 + 10 (+) - 11 12 + 13 (+) - 14 - (associate "a" (+)) + (associate "a" (*) "b" 2 (+)) ) --commonality_entities-- @@ -2735,10 +2748,10 @@ MergeEntityChild1 (associate "x" 3 "y" 4) MergeEntityChild2 (associate "p" 3 "q" 4) -_2280722175 -(associate "E" 3 "F" 4) _2169689611 (associate "e" 3 "f" 4) +_2280722175 +(associate "E" 3 "F" 4) --union_entities-- (associate "b" 4 "a" 3 "c" 3) MergeEntityChild1 @@ -2756,26 +2769,26 @@ MergeEntityChild2 "w" 7 ) -_2280722175 +_2169689611 (associate - "E" + "e" 3 - "F" + "f" 4 - "G" + "g" 5 - "H" + "h" 6 ) -_2169689611 +_2280722175 (associate - "e" + "E" 3 - "f" + "F" 4 - "g" + "G" 5 - "h" + "H" 6 ) (parallel @@ -3271,8 +3284,14 @@ _41032496 (list) (lambda (assoc - E 3 - F 4 + E (get + (current_value 1) + "E" + ) + F (get + (current_value 1) + "F" + ) G 5 H 6 ) @@ -3297,7 +3316,16 @@ _41032496 _ (list) (lambda - (assoc e 3 f 4) + (assoc + e (get + (current_value 1) + "e" + ) + f (get + (current_value 1) + "f" + ) + ) ) ) ) @@ -3325,27 +3353,18 @@ DiffContainerReconstructed ) --mix_entities-- (associate "b" 4 "a" 3) +_523256902 +(associate "G" 5) _3895405527 (null) -_523256902 -(associate "E" 3) -MergeEntityChild2 -(associate "p" 3 "q" 4) MergeEntityChild1 (associate "x" 3 "y" 4) +MergeEntityChild2 +(associate "p" 3 "q" 4 "u" 5) +_2169689611 +(associate "f" 4) _2280722175 (associate "E" 3 "F" 4) -_2169689611 -(associate - "e" - 3 - "f" - 4 - "g" - 5 - "h" - 6 -) --get_entity_comments-- Full test This is a suite of unit tests. @@ -3405,7 +3424,7 @@ deep sets --set_entity_root_permission-- RootTest -1711389109.878964 +1711636959.03925 (true) RootTest @@ -3797,74 +3816,74 @@ store to .json normally (list "Child2" "Child7") (list "Child1" "Child5") (list "Child3" "Child4") -(list "Child2" "Child5" "Child6" "Child7") -(list "Child1" "Child4" "Child6" "Child7") +(list "Child1" "Child2" "Child3" "Child7") +(list "Child1" "Child2" "Child3" "Child4") (list "Child4" "Child6") --query_sample-- -(list "Child7") -(list "Child3" "Child3") -(list "Child2") +(list "Child1") +(list "Child1" "Child5") (list "Child2") +(list "Child1") --query_weighted_sample-- -(list "Child2") (list "Child1") +(list "Child2") (list "Child1" "Child2" "Child2" "Child2" "Child1" + "Child2" "Child1" "Child1" - "Child4" "Child2" "Child1" "Child2" "Child2" - "Child2" "Child1" - "Child2" - "Child7" "Child1" + "Child2" + "Child2" "Child1" "Child2" "Child1" + "Child6" ) (list "Child2" - "Child1" - "Child1" - "Child2" - "Child6" "Child2" "Child2" "Child2" "Child1" "Child2" - "Child2" - "Child2" + "Child7" "Child1" "Child1" "Child1" "Child2" "Child1" + "Child1" + "Child3" "Child2" + "Child1" + "Child1" "Child2" "Child2" + "Child1" ) (list "Child2" - "Child2" - "Child6" + "Child3" "Child2" "Child2" "Child2" "Child2" + "Child4" "Child2" "Child2" "Child2" ) -(list "Child2" "Child7") +(list "Child2") --query_in_entity_list-- (list "Child6" "Child7") --query_not_in_entity_list-- @@ -3919,16 +3938,16 @@ unweighted query: (assoc weighted query: (assoc Child1 1.8 Child2 0.45 - Child4 2 + Child3 2 Child6 0.04 Child7 0.2 ) weighted query list of lists: (list - (list "Child6" "Child7" "Child2" "Child1" "Child3") + (list "Child6" "Child7" "Child2" "Child1" "Child4") (list 0.04 0.2 0.45 1.8 2) ) weighted query list of lists: (list - (list "Child2" "Child6" "Child1" "Child7" "Child4") + (list "Child2" "Child6" "Child1" "Child7" "Child3") (list 1 2 4 10 100) (list -1 2 4 10 100) ) @@ -4233,15 +4252,15 @@ case conviction:(assoc ) cyclic feature nearest neighbors: (assoc cyclic1 1 cyclic5 0.5) cyclic test expected: 155, 200, 190 ... deg values of 0 8 and 12: -200: 0.05555555555555555 (null - ##deg 8 -) 190: 0.045454545454545456 (null ##deg 12 ) 155: 0.1 (null ##deg 0 ) +200: 0.05555555555555555 (null + ##deg 8 +) --contains_label-- (true) @@ -4418,10 +4437,10 @@ distance symmetry tests (list (list "B" - "F" - "I" - "C" "D" + "C" + "I" + "F" "A" "G" "H" @@ -4440,12 +4459,12 @@ distance symmetry tests (list (list "B" - "I" + "D" "C" "A" - "D" + "I" "F" - "H" + "G" "E" ) (list @@ -4640,4 +4659,4 @@ concurrent entity writes successful: (true) --clean-up test files-- --total execution time-- -1.4943439960479736 +1.6799509525299072