[Avida-SVN] r2494 - in development/source: script tools
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sun Mar 23 14:24:36 PDT 2008
Author: brysonda
Date: 2008-03-23 17:24:35 -0400 (Sun, 23 Mar 2008)
New Revision: 2494
Modified:
development/source/script/ASTree.h
development/source/script/AvidaScript.h
development/source/script/cASLibrary.cc
development/source/script/cDirectInterpretASTVisitor.cc
development/source/script/cDirectInterpretASTVisitor.h
development/source/script/cParser.cc
development/source/tools/cString.cc
development/source/tools/tDictionary.h
Log:
AS:
Cleanup function objects.
Implement matrix multiplication (un-optimized).
Modified: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/ASTree.h 2008-03-23 21:24:35 UTC (rev 2494)
@@ -72,15 +72,17 @@
private:
static const sASTypeInfo s_invalid_type;
-
cASTNode(); // @not_implemented
cASTNode(const cASTNode&); // @not_implemented
cASTNode& operator=(const cASTNode&); // @not_implmented
+
protected:
cASFilePosition m_file_pos;
+
cASTNode(const cASFilePosition& fp) : m_file_pos(fp) { ; }
+
public:
virtual ~cASTNode() { ; }
@@ -88,6 +90,9 @@
inline const cASFilePosition& GetFilePosition() const { return m_file_pos; }
+ virtual bool IsOutputSuppressed() const { return false; }
+ virtual void SuppressOutput() { ; }
+
virtual void Accept(cASTVisitor& visitor) = 0;
};
Modified: development/source/script/AvidaScript.h
===================================================================
--- development/source/script/AvidaScript.h 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/AvidaScript.h 2008-03-23 21:24:35 UTC (rev 2494)
@@ -162,6 +162,8 @@
AS_DIRECT_INTERPRET_ERR_INDEX_ERROR,
AS_DIRECT_INTERPRET_ERR_INVALID_ARRAY_SIZE,
AS_DIRECT_INTERPRET_ERR_KEY_NOT_FOUND,
+ AS_DIRECT_INTERPRET_ERR_MATRIX_OP_TYPE_MISMATCH,
+ AS_DIRECT_INTERPRET_ERR_MATRIX_SIZE_MISMATCH,
AS_DIRECT_INTERPRET_ERR_OBJECT_ASSIGN_FAIL,
AS_DIRECT_INTERPRET_ERR_TYPE_CAST,
AS_DIRECT_INTERPRET_ERR_UNDEFINED_TYPE_OP,
Modified: development/source/script/cASLibrary.cc
===================================================================
--- development/source/script/cASLibrary.cc 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/cASLibrary.cc 2008-03-23 21:24:35 UTC (rev 2494)
@@ -28,8 +28,10 @@
cASLibrary::~cASLibrary()
{
for (int i = 0; i < m_obj_tbl.GetSize(); i++) delete m_obj_tbl[i];
-
- // @TODO - cleanup function objects
+
+ tArray<const cASFunction*> fun_objs;
+ m_fun_dict.GetValues(fun_objs);
+ for (int i = 0; i < fun_objs.GetSize(); i++) delete fun_objs[i];
}
Modified: development/source/script/cDirectInterpretASTVisitor.cc
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.cc 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/cDirectInterpretASTVisitor.cc 2008-03-23 21:24:35 UTC (rev 2494)
@@ -34,6 +34,8 @@
#include "cStringUtil.h"
#include "cSymbolTable.h"
+#include "tMatrix.h"
+
using namespace AvidaScript;
@@ -199,7 +201,7 @@
sASTypeInfo var_type = node.GetVariable()->GetType();
node.GetValues()->Accept(*this);
- cLocalArray* arr = m_rvalue.as_array;
+ cLocalArray* arr = asArray(m_rtype, m_rvalue, node);
int var_idx = m_sp + var_id;
for (int i = 0; i < arr->GetSize(); i++) {
@@ -547,10 +549,11 @@
if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type, true);
switch (rettype) {
- case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) + asChar(rtype, rval, node); break;
- case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) + asInt(rtype, rval, node); break;
- case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) + asFloat(rtype, rval, node); break;
-
+ case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) + asChar(rtype, rval, node); break;
+ case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) + asInt(rtype, rval, node); break;
+ case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) + asFloat(rtype, rval, node); break;
+ case TYPE(MATRIX): matrixAdd(asMatrix(ltype, lval, node), asMatrix(rtype, rval, node), node); break;
+
case TYPE(STRING):
{
cString* l = asString(ltype, lval, node);
@@ -571,9 +574,6 @@
}
break;
- case TYPE(MATRIX): // @TODO - addition
- INTERPRET_ERROR(INTERNAL);
-
default:
INTERPRET_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_ADD)), mapType(rettype));
}
@@ -590,13 +590,11 @@
if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
switch (rettype) {
- case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) - asChar(rtype, rval, node); break;
- case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) - asInt(rtype, rval, node); break;
- case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) - asFloat(rtype, rval, node); break;
-
- case TYPE(MATRIX): // @TODO - subtraction
- INTERPRET_ERROR(INTERNAL);
-
+ case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) - asChar(rtype, rval, node); break;
+ case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) - asInt(rtype, rval, node); break;
+ case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) - asFloat(rtype, rval, node); break;
+ case TYPE(MATRIX): matrixSubtract(asMatrix(ltype, lval, node), asMatrix(rtype, rval, node), node); break;
+
default:
INTERPRET_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_ADD)), mapType(rettype));
}
@@ -613,12 +611,10 @@
if (rettype == TYPE(RUNTIME)) rettype = getRuntimeType(ltype.type, rtype.type);
switch (rettype) {
- case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) * asChar(rtype, rval, node); break;
- case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) * asInt(rtype, rval, node); break;
- case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) * asFloat(rtype, rval, node); break;
-
- case TYPE(MATRIX): // @TODO - multiplication
- INTERPRET_ERROR(INTERNAL);
+ case TYPE(CHAR): m_rvalue.as_char = asChar(ltype, lval, node) * asChar(rtype, rval, node); break;
+ case TYPE(INT): m_rvalue.as_int = asInt(ltype, lval, node) * asInt(rtype, rval, node); break;
+ case TYPE(FLOAT): m_rvalue.as_float = asFloat(ltype, lval, node) * asFloat(rtype, rval, node); break;
+ case TYPE(MATRIX): matrixMultiply(asMatrix(ltype, lval, node), asMatrix(rtype, rval, node), node); break;
default:
INTERPRET_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_ADD)), mapType(rettype));
@@ -1577,7 +1573,7 @@
}
default:
- INTERPRET_ERROR(TYPE_CAST, mapType(type), mapType(TYPE(CHAR)));
+ INTERPRET_ERROR(TYPE_CAST, mapType(type), mapType(TYPE(ARRAY)));
}
return false;
@@ -1874,6 +1870,307 @@
}
+void cDirectInterpretASTVisitor::matrixAdd(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node)
+{
+ INTERPRET_ERROR(INTERNAL); // @TODO - handle matrix add
+}
+
+
+void cDirectInterpretASTVisitor::matrixSubtract(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node)
+{
+ INTERPRET_ERROR(INTERNAL); // @TODO - handle matrix sub
+}
+
+
+void cDirectInterpretASTVisitor::matrixMultiply(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node)
+{
+ // Validate all values in matrix operands and determine operation type
+ ASType_t op_type = TYPE(INT);
+ for (int i = 0; i < m1->GetNumRows(); i++) {
+ cLocalArray* row = m1->GetRow(i);
+ for (int j = 0; j < m1->GetNumCols(); j++) {
+ switch (row->Get(j).type.type) {
+ case TYPE(BOOL):
+ case TYPE(CHAR):
+ case TYPE(INT):
+ case TYPE(STRING):
+ break;
+
+ case TYPE(FLOAT):
+ op_type = TYPE(FLOAT);
+ break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+ for (int i = 0; i < m2->GetNumRows(); i++) {
+ cLocalArray* row = m2->GetRow(i);
+ for (int j = 0; j < m2->GetNumCols(); j++) {
+ switch (row->Get(j).type.type) {
+ case TYPE(BOOL):
+ case TYPE(CHAR):
+ case TYPE(INT):
+ case TYPE(STRING):
+ break;
+
+ case TYPE(FLOAT):
+ op_type = TYPE(FLOAT);
+ break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+
+
+
+ if (m1->GetNumRows() == 1 && m1->GetNumCols() == 1) {
+ // left op scalar multiply
+
+ if (op_type == TYPE(INT)) matrixMultiply_ScalarInt(m1, m2, node);
+ else matrixMultiply_ScalarFloat(m1, m2, node);
+
+ } else if (m2->GetNumRows() == 1 && m2->GetNumCols() == 1) {
+ // right op scalar multiply
+
+ if (op_type == TYPE(INT)) matrixMultiply_ScalarInt(m2, m1, node);
+ else matrixMultiply_ScalarFloat(m2, m1, node);
+
+ } else {
+ // full multiply
+
+ if (m1->GetNumCols() != m2->GetNumRows()) INTERPRET_ERROR(MATRIX_SIZE_MISMATCH, mapToken(TOKEN(OP_MUL)));
+
+ if (op_type == TYPE(INT)) matrixMultiply_FullInt(m1, m2, node);
+ else matrixMultiply_FullFloat(m1, m2, node);
+ }
+}
+
+void cDirectInterpretASTVisitor::matrixMultiply_ScalarInt(cLocalMatrix* s, cLocalMatrix* m, cASTNode& node)
+{
+ int scalar = 0;
+ tMatrix<int> op(m->GetNumRows(), m->GetNumCols());
+
+ const sAggregateValue& val = s->GetRow(0)->Get(0);
+ switch (val.type.type) {
+ case TYPE(BOOL): scalar = (val.value.as_bool) ? 1 : 0; break;
+ case TYPE(CHAR): scalar = (int)val.value.as_char; break;
+ case TYPE(INT): scalar = val.value.as_int; break;
+ case TYPE(STRING): scalar = val.value.as_string->AsInt(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(val.type));
+ }
+
+ for (int i = 0; i < m->GetNumRows(); i++) {
+ cLocalArray* row = m->GetRow(i);
+ for (int j = 0; j < m->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op[i][j] = (val.value.as_bool) ? 1 : 0; break;
+ case TYPE(CHAR): op[i][j] = (int)val.value.as_char; break;
+ case TYPE(INT): op[i][j] = val.value.as_int; break;
+ case TYPE(STRING): op[i][j] = val.value.as_string->AsInt(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+
+ int sz_x = m->GetNumRows();
+ int sz_y = m->GetNumCols();
+ cLocalMatrix* mat = new cLocalMatrix();
+ mat->Resize(sz_x, sz_y);
+
+ sASTypeInfo op_type(TYPE(INT));
+ for (int i = 0; i < sz_x; i++) {
+ cLocalArray* row = mat->GetRow(i);
+ for (int j = 0; j < sz_y; j++) {
+ uAnyType val;
+ val.as_int = scalar * op[i][j];
+ row->Set(j, op_type, val);
+ }
+ }
+
+ m_rvalue.as_matrix = mat;
+ m_rtype = TYPE(MATRIX);
+}
+
+void cDirectInterpretASTVisitor::matrixMultiply_ScalarFloat(cLocalMatrix* s, cLocalMatrix* m, cASTNode& node)
+{
+ double scalar = 0.0;
+ tMatrix<double> op(m->GetNumRows(), m->GetNumCols());
+
+ const sAggregateValue& val = s->GetRow(0)->Get(0);
+ switch (val.type.type) {
+ case TYPE(BOOL): scalar = (val.value.as_bool) ? 1.0 : 0.0; break;
+ case TYPE(CHAR): scalar = (double)val.value.as_char; break;
+ case TYPE(INT): scalar = (double)val.value.as_int; break;
+ case TYPE(FLOAT): scalar = val.value.as_float; break;
+ case TYPE(STRING): scalar = val.value.as_string->AsDouble(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(val.type));
+ }
+
+ for (int i = 0; i < m->GetNumRows(); i++) {
+ cLocalArray* row = m->GetRow(i);
+ for (int j = 0; j < m->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op[i][j] = (val.value.as_bool) ? 1.0 : 0.0; break;
+ case TYPE(CHAR): op[i][j] = (double)val.value.as_char; break;
+ case TYPE(INT): op[i][j] = (double)val.value.as_int; break;
+ case TYPE(FLOAT): op[i][j] = val.value.as_float; break;
+ case TYPE(STRING): op[i][j] = val.value.as_string->AsDouble(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+
+ int sz_x = m->GetNumRows();
+ int sz_y = m->GetNumCols();
+ cLocalMatrix* mat = new cLocalMatrix();
+ mat->Resize(sz_x, sz_y);
+
+ sASTypeInfo op_type(TYPE(FLOAT));
+ for (int i = 0; i < sz_x; i++) {
+ cLocalArray* row = mat->GetRow(i);
+ for (int j = 0; j < sz_y; j++) {
+ uAnyType val;
+ val.as_float = scalar * op[i][j];
+ row->Set(j, op_type, val);
+ }
+ }
+
+ m_rvalue.as_matrix = mat;
+ m_rtype = TYPE(MATRIX);
+}
+
+void cDirectInterpretASTVisitor::matrixMultiply_FullInt(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node)
+{
+ tMatrix<int> op1(m1->GetNumRows(), m1->GetNumCols());
+ tMatrix<int> op2(m2->GetNumRows(), m2->GetNumCols());
+
+ for (int i = 0; i < m1->GetNumRows(); i++) {
+ cLocalArray* row = m1->GetRow(i);
+ for (int j = 0; j < m1->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op1[i][j] = (val.value.as_bool) ? 1 : 0; break;
+ case TYPE(CHAR): op1[i][j] = (int)val.value.as_char; break;
+ case TYPE(INT): op1[i][j] = val.value.as_int; break;
+ case TYPE(STRING): op1[i][j] = val.value.as_string->AsInt(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+ for (int i = 0; i < m2->GetNumRows(); i++) {
+ cLocalArray* row = m2->GetRow(i);
+ for (int j = 0; j < m2->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op2[i][j] = (val.value.as_bool) ? 1 : 0; break;
+ case TYPE(CHAR): op2[i][j] = (int)val.value.as_char; break;
+ case TYPE(INT): op2[i][j] = val.value.as_int; break;
+ case TYPE(STRING): op2[i][j] = val.value.as_string->AsInt(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+
+ int sz_x = m1->GetNumRows();
+ int sz_y = m2->GetNumCols();
+ cLocalMatrix* mat = new cLocalMatrix();
+ mat->Resize(sz_x, sz_y);
+
+ sASTypeInfo op_type(TYPE(INT));
+ for (int i = 0; i < sz_x; i++) {
+ cLocalArray* row = mat->GetRow(i);
+ for (int j = 0; j < sz_y; j++) {
+ uAnyType sum;
+ sum.as_int = 0;
+ for (int k = 0; k < m1->GetNumCols(); k++) sum.as_int += op1[i][k] * op2[k][j];
+ row->Set(j, op_type, sum);
+ }
+ }
+
+ m_rvalue.as_matrix = mat;
+ m_rtype = TYPE(MATRIX);
+}
+
+
+void cDirectInterpretASTVisitor::matrixMultiply_FullFloat(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node)
+{
+ tMatrix<double> op1(m1->GetNumRows(), m1->GetNumCols());
+ tMatrix<double> op2(m2->GetNumRows(), m2->GetNumCols());
+
+ for (int i = 0; i < m1->GetNumRows(); i++) {
+ cLocalArray* row = m1->GetRow(i);
+ for (int j = 0; j < m1->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op1[i][j] = (val.value.as_bool) ? 1.0 : 0.0; break;
+ case TYPE(CHAR): op1[i][j] = (double)val.value.as_char; break;
+ case TYPE(INT): op1[i][j] = (double)val.value.as_int; break;
+ case TYPE(FLOAT): op1[i][j] = val.value.as_float; break;
+ case TYPE(STRING): op1[i][j] = val.value.as_string->AsDouble(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+ for (int i = 0; i < m2->GetNumRows(); i++) {
+ cLocalArray* row = m2->GetRow(i);
+ for (int j = 0; j < m2->GetNumCols(); j++) {
+ const sAggregateValue& val = row->Get(j);
+ switch (val.type.type) {
+ case TYPE(BOOL): op2[i][j] = (val.value.as_bool) ? 1.0 : 0.0; break;
+ case TYPE(CHAR): op2[i][j] = (double)val.value.as_char; break;
+ case TYPE(INT): op2[i][j] = (double)val.value.as_int; break;
+ case TYPE(FLOAT): op2[i][j] = val.value.as_float; break;
+ case TYPE(STRING): op2[i][j] = val.value.as_string->AsDouble(); break;
+
+ default:
+ INTERPRET_ERROR(MATRIX_OP_TYPE_MISMATCH, mapToken(TOKEN(OP_MUL)), mapType(row->Get(j).type));
+ }
+ }
+ }
+
+ int sz_x = m1->GetNumRows();
+ int sz_y = m2->GetNumCols();
+ cLocalMatrix* mat = new cLocalMatrix();
+ mat->Resize(sz_x, sz_y);
+
+ sASTypeInfo op_type(TYPE(FLOAT));
+ for (int i = 0; i < sz_x; i++) {
+ cLocalArray* row = mat->GetRow(i);
+ for (int j = 0; j < sz_y; j++) {
+ uAnyType sum;
+ sum.as_float = 0.0;
+ for (int k = 0; k < m1->GetNumCols(); k++) sum.as_float += op1[i][k] * op2[k][j];
+ row->Set(j, op_type, sum);
+ }
+ }
+
+ m_rvalue.as_matrix = mat;
+ m_rtype = TYPE(MATRIX);
+}
+
+
+
+
void cDirectInterpretASTVisitor::sAggregateValue::Cleanup()
{
switch (type.type) {
@@ -2413,6 +2710,16 @@
case AS_DIRECT_INTERPRET_ERR_KEY_NOT_FOUND:
std::cerr << "key not found" << ERR_ENDL;
break;
+ case AS_DIRECT_INTERPRET_ERR_MATRIX_OP_TYPE_MISMATCH:
+ {
+ const char* op = VA_ARG_STR;
+ const char* type = VA_ARG_STR;
+ std::cerr << "matrix '" << op << "' undefined for contained value of type '" << type << "'" << ERR_ENDL;
+ }
+ break;
+ case AS_DIRECT_INTERPRET_ERR_MATRIX_SIZE_MISMATCH:
+ std::cerr << "matrix size mismatch for '" << VA_ARG_STR << "' operation" << ERR_ENDL;
+ break;
case AS_DIRECT_INTERPRET_ERR_OBJECT_ASSIGN_FAIL:
std::cerr << "aggregate assignment failed" << ERR_ENDL;
break;
Modified: development/source/script/cDirectInterpretASTVisitor.h
===================================================================
--- development/source/script/cDirectInterpretASTVisitor.h 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/cDirectInterpretASTVisitor.h 2008-03-23 21:24:35 UTC (rev 2494)
@@ -133,9 +133,18 @@
double asFloat(const sASTypeInfo& type, uAnyType value, cASTNode& node);
cLocalMatrix* asMatrix(const sASTypeInfo& type, uAnyType value, cASTNode& node);
cString* asString(const sASTypeInfo& type, uAnyType value, cASTNode& node);
-
+
ASType_t getRuntimeType(ASType_t ltype, ASType_t rtype, bool allow_str = false);
+ void matrixAdd(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node);
+ void matrixSubtract(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node);
+
+ void matrixMultiply(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node);
+ void matrixMultiply_ScalarInt(cLocalMatrix* s, cLocalMatrix* m, cASTNode& node);
+ void matrixMultiply_ScalarFloat(cLocalMatrix* s, cLocalMatrix* m, cASTNode& node);
+ void matrixMultiply_FullInt(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node);
+ void matrixMultiply_FullFloat(cLocalMatrix* m1, cLocalMatrix* m2, cASTNode& node);
+
void reportError(ASDirectInterpretError_t err, const cASFilePosition& fp, const int line, ...);
Modified: development/source/script/cParser.cc
===================================================================
--- development/source/script/cParser.cc 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/script/cParser.cc 2008-03-23 21:24:35 UTC (rev 2494)
@@ -991,13 +991,10 @@
return sl.Release();
}
- if (node.IsNull()) {
- // Some error has occured, so terminate early
- if (m_success) PARSE_ERROR(INTERNAL); // Should not receive a null response without an error flag
- }
+ if (node.IsNull() && m_success) PARSE_ERROR(INTERNAL); // Should not receive a null response without an error flag
if (currentToken() == TOKEN(SUPPRESS)) {
- // @TODO - mark output as suppressed
+ if (!node.IsNull()) (*node).SuppressOutput();
} else if (currentToken() != TOKEN(ENDL)) {
PARSE_ERROR(UNTERMINATED_EXPR);
}
Modified: development/source/tools/cString.cc
===================================================================
--- development/source/tools/cString.cc 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/tools/cString.cc 2008-03-23 21:24:35 UTC (rev 2494)
@@ -300,7 +300,7 @@
cString cString::Substring(int start, int size) const
{
- assert(size > 0); // Non-Positive Size
+ assert(size >= 0); // Non-Positive Size
assert(start >= 0); // Negative Position
assert(start + size <= GetSize()); // Position+Size Past End of String
Modified: development/source/tools/tDictionary.h
===================================================================
--- development/source/tools/tDictionary.h 2008-03-23 18:47:51 UTC (rev 2493)
+++ development/source/tools/tDictionary.h 2008-03-23 21:24:35 UTC (rev 2494)
@@ -77,6 +77,9 @@
m_hash.AsLists(name_list, value_list);
}
inline void GetKeys(tList<cString>& names) const { m_hash.GetKeys(names); }
+ inline void GetKeys(tArray<cString>& names) const { m_hash.GetKeys(names); }
+ inline void GetValues(tList<T>& values) const { m_hash.GetValues(values); }
+ inline void GetValues(tArray<T>& values) const { m_hash.GetValues(values); }
// This function will take an input string and load its value into the
// dictionary; it will only work for types that cStringUtil can convert to.
More information about the Avida-cvs
mailing list