Merge pull request #362 from aws-lumberyard-dev/carlitosan-parser-fixes

Carlitosan parser fixes Fixes for branching runtime, nested user branch parse-error, unit tests for both. LYN-3338
This commit is contained in:
carlitosan
2021-04-27 15:52:44 -07:00
committed by GitHub
10 changed files with 4621 additions and 16 deletions
@@ -510,7 +510,7 @@ namespace ScriptCanvas
AZ_Assert(lua_isuserdata(lua, 1), "CallExecutionOut: Error in compiled lua file, 1st argument to SetExecutionOut is not userdata (Nodeable)");
AZ_Assert(lua_isnumber(lua, 2), "CallExecutionOut: Error in compiled lua file, 2nd argument to SetExecutionOut is not a number");
Nodeable* nodeable = AZ::ScriptValue<Nodeable*>::StackRead(lua, 1);
size_t index = aznumeric_caster(lua_tointeger(lua, -2));
size_t index = aznumeric_caster(lua_tointeger(lua, 2));
nodeable->CallOut(index, nullptr, nullptr, argsCount - 2);
// Lua: results...
return lua_gettop(lua);
@@ -697,7 +697,7 @@ namespace ScriptCanvas
AZ_Assert(lua_islightuserdata(lua, 2), "Error in compiled lua file, 2nd argument to UnpackDependencyArgs is not userdata (AZStd::vector<AZ::Data::Asset<RuntimeAsset>>*), but a :%s", lua_typename(lua, 2));
auto dependentAssets = reinterpret_cast<AZStd::vector<AZ::Data::Asset<RuntimeAsset>>*>(lua_touserdata(lua, 2));
AZ_Assert(lua_isinteger(lua, 3), "Error in compiled Lua file, 3rd argument to UnpackDependencyArgs is not a number");
const size_t dependentAssetsIndex = lua_tointeger(lua, 3);
const size_t dependentAssetsIndex = aznumeric_caster(lua_tointeger(lua, 3));
return DependencyConstructionPack{ executionState, dependentAssets, dependentAssetsIndex, (*dependentAssets)[dependentAssetsIndex].Get()->m_runtimeData };
}
@@ -3257,13 +3257,12 @@ namespace ScriptCanvas
return;
}
execution->SetNodeable(iter->second->m_nodeable);
child->SetNodeable(iter->second->m_nodeable);
for (auto& childOutSlot : childOutSlots)
{
AZ_Assert(childOutSlot, "null slot in child out slot list");
ExecutionTreePtr internalOut = OpenScope(child, node, childOutSlot);
internalOut->SetNodeable(execution->GetNodeable());
const size_t outIndex = node->GetOutIndex(*childOutSlot);
if (outIndex == std::numeric_limits<size_t>::max())
@@ -262,9 +262,6 @@ namespace ScriptCanvas
void SetSymbol(Symbol val);
protected:
VariableConstPtr m_nodeable;
private:
// the (possible) slot(s) through which execution exited, along with associated output
AZStd::vector<ExecutionChild> m_children;
@@ -316,6 +313,8 @@ namespace ScriptCanvas
Symbol m_symbol = Symbol::FunctionCall;
VariableConstPtr m_nodeable;
size_t FindIndexOfChild(ExecutionTreeConstPtr child) const;
};
@@ -276,7 +276,7 @@ namespace ScriptCanvas
if (IsMethodOverloaded() && BehaviorContextUtils::FindExplicitOverload(method, bcClass, className, methodName, &prettyClassName))
{
MethodConfiguration config(*method, method->IsMember() ? MethodType::Member : MethodType::Free);
MethodConfiguration config(*method, MethodType::Member);
config.m_class = bcClass;
config.m_namespaces = &m_namespaces;
config.m_className = &className;
@@ -582,7 +582,7 @@ namespace ScriptCanvas
void GraphToLua::TranslateExecutionTreeFunctionCall(Grammar::ExecutionTreeConstPtr execution)
{
TranslateNodeableOuts(execution);
TranslateNodeableOuts(execution->GetNodeable(), execution);
WriteDebugInfoIn(execution, "TranslateExecutionTreeFunctionCall begin");
m_dotLua.WriteIndent();
WriteLocalOutputInitialization(execution);
@@ -955,7 +955,7 @@ namespace ScriptCanvas
for (auto& out : nodeAndParse->m_latents)
{
m_dotLua.WriteNewLine();
TranslateNodeableOut(out.second);
TranslateNodeableOut(nodeAndParse->m_nodeable, out.second);
}
if (!nodeAndParse->m_latents.empty())
@@ -1017,7 +1017,7 @@ namespace ScriptCanvas
m_dotLua.WriteNewLine();
}
void GraphToLua::TranslateNodeableOut(Grammar::ExecutionTreeConstPtr execution)
void GraphToLua::TranslateNodeableOut(Grammar::VariableConstPtr host, Grammar::ExecutionTreeConstPtr execution)
{
auto outCallIndexOptional = execution->GetOutCallIndex();
if (!outCallIndexOptional)
@@ -1037,7 +1037,7 @@ namespace ScriptCanvas
m_dotLua.WriteLineIndented("%s(self.%s, %zu, -- %s"
, setExecutionOutName
, execution->GetNodeable()->m_name.data()
, host->m_name.data()
, outIndex
, execution->GetName().data());
@@ -1048,14 +1048,14 @@ namespace ScriptCanvas
m_dotLua.Outdent();
}
void GraphToLua::TranslateNodeableOuts(Grammar::ExecutionTreeConstPtr execution)
void GraphToLua::TranslateNodeableOuts(Grammar::VariableConstPtr host, Grammar::ExecutionTreeConstPtr execution)
{
const auto outs = execution->GetInternalOuts();
for (const auto& out : outs)
{
m_dotLua.WriteNewLine();
TranslateNodeableOut(out);
TranslateNodeableOut(host, out);
}
if (!outs.empty())
@@ -111,8 +111,8 @@ namespace ScriptCanvas
void TranslateFunctionBlock(Grammar::ExecutionTreeConstPtr execution, FunctionBlockConfig functionBlockConfig, IsNamed lex);
void TranslateFunctionDefinition(Grammar::ExecutionTreeConstPtr execution, IsNamed lex);
void TranslateInheritance();
void TranslateNodeableOut(Grammar::ExecutionTreeConstPtr execution);
void TranslateNodeableOuts(Grammar::ExecutionTreeConstPtr execution);
void TranslateNodeableOut(Grammar::VariableConstPtr host, Grammar::ExecutionTreeConstPtr execution);
void TranslateNodeableOuts(Grammar::VariableConstPtr host, Grammar::ExecutionTreeConstPtr execution);
void TranslateNodeableParse();
void TranslateStaticInitialization();
void TranslateVariableInitialization(AZStd::string_view leftValue);
@@ -100,6 +100,11 @@ TEST_F(ScriptCanvasTestFixture, InterpretedReadEnumConstant)
RunUnitTestGraph("LY_SC_UnitTest_ReadEnumConstant");
}
TEST_F(ScriptCanvasTestFixture, UserBranchSanityCheck)
{
RunUnitTestGraph("LY_SC_UnitTest_UserBranchSanityCheck");
}
TEST_F(ScriptCanvasTestFixture, InterpretedEventHandlerNoDisconnect)
{
GlobalHandler handler;