コード例 #1
0
ファイル: ASTNodes.hpp プロジェクト: atgeirr/equelle
 Dimension dimension() const
 {
     EquelleType t = expr_to_norm_->type();
     if (isNumericType(t.basicType())) {
         // The norm of a Scalar or Vector has the same dimension
         // as the Scalar or Vector itself.
         return expr_to_norm_->dimension();
     } else {
         // Taking the norm of a grid entity.
         // Note: for now we always assume 3d for the
         // purpose of dimensions of these types.
         Dimension d;
         switch (t.basicType()) {
         case Vertex:
             // 0-dimensional.
             break;
         case Edge:
             d.setCoefficient(Length, 1);
             break;
         case Face:
             d.setCoefficient(Length, 2);
             break;
         case Cell:
             d.setCoefficient(Length, 3);
             break;
         default:
             throw std::logic_error("internal compiler error in NormNode::dimension().");
         }
         return d;
     }
 }
コード例 #2
0
ファイル: ASTNodes.hpp プロジェクト: atgeirr/equelle
 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();
     }
 }
コード例 #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;
     }
 }
コード例 #4
0
ファイル: ASTNodes.hpp プロジェクト: atgeirr/equelle
 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);
 }
コード例 #5
0
ファイル: ASTNodes.hpp プロジェクト: atgeirr/equelle
 EquelleType type() const
 {
     // Either erpr_ must be an Array, or, if not,
     // we must be a (Collection Of) Scalar,
     // since expr_ must be a (Collection Of) Vector.
     EquelleType t = expr_->type();
     if (t.isArray()) {
         t.setArraySize(NotAnArray);
         return t;
     } else {
         assert(t.basicType() == Vector);
         t.setBasicType(Scalar);
         return t;
     }
 }
コード例 #6
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
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
}