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

Method VisitLiteralArray

avida-core/source/script/cDirectInterpretASTVisitor.cc:1359–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357
1358
1359void cDirectInterpretASTVisitor::VisitLiteralArray(cASTLiteralArray& node)
1360{
1361 cASTArgumentList* vals = node.GetValues();
1362
1363 if (node.IsMatrix()) {
1364 cLocalMatrix* mat = new cLocalMatrix();
1365
1366 int sz_y = 1;
1367 bool first = true;
1368
1369 tListIterator<cASTNode> it = vals->Iterator();
1370 cASTNode* val = NULL;
1371 int i = 0;
1372 while ((val = it.Next())) {
1373 val->Accept(*this);
1374 if (first && m_rtype.type == TYPE(ARRAY)) {
1375 sz_y = m_rvalue.as_array->GetSize();
1376 }
1377
1378 mat->Resize(i + 1, sz_y);
1379
1380 if (sz_y > 1) {
1381 if (m_rtype.type != TYPE(ARRAY)) INTERPRET_ERROR(INVALID_ARRAY_SIZE);
1382 mat->Set(i, m_rvalue.as_array);
1383 } else {
1384 mat->GetRow(i)->Set(0, m_rtype, m_rvalue);
1385 }
1386
1387 sAggregateValue val(m_rtype, m_rvalue);
1388 val.Cleanup();
1389 first = false;
1390 i++;
1391 }
1392
1393 m_rvalue.as_matrix = mat;
1394 m_rtype = TYPE(MATRIX);
1395 } else {
1396 cLocalArray* arr = new cLocalArray(vals->GetSize());
1397
1398 tListIterator<cASTNode> it = vals->Iterator();
1399 cASTNode* val = NULL;
1400 int i = 0;
1401 while ((val = it.Next())) {
1402 val->Accept(*this);
1403 arr->Set(i++, m_rtype.type, m_rvalue);
1404 }
1405
1406 m_rvalue.as_array = arr;
1407 m_rtype = TYPE(ARRAY);
1408 }
1409}
1410
1411void cDirectInterpretASTVisitor::VisitLiteralDict(cASTLiteralDict& node)
1412{

Callers

nothing calls this directly

Calls 10

IsMatrixMethod · 0.80
AcceptMethod · 0.80
GetRowMethod · 0.80
GetValuesMethod · 0.45
IteratorMethod · 0.45
NextMethod · 0.45
GetSizeMethod · 0.45
ResizeMethod · 0.45
SetMethod · 0.45
CleanupMethod · 0.45

Tested by

no test coverage detected