EquelleType type() const { EquelleType lt = left_->type(); EquelleType rt = right_->type(); switch (op_) { case Add: return lt; // should be identical to rt. case Subtract: return lt; // should be identical to rt. case Multiply: { const bool isvec = lt.basicType() == Vector || rt.basicType() == Vector; const BasicType bt = isvec ? Vector : Scalar; const bool coll = lt.isCollection() || rt.isCollection(); const bool sequence = lt.isSequence() || rt.isSequence(); const CompositeType ct = coll ? Collection : (sequence ? Sequence : None); const int gm = lt.isCollection() ? lt.gridMapping() : rt.gridMapping(); return EquelleType(bt, ct, gm); } case Divide: { const BasicType bt = lt.basicType(); const bool coll = lt.isCollection() || rt.isCollection(); const int gm = lt.isCollection() ? lt.gridMapping() : rt.gridMapping(); return EquelleType(bt, coll ? Collection : None, gm); } default: yyerror("internal compiler error in BinaryOpNode::type()."); return EquelleType(); } }
CollectionTypeNode(TypeNode* btype, ExpressionNode* gridmapping, ExpressionNode* subsetof) : TypeNode(EquelleType()), btype_(btype), gridmapping_(gridmapping), subsetof_(subsetof) { // TODO. Check if this assert is what we want. // Is "Collection Of X On Y Subset Of Z" allowed? assert(gridmapping == nullptr || subsetof == nullptr); }
EquelleType type() const { EquelleType t = SymbolTable::getFunction(funcname_).returnType(funcargs_->argumentTypes()); if (dsr_ != NotApplicable) { assert(t.isEntityCollection()); return EquelleType(t.basicType(), Collection, dsr_, t.subsetOf(), t.isMutable(), t.isDomain()); } else { return t; } }
EquelleType type() const { EquelleType bt = btype_->type(); int gm = NotApplicable; if (gridmapping_) { gm = gridmapping_->type().gridMapping(); } int subset = NotApplicable; if (subsetof_) { gm = PostponedDefinition; subset = subsetof_->type().gridMapping(); } return EquelleType(bt.basicType(), Collection, gm, subset); }
TypeNode* handleSequenceType(TypeNode* type_expr) { SequenceTypeNode* tn = new SequenceTypeNode(type_expr); tn->setLocation(FileLocation(yylineno)); return tn; #if 0 const EquelleType et = type_expr->type(); if (!et.isBasic()) { yyerror("cannot create a Sequence of non-basic types."); } TypeNode* node = new TypeNode(EquelleType(et.basicType(), Sequence, et.gridMapping(), et.subsetOf())); node->setLocation(FileLocation(yylineno)); return node; #endif }
EquelleType type() const { // We do not want mutability of a variable to be passed on to // expressions involving that variable. if (SymbolTable::isVariableDeclared(varname_)) { EquelleType et = SymbolTable::variableType(varname_); if (et.isMutable()) { et.setMutable(false); } return et; } else if (SymbolTable::isFunctionDeclared(varname_)) { // Function reference. return EquelleType(); } else { throw std::logic_error("Internal compiler error in VarNode::type()."); } }
EquelleType type() const { return EquelleType(Scalar); }
EquelleType type() const { return EquelleType(); }
EquelleType type() const { // Functions' types cannot be expressed as an EquelleType return EquelleType(); }
EquelleType type() const { return EquelleType(left_->type().basicType(), Collection, right_->type().gridMapping(), left_->type().subsetOf()); }
EquelleType type() const { return EquelleType(Scalar, expr_to_norm_->type().compositeType(), expr_to_norm_->type().gridMapping()); }
EquelleType type() const { EquelleType lt = left_->type(); return EquelleType(Bool, lt.compositeType(), lt.gridMapping()); }
explicit MutableTypeNode(TypeNode* btype) : TypeNode(EquelleType()), btype_(btype) { }
explicit SequenceTypeNode(TypeNode* btype) : TypeNode(EquelleType()), btype_(btype) { }
ArrayTypeNode(TypeNode* btype, const int array_size) : TypeNode(EquelleType()), btype_(btype), array_size_(array_size) { }
EquelleType type() const { return EquelleType(String); }