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; } }
TypeNode* handleStencilCollection(TypeNode* type_expr) { EquelleType et = type_expr->type(); et.setStencil(true); TypeNode* tn = new TypeNode(et); tn->setLocation(type_expr->location()); delete type_expr; return tn; }
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 { // We do not want mutability of a variable to be passed on to // expressions involving that variable. EquelleType et = SymbolTable::variableType(varname_); if (et.isMutable()) { et.setMutable(false); } return et; }
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* handleMutableType(TypeNode* type_expr) { MutableTypeNode* tn = new MutableTypeNode(type_expr); tn->setLocation(FileLocation(yylineno)); return tn; #if 0 EquelleType et = type_expr->type(); et.setMutable(true); TypeNode* tn = new TypeNode(et); tn->setLocation(type_expr->location()); delete type_expr; return tn; #endif }
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; } }
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()."); } }
TypeNode* handleArrayType(const int array_size, TypeNode* type_expr) { ArrayTypeNode* tn = new ArrayTypeNode(type_expr, array_size); tn->setLocation(FileLocation(yylineno)); return tn; #if 0 EquelleType et = type_expr->type(); if (et.isArray()) { yyerror("cannot create an Array of an Array."); return type_expr; } else { et.setArraySize(array_size); TypeNode* tn = new TypeNode(et); tn->setLocation(type_expr->location()); delete type_expr; return tn; } #endif }
EquelleType type() const { EquelleType lt = left_->type(); return EquelleType(Bool, lt.compositeType(), lt.gridMapping()); }
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(); } }
EquelleType type() const { EquelleType bt = btype_->type(); bt.setMutable(true); return bt; }
EquelleType type() const { EquelleType bt = btype_->type(); bt.setCompositeType(Sequence); return bt; }
EquelleType type() const { EquelleType bt = btype_->type(); bt.setArraySize(array_size_); return bt; }
EquelleType type() const { EquelleType t = expr_list_->arguments().front()->type(); t.setArraySize(expr_list_->arguments().size()); return t; }