void Expression::computeType() { TypedNode* child = dynamic_cast<TypedNode*>(children.at(0)); if (!child) { throw CompileError("Child of Expression must be a TypedNode"); } m_type = child->getType(); if (!m_type.get()) { throw CompileError("Child of Expression must have a Type"); } }
void TypeSpec::computeType() { // Extract the type of our expression tree, then delete all its nodes; they // are irrelevant, we don't want to actually evaluate them as if they were // code. TypedNode* child = dynamic_cast<TypedNode*>(children.at(0)); if (!child) { throw EvalError("Child of TypeSpec must be a TypedNode"); } m_type = child->getType(); if (!m_type.get()) { throw EvalError("Child of TypeSpec must have a Type"); } delete children.at(0); children.clear(); }