MCPcopy Create free account
hub / github.com/devosoft/avida / VisitUnpackTarget

Method VisitUnpackTarget

avida-core/source/script/cSemanticASTVisitor.cc:846–870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

844
845
846void cSemanticASTVisitor::VisitUnpackTarget(cASTUnpackTarget& node)
847{
848 node.GetExpression()->Accept(*this);
849
850 // Make sure that the expression can be used as an array
851 checkCast(node.GetExpression()->GetType(), TYPEINFO(ARRAY));
852
853 // Check each named variable and determine if it exists
854 for (int var = 0; var < node.GetSize(); var++) {
855 int var_id = -1;
856 bool global = false;
857 if (lookupVariable(node.GetVarName(var), var_id, global)) {
858 node.SetVar(var, var_id, global, (global ? m_global_symtbl : m_cur_symtbl)->GetVariableType(var_id));
859 } else {
860 SEMANTIC_ERROR(VARIABLE_UNDEFINED, (const char*)node.GetVarName(var));
861 }
862 }
863
864 // Check if last named is of array type
865 const int last = node.GetSize() - 1;
866 if (node.IsLastNamed() && node.GetVarID(last) != -1 && node.GetVarType(last) != TYPE(ARRAY))
867 SEMANTIC_ERROR(UNPACK_WILD_NONARRAY, (const char*)node.GetVarName(last));
868
869 // Rest of variable type checking must be done at runtime
870}
871
872void cSemanticASTVisitor::PostCheck()
873{

Callers

nothing calls this directly

Calls 7

AcceptMethod · 0.80
IsLastNamedMethod · 0.80
GetExpressionMethod · 0.45
GetTypeMethod · 0.45
GetSizeMethod · 0.45
SetVarMethod · 0.45
GetVarIDMethod · 0.45

Tested by

no test coverage detected