BOOST_FORCEINLINE result_type operator()(Expr& e) const { BOOST_ASSERT_MSG((isscalar( boost::proto::child_c<0>(e))&&issquare(boost::proto::child_c<1>(e)))|| (isscalar( boost::proto::child_c<1>(e))&&issquare(boost::proto::child_c<0>(e))), "mpower needs a square matrix expression and a scalar or a scalar and a square matrix expression"); return nt2::utility::max_extent(nt2::extent(boost::proto::child_c<0>(e)), nt2::extent(boost::proto::child_c<1>(e))); }
int askregvar(Symbol p, Symbol regs) { Symbol r; assert(p); if (p->sclass != REGISTER) return 0; else if (!isscalar(p->type)) { p->sclass = AUTO; return 0; } else if (p->temporary) { p->x.name = "?"; return 1; } else if ((r = askreg(regs, vmask)) != NULL) { p->x.regnode = r->x.regnode; p->x.regnode->vbl = p; p->x.name = r->x.name; debug(dumpregs("(allocating %s to symbol %s)\n", p->x.name, p->name)); return 1; } else { p->sclass = AUTO; return 0; } }
/* See if two C++ functions match */ static int fomatch(TYP *tp1, TYP *tp2) { SYM *sp1 = tp1->lst.head; SYM *sp2 = tp2->lst.head; if (sp1 == (SYM *)-1 && sp2 == (SYM *)-1) return TRUE; if (sp1 && sp1->defalt) return TRUE; while (sp2 && sp1) { if (sp1->tp->type == bt_ellipse) return TRUE; if (!exactype(sp1->tp, sp2->tp) && !(isscalar(tp1) && isscalar(tp2))) return FALSE; if (sp1->defalt) return TRUE; sp1 = sp1->next; sp2 = sp2->next; } return sp1 == sp2; }
SNODE *retstmt(void) /* * Handle return */ { SNODE *snp; TYP *tp; snp = xalloc(sizeof(SNODE)); snp->next = 0; snp->stype = st_return; snp->exp = 0; getsym(); if (lastst == end || lastst == semicolon) { if (currentfunc->tp->btp->type != bt_void) generror(ERR_RETMISMATCH,0,0); needpunc(semicolon,0); } else { int ogc = goodcode; goodcode |= GF_SUPERAND; tp = expression(&(snp->exp)); goodcode = ogc; if( lastst != eof) needpunc( semicolon, 0 ); if (tp->type == bt_void) { generror(ERR_NOVOIDRET,0,0); } else /* if (tp->type == bt_pointer && tp->val_flag) generror(ERR_NOFUNCARRAY,0,0); else */ if (!checktype(tp,currentfunc->tp->btp)) if (isscalar(tp) && isscalar(currentfunc->tp->btp)) promote_type(currentfunc->tp->btp, &(snp->exp)); else if (currentfunc->tp->btp->type != bt_pointer || floatrecurse(snp->exp)) generror(ERR_RETMISMATCH,0,0); } return snp; }
static int makeTemp(Symbol p) { if (!isscalar(p->type) || p->type->size == 8) { p->sclass = AUTO; return 0; } else if (p->sclass == AUTO) { if (p->addressed) { return 0; } else { return 1; } } else if (p->sclass == REGISTER) { return 1; } else { return 0; } }
Tree unary(void) { Tree p; switch (t) { case '*': t = gettok(); p = unary(); p = pointer(p); if (isptr(p->type) && (isfunc(p->type->type) || isarray(p->type->type))) p = retype(p, p->type->type); else { if (YYnull) p = nullcheck(p); p = rvalue(p); } break; case '&': t = gettok(); p = unary(); if (isarray(p->type) || isfunc(p->type)) p = retype(p, ptr(p->type)); else p = lvalue(p); if (isaddrop(p->op) && p->u.sym->sclass == REGISTER) error("invalid operand of unary &; `%s' is declared register\n", p->u.sym->name); else if (isaddrop(p->op)) p->u.sym->addressed = 1; break; case '+': t = gettok(); p = unary(); p = pointer(p); if (isarith(p->type)) p = cast(p, promote(p->type)); else typeerror(ADD, p, NULL); break; case '-': t = gettok(); p = unary(); p = pointer(p); if (isarith(p->type)) { Type ty = promote(p->type); p = cast(p, ty); if (isunsigned(ty)) { warning("unsigned operand of unary -\n"); p = simplify(ADD, ty, simplify(BCOM, ty, p, NULL), cnsttree(ty, 1UL)); } else p = simplify(NEG, ty, p, NULL); } else typeerror(SUB, p, NULL); break; case '~': t = gettok(); p = unary(); p = pointer(p); if (isint(p->type)) { Type ty = promote(p->type); p = simplify(BCOM, ty, cast(p, ty), NULL); } else typeerror(BCOM, p, NULL); break; case '!': t = gettok(); p = unary(); p = pointer(p); if (isscalar(p->type)) p = simplify(NOT, inttype, cond(p), NULL); else typeerror(NOT, p, NULL); break; case INCR: t = gettok(); p = unary(); p = incr(INCR, pointer(p), consttree(1, inttype)); break; case DECR: t = gettok(); p = unary(); p = incr(DECR, pointer(p), consttree(1, inttype)); break; case TYPECODE: case SIZEOF: { int op = t; Type ty; p = NULL; t = gettok(); if (t == '(') { t = gettok(); if (istypename(t, tsym)) { ty = typename(); expect(')'); } else { p = postfix(expr(')')); ty = p->type; } } else {
/* andtree - construct tree for l [&& ||] r */ static Tree andtree(int op, Tree l, Tree r) { if (!isscalar(l->type) || !isscalar(r->type)) typeerror(op, l, r); return simplify(op, inttype, cond(l), cond(r)); }
Slice Matrix<int>::toSlice(bool ind1) const { return isscalar() ? Slice(toScalar(), ind1) : Slice(data(), ind1); }
bool Matrix<int>::isSlice(bool ind1) const { return isscalar() || (iscolumn() && isdense() && Slice::isSlice(data(), ind1)); }