diff --git a/src/Amalgam/entity/EntityExternalInterface.cpp b/src/Amalgam/entity/EntityExternalInterface.cpp index 63da11aa..7e483fc8 100644 --- a/src/Amalgam/entity/EntityExternalInterface.cpp +++ b/src/Amalgam/entity/EntityExternalInterface.cpp @@ -526,7 +526,8 @@ std::string EntityExternalInterface::GetJSONFromLabel(std::string &handle, std:: return ""; EvaluableNode *label_val = bundle->entity->GetValueAtLabel(label, nullptr, false); - return EvaluableNodeJSONTranslation::EvaluableNodeToJson(label_val); + auto [result, converted] = EvaluableNodeJSONTranslation::EvaluableNodeToJson(label_val); + return (converted ? result : string_intern_pool.GetStringFromID(string_intern_pool.NOT_A_STRING_ID)); } std::string EntityExternalInterface::ExecuteEntityJSON(std::string &handle, std::string &label, std::string_view json) @@ -552,9 +553,9 @@ std::string EntityExternalInterface::ExecuteEntityJSON(std::string &handle, std: //ConvertArgsToCallStack always adds an outer list that is safe to free enm.FreeNode(call_stack); - std::string result = EvaluableNodeJSONTranslation::EvaluableNodeToJson(returned_value); + auto [result, converted] = EvaluableNodeJSONTranslation::EvaluableNodeToJson(returned_value); enm.FreeNodeTreeIfPossible(returned_value); - return result; + return (converted ? result : string_intern_pool.GetStringFromID(string_intern_pool.NOT_A_STRING_ID)); } bool EntityExternalInterface::EntityListenerBundle::SetEntityValueAtLabel(std::string &label_name, EvaluableNodeReference new_value) diff --git a/src/Amalgam/importexport/FileSupportJSON.cpp b/src/Amalgam/importexport/FileSupportJSON.cpp index 58d2af89..128bfb0e 100644 --- a/src/Amalgam/importexport/FileSupportJSON.cpp +++ b/src/Amalgam/importexport/FileSupportJSON.cpp @@ -319,21 +319,20 @@ EvaluableNode *EvaluableNodeJSONTranslation::JsonToEvaluableNode(EvaluableNodeMa } } -std::string EvaluableNodeJSONTranslation::EvaluableNodeToJson(EvaluableNode *code, bool sort_keys) +std::pair EvaluableNodeJSONTranslation::EvaluableNodeToJson(EvaluableNode *code, bool sort_keys) { if(code == nullptr) - return "null"; + return std::make_pair("null", true); //if need cycle check, double-check if(!EvaluableNode::CanNodeTreeBeFlattened(code)) - return ""; + return std::make_pair("", false); - //if successful return the json, otherwise return blank std::string json_str; if(EvaluableNodeToJsonStringRecurse(code, json_str, sort_keys)) - return json_str; + return std::make_pair(json_str, true); else - return ""; + return std::make_pair("", false); } EvaluableNode *EvaluableNodeJSONTranslation::Load(const std::string &resource_path, EvaluableNodeManager *enm) @@ -371,8 +370,14 @@ bool EvaluableNodeJSONTranslation::Store(EvaluableNode *code, const std::string return false; } + auto [result, converted] = EvaluableNodeToJson(code, sort_keys); + if(!converted) + { + std::cerr << "Error storing JSON: cannot convert node to JSON" << std::endl; + return false; + } std::ofstream file(resource_path); - file << EvaluableNodeToJson(code, sort_keys); + file << result; return true; } diff --git a/src/Amalgam/importexport/FileSupportJSON.h b/src/Amalgam/importexport/FileSupportJSON.h index 25d05da3..2e9b74fd 100644 --- a/src/Amalgam/importexport/FileSupportJSON.h +++ b/src/Amalgam/importexport/FileSupportJSON.h @@ -12,9 +12,9 @@ namespace EvaluableNodeJSONTranslation //converts JSON string_view to EvaluableNode tree EvaluableNode *JsonToEvaluableNode(EvaluableNodeManager *enm, std::string_view json_str); - //converts EvaluableNode tree to JSON string + //converts EvaluableNode tree to JSON string. Returns false if EN cannot be converted to JSON // if sort_keys is true, it will sort all of the assoc keys - std::string EvaluableNodeToJson(EvaluableNode *code, bool sort_keys = false); + std::pair EvaluableNodeToJson(EvaluableNode *code, bool sort_keys = false); //loads json file to EvaluableNode tree EvaluableNode *Load(const std::string &resource_path, EvaluableNodeManager *enm); diff --git a/src/Amalgam/importexport/FileSupportYAML.cpp b/src/Amalgam/importexport/FileSupportYAML.cpp index 0535b4c7..52e56cb9 100644 --- a/src/Amalgam/importexport/FileSupportYAML.cpp +++ b/src/Amalgam/importexport/FileSupportYAML.cpp @@ -158,21 +158,21 @@ EvaluableNode *EvaluableNodeYAMLTranslation::YamlToEvaluableNode(EvaluableNodeMa return YamlToEvaluableNodeRecurse(enm, yaml_top_element); } -std::string EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(EvaluableNode *code, bool sort_keys) +std::pair EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(EvaluableNode *code, bool sort_keys) { if(code == nullptr) - return "null"; + return std::make_pair("null", true); //if need cycle check, double-check if(!EvaluableNode::CanNodeTreeBeFlattened(code)) - return ""; + return std::make_pair("", false); ryml::Tree tree; auto top_node = tree.rootref(); if(EvaluableNodeToYamlStringRecurse(code, top_node, sort_keys)) - return ryml::emitrs_yaml(tree); + return std::make_pair(ryml::emitrs_yaml(tree), true); else - return ""; + return std::make_pair("", false); } EvaluableNode *EvaluableNodeYAMLTranslation::Load(const std::string &resource_path, EvaluableNodeManager *enm) @@ -200,8 +200,14 @@ bool EvaluableNodeYAMLTranslation::Store(EvaluableNode *code, const std::string return false; } + auto [result, converted] = EvaluableNodeToYaml(code, sort_keys); + if(!converted) + { + std::cerr << "Error storing YAML: cannot convert node to YAML" << std::endl; + return false; + } std::ofstream file(resource_path); - file << EvaluableNodeToYaml(code, sort_keys); + file << result; return true; } diff --git a/src/Amalgam/importexport/FileSupportYAML.h b/src/Amalgam/importexport/FileSupportYAML.h index cd1b2261..1eceab39 100644 --- a/src/Amalgam/importexport/FileSupportYAML.h +++ b/src/Amalgam/importexport/FileSupportYAML.h @@ -12,9 +12,9 @@ namespace EvaluableNodeYAMLTranslation //converts YAML string_view to EvaluableNode tree EvaluableNode *YamlToEvaluableNode(EvaluableNodeManager *enm, std::string &yaml_str); - //converts EvaluableNode tree to YAML string + //converts EvaluableNode tree to YAML string. Returns false if EN cannot be converted to YAML // if sort_keys is true, it will sort all of the assoc keys - std::string EvaluableNodeToYaml(EvaluableNode *code, bool sort_keys = false); + std::pair EvaluableNodeToYaml(EvaluableNode *code, bool sort_keys = false); //loads yaml file to EvaluableNode tree EvaluableNode *Load(const std::string &resource_path, EvaluableNodeManager *enm); diff --git a/src/Amalgam/interpreter/Interpreter.h b/src/Amalgam/interpreter/Interpreter.h index 5285d33d..0f238fda 100644 --- a/src/Amalgam/interpreter/Interpreter.h +++ b/src/Amalgam/interpreter/Interpreter.h @@ -421,7 +421,7 @@ class Interpreter //calls InterpretNode on tpl, traverses source based on tpl. // If create_destination_if_necessary is set, then it will expand anything in the source as appropriate //Returns the location of the EvaluableNode * of the destination, nullptr if it does not exist - __forceinline EvaluableNode **InterpretNodeIntoDestinationFromTraversalPathList(EvaluableNode **source, + __forceinline EvaluableNode **InterpretNodeIntoDestination(EvaluableNode **source, EvaluableNode *tpl, bool create_destination_if_necessary) { EvaluableNodeReference address_list_node = InterpretNodeForImmediateUse(tpl); @@ -432,7 +432,7 @@ class Interpreter //Interprets node_id_path_to_interpret and then attempts to find the Entity relative to curEntity. Returns nullptr if cannot find template - EntityReferenceType InterpretNodeIntoRelativeSourceEntityReferenceFromInterpretedEvaluableNodeIDPath(EvaluableNode *node_id_path_to_interpret) + EntityReferenceType InterpretNodeIntoRelativeSourceEntityReference(EvaluableNode *node_id_path_to_interpret) { if(curEntity == nullptr) return EntityReferenceType(nullptr); @@ -448,16 +448,16 @@ class Interpreter return source_entity; } - //like InterpretNodeIntoRelativeSourceEntityReferenceFromInterpretedEvaluableNodeIDPath but with a read reference - inline EntityReadReference InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(EvaluableNode *node_id_path_to_interpret) + //like InterpretNodeIntoRelativeSourceEntityReference but with a read reference + inline EntityReadReference InterpretNodeIntoRelativeSourceEntityReadReference(EvaluableNode *node_id_path_to_interpret) { - return InterpretNodeIntoRelativeSourceEntityReferenceFromInterpretedEvaluableNodeIDPath(node_id_path_to_interpret); + return InterpretNodeIntoRelativeSourceEntityReference(node_id_path_to_interpret); } - //like InterpretNodeIntoRelativeSourceEntityReferenceFromInterpretedEvaluableNodeIDPath but with a write reference - inline EntityWriteReference InterpretNodeIntoRelativeSourceEntityWriteReferenceFromInterpretedEvaluableNodeIDPath(EvaluableNode *node_id_path_to_interpret) + //like InterpretNodeIntoRelativeSourceEntityReference but with a write reference + inline EntityWriteReference InterpretNodeIntoRelativeSourceEntityWriteReference(EvaluableNode *node_id_path_to_interpret) { - return InterpretNodeIntoRelativeSourceEntityReferenceFromInterpretedEvaluableNodeIDPath(node_id_path_to_interpret); + return InterpretNodeIntoRelativeSourceEntityReference(node_id_path_to_interpret); } protected: diff --git a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp index c1662b60..2286a330 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesBase.cpp @@ -1075,7 +1075,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET(EvaluableNode *en, boo //if just a single index passed to get if(ocn_size == 2) { - EvaluableNode **target = InterpretNodeIntoDestinationFromTraversalPathList(&source.GetReference(), ocn[1], false); + EvaluableNode **target = InterpretNodeIntoDestination(&source.GetReference(), ocn[1], false); node_stack.PopEvaluableNode(); @@ -1095,7 +1095,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET(EvaluableNode *en, boo for(size_t param_index = 1; param_index < ocn_size; param_index++) { - EvaluableNode **target = InterpretNodeIntoDestinationFromTraversalPathList(&source.GetReference(), ocn[param_index], false); + EvaluableNode **target = InterpretNodeIntoDestination(&source.GetReference(), ocn[param_index], false); if(target != nullptr) retrieved_list->AppendOrderedChildNode(*target); else @@ -1131,7 +1131,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_SET_and_REPLACE(EvaluableN { //find replacement location, make sure it's a valid target EvaluableNode *previous_result = result; - EvaluableNode **copy_destination = InterpretNodeIntoDestinationFromTraversalPathList(&result.GetReference(), ocn[replace_change_index], true); + EvaluableNode **copy_destination = InterpretNodeIntoDestination(&result.GetReference(), ocn[replace_change_index], true); //if the target changed, keep track of the proper reference if(result != previous_result) { diff --git a/src/Amalgam/interpreter/InterpreterOpcodesCodeMixing.cpp b/src/Amalgam/interpreter/InterpreterOpcodesCodeMixing.cpp index e9a21623..430b23d6 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesCodeMixing.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesCodeMixing.cpp @@ -298,7 +298,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_TOTAL_ENTITY_SIZE(Evaluabl //TODO 10975: lock entire entity tree //get the id of the first source entity - EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(source_entity == nullptr) return EvaluableNodeReference::Null(); @@ -323,7 +323,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FLATTEN_ENTITY(EvaluableNo //TODO 10975: lock entire entity tree //get the id of the first source entity - EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(source_entity == nullptr) return EvaluableNodeReference::Null(); @@ -388,7 +388,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_MUTATE_ENTITY(EvaluableNod //retrieve the entities after other parameters to minimize time in locks // and prevent deadlock if one of the params accessed the entity //get the id of the first source entity - EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity == nullptr || source_entity == curEntity) return EvaluableNodeReference::Null(); @@ -423,12 +423,12 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_COMMONALITY_ENTITIES(Evalu //TODO 10975: change this to lock all entities at once //get the id of the first source entity - Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(source_entity_1 == nullptr) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); if(source_entity_2 == nullptr) return EvaluableNodeReference::Null(); @@ -445,12 +445,12 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_EDIT_DISTANCE_ENTITIES(Eva //TODO 10975: change this to lock all entities at once //get the id of the first source entity - Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(source_entity_1 == nullptr) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); if(source_entity_2 == nullptr) return EvaluableNodeReference::Null(); @@ -471,13 +471,13 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_INTERSECT_ENTITIES(Evaluab //TODO 10975: change this to lock all entities at once //get the id of the first source entity - Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_1 == nullptr || source_entity_1 == curEntity) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_2 == nullptr || source_entity_2 == curEntity) return EvaluableNodeReference::Null(); @@ -524,13 +524,13 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_UNION_ENTITIES(EvaluableNo //TODO 10975: change this to lock all entities at once //get the id of the first source entity - Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity *source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_1 == nullptr || source_entity_1 == curEntity) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity *source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_2 == nullptr || source_entity_2 == curEntity) return EvaluableNodeReference::Null(); @@ -573,13 +573,13 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_DIFFERENCE_ENTITIES(Evalua //TODO 10975: change this to lock all entities at once //get the id of the first source entity - Entity *entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity *entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); //need a source entity, and can't copy self! (that could cause badness) if(entity_1 == nullptr || entity_1 == curEntity) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity *entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity *entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); //need a source entity, and can't copy self! (that could cause badness) if(entity_2 == nullptr || entity_2 == curEntity) return EvaluableNodeReference::Null(); @@ -630,13 +630,13 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_MIX_ENTITIES(EvaluableNode //retrieve the entities after other parameters to minimize time in locks // and prevent deadlock if one of the params accessed the entity //get the id of the first source entity - Entity* source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + Entity* source_entity_1 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_1 == nullptr || source_entity_1 == curEntity) return EvaluableNodeReference::Null(); //get the id of the second source entity - Entity* source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + Entity* source_entity_2 = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity_2 == nullptr || source_entity_2 == curEntity) return EvaluableNodeReference::Null(); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp b/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp index 4d232ce9..a3ed7005 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesDataTypes.cpp @@ -339,6 +339,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, bool use_string = false; std::string string_value = ""; + bool valid_string_value = true; const std::string date_string("date:"); @@ -805,7 +806,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, else if(use_string) { EvaluableNode en_str(ENT_STRING, string_value); - string_value = EvaluableNodeJSONTranslation::EvaluableNodeToJson(&en_str); + std::tie(string_value, valid_string_value) = EvaluableNodeJSONTranslation::EvaluableNodeToJson(&en_str); } else if(use_code) { @@ -819,7 +820,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, sort_keys = EvaluableNode::IsTrue(found_sort_keys->second); } - string_value = EvaluableNodeJSONTranslation::EvaluableNodeToJson(code_value, sort_keys); + std::tie(string_value, valid_string_value) = EvaluableNodeJSONTranslation::EvaluableNodeToJson(code_value, sort_keys); } } else if(to_type == ENBISI_yaml) @@ -827,22 +828,22 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, if(use_number) { EvaluableNode value(number_value); - string_value = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); + std::tie(string_value, valid_string_value) = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); } else if(use_uint_number) { EvaluableNode value(static_cast(uint_number_value)); - string_value = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); + std::tie(string_value, valid_string_value) = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); } else if(use_int_number) { EvaluableNode value(static_cast(int_number_value)); - string_value = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); + std::tie(string_value, valid_string_value) = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&value); } else if(use_string) { EvaluableNode en_str(ENT_STRING, string_value); - string_value = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&en_str); + std::tie(string_value, valid_string_value) = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(&en_str); } else if(use_code) { @@ -856,7 +857,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, sort_keys = EvaluableNode::IsTrue(found_sort_keys->second); } - string_value = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(code_value, sort_keys); + std::tie(string_value, valid_string_value) = EvaluableNodeYAMLTranslation::EvaluableNodeToYaml(code_value, sort_keys); } } else //need to parse the string @@ -893,6 +894,8 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_FORMAT(EvaluableNode *en, string_intern_pool.DestroyStringReference(to_type); + if(!valid_string_value) + return ReuseOrAllocReturn(to_params, string_intern_pool.NOT_A_STRING_ID, immediate_result); return ReuseOrAllocOneOfReturn(to_params, code_value, string_value, immediate_result); } diff --git a/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp b/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp index 365636bb..a1992a66 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesEntityAccess.cpp @@ -197,7 +197,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CONTAINS_LABEL(EvaluableNo //get the id of the entity EntityReadReference target_entity; if(ocn.size() > 1) - target_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + target_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); else target_entity = EntityReadReference(curEntity); @@ -240,7 +240,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ASSIGN_TO_ENTITIES_and_DIR EntityWriteReference target_entity; if(i + 1 < ocn.size()) - target_entity = InterpretNodeIntoRelativeSourceEntityWriteReferenceFromInterpretedEvaluableNodeIDPath(ocn[i]); + target_entity = InterpretNodeIntoRelativeSourceEntityWriteReference(ocn[i]); else target_entity = EntityWriteReference(curEntity); @@ -324,7 +324,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_RETRIEVE_FROM_ENTITY_and_D //get the id of the source to check EntityReadReference target_entity; if(ocn.size() > 1) - target_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + target_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); else target_entity = EntityReadReference(curEntity); @@ -484,7 +484,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CALL_ENTITY_and_CALL_ENTIT } //get a write lock on the entity - EntityReadReference called_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference called_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(called_entity == nullptr) return EvaluableNodeReference::Null(); diff --git a/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp b/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp index 83a6129a..2bea2a97 100644 --- a/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp +++ b/src/Amalgam/interpreter/InterpreterOpcodesEntityControl.cpp @@ -38,7 +38,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ENTITY_COMMENTS(Evalua // and prevent deadlock if one of the params accessed the entity EntityReadReference target_entity; if(ocn.size() > 0) - target_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + target_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); else target_entity = EntityReadReference(curEntity); @@ -129,7 +129,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_RETRIEVE_ENTITY_ROOT(Evalu // and prevent deadlock if one of the params accessed the entity EntityReadReference target_entity; if(ocn.size() > 0) - target_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + target_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); else target_entity = EntityReadReference(curEntity); @@ -163,7 +163,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ASSIGN_ENTITY_ROOTS_and_AC EntityWriteReference target_entity; if(i + 1 < ocn.size()) { - target_entity = InterpretNodeIntoRelativeSourceEntityWriteReferenceFromInterpretedEvaluableNodeIDPath(ocn[i]); + target_entity = InterpretNodeIntoRelativeSourceEntityWriteReference(ocn[i]); //if didn't find an entity, then use current one if(target_entity == nullptr) @@ -226,7 +226,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ENTITY_RAND_SEED(Evalu return EvaluableNodeReference::Null(); //get the id of the entity - EntityReadReference entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); if(entity == nullptr) return EvaluableNodeReference::Null(); @@ -264,7 +264,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_SET_ENTITY_RAND_SEED(Evalu //get the entity EntityWriteReference entity; if(num_params > 1) - entity = InterpretNodeIntoRelativeSourceEntityWriteReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + entity = InterpretNodeIntoRelativeSourceEntityWriteReference(ocn[0]); else entity = EntityWriteReference(curEntity); @@ -286,7 +286,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_GET_ENTITY_ROOT_PERMISSION if(!asset_manager.DoesEntityHaveRootPermission(curEntity)) return EvaluableNodeReference::Null(); - EntityReadReference entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[0]); + EntityReadReference entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[0]); return AllocReturn(asset_manager.DoesEntityHaveRootPermission(entity), immediate_result); } @@ -393,7 +393,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_CLONE_ENTITIES(EvaluableNo for(size_t i = 0; i < ocn.size(); i += 2) { //get the id of the source entity - Entity *source_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[i]); + Entity *source_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[i]); //need a source entity, and can't copy self! (that could cause badness) if(source_entity == nullptr || source_entity == curEntity) { @@ -748,7 +748,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_STORE_ENTITY(EvaluableNode //get the id of the source entity to store. Don't need to keep the reference because it won't be used once the source entety pointer is looked up //retrieve the entity after other parameters to minimize time in locks // and prevent deadlock if one of the params accessed the entity - EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReferenceFromInterpretedEvaluableNodeIDPath(ocn[1]); + EntityReadReference source_entity = InterpretNodeIntoRelativeSourceEntityReadReference(ocn[1]); if(source_entity == nullptr || source_entity == curEntity) return EvaluableNodeReference::Null();