Example #1
0
 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();
     }
 }
Example #2
0
 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);
 }
Example #3
0
 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;
     }
 }
Example #4
0
 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);
 }
Example #5
0
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
}
Example #6
0
 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().");
     }
 }
Example #7
0
 EquelleType type() const
 {
     return EquelleType(Scalar);
 }
Example #8
0
 EquelleType type() const
 {
     return EquelleType();
 }
Example #9
0
 EquelleType type() const
 {
     // Functions' types cannot be expressed as an EquelleType
     return EquelleType();
 }
Example #10
0
 EquelleType type() const
 {
     return EquelleType(left_->type().basicType(), Collection, right_->type().gridMapping(), left_->type().subsetOf());
 }
Example #11
0
 EquelleType type() const
 {
     return EquelleType(Scalar,
                        expr_to_norm_->type().compositeType(),
                        expr_to_norm_->type().gridMapping());
 }
Example #12
0
 EquelleType type() const
 {
     EquelleType lt = left_->type();
     return EquelleType(Bool, lt.compositeType(), lt.gridMapping());
 }
Example #13
0
 explicit MutableTypeNode(TypeNode* btype)
     : TypeNode(EquelleType()),
       btype_(btype)
 {
 }
Example #14
0
 explicit SequenceTypeNode(TypeNode* btype)
     : TypeNode(EquelleType()),
       btype_(btype)
 {
 }
Example #15
0
 ArrayTypeNode(TypeNode* btype, const int array_size)
     : TypeNode(EquelleType()),
       btype_(btype),
       array_size_(array_size)
 {
 }
Example #16
0
 EquelleType type() const
 {
     return EquelleType(String);
 }