FAUST compiler  0.9.9.6b8
binop.cpp
Go to the documentation of this file.
1 /************************************************************************
2  ************************************************************************
3  FAUST compiler
4  Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5  ---------------------------------------------------------------------
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  ************************************************************************
20  ************************************************************************/
21 
22 
23 
24 #include "binop.hh"
25 
26 static bool noNtrl(const Node& n) { return false; }
27 
29 
30  new BinOp("+","add_vec","add_scal", &addNode, &isZero, &isZero, 6),
31  new BinOp("-","sub_vec","sub_scal", &subNode, &noNtrl, &isZero, 7),
32  new BinOp("*","mul_vec","mul_scal", &mulNode, &isOne, &isOne, 8),
33  new BinOp("/","div_vec","div_scal", &divExtendedNode, &noNtrl, &isOne, 10),
34  new BinOp("%","mod_vec","mod_scal", &remNode, &noNtrl, &noNtrl, 9),
35 
36  new BinOp("<<","shift_left_vec","shift_left_scal", &lshNode, &noNtrl, &isZero, 8),
37  new BinOp(">>","shift_right_vec","shift_right_scal", &rshNode, &noNtrl, &isZero, 8),
38 
39  new BinOp(">","gt_vec","gt_scal", &gtNode, &noNtrl, &noNtrl, 5),
40  new BinOp("<","lt_vec","lt_scal", &ltNode, &noNtrl, &noNtrl, 5),
41  new BinOp(">=","ge_vec","ge_scal", &geNode, &noNtrl, &noNtrl, 5),
42  new BinOp("<=","le_vec","le_scal", &leNode, &noNtrl, &noNtrl, 5),
43  new BinOp("==","eq_vec","eq_scal", &eqNode, &noNtrl, &noNtrl, 5),
44  new BinOp("!=","neq_vec","neq_scal", &neNode, &noNtrl, &noNtrl, 5),
45 
46  new BinOp("&","and_vec","and_scal", &andNode, &isMinusOne, &isMinusOne, 8),
47  new BinOp("|","or_vec","or_scal", &orNode, &isZero, &isZero, 7),
48  new BinOp("^","xor_vec","xor_scal", &xorNode, &noNtrl, &noNtrl, 8)
49 };
50 
51 
53 
54  new BinOp("+","add_vec","add_scal", &addNode, &isZero, &isZero, 6),
55  new BinOp("-","sub_vec","sub_scal", &subNode, &noNtrl, &isZero, 7),
56  new BinOp("*","mul_vec","mul_scal", &mulNode, &isOne, &isOne, 8), // \DeclareMathSymbol{*}{\mathbin}{symbols}{"01}
57  new BinOp("/","div_vec","div_scal", &divExtendedNode, &noNtrl, &isOne, 10), // \frac{}{} used in generateBinOp
58  new BinOp("\\bmod","mod_vec","mod_scal", &remNode, &noNtrl, &noNtrl, 9),
59 
60  new BinOp("\\hiderel{\\ll}","shift_left_vec","shift_left_scal", &lshNode, &noNtrl, &isZero, 8),
61  new BinOp("\\hiderel{\\gg}","shift_right_vec","shift_right_scal", &rshNode, &noNtrl, &isZero, 8),
62 
63  new BinOp("\\hiderel{>}","gt_vec","gt_scal", &gtNode, &noNtrl, &noNtrl, 5),
64  new BinOp("\\hiderel{<}","lt_vec","lt_scal", &ltNode, &noNtrl, &noNtrl, 5),
65  new BinOp("\\hiderel{\\geq}","ge_vec","ge_scal", &geNode, &noNtrl, &noNtrl, 5),
66  new BinOp("\\hiderel{\\leq}","le_vec","le_scal", &leNode, &noNtrl, &noNtrl, 5),
67  new BinOp("\\hiderel{\\equiv}","eq_vec","eq_scal", &eqNode, &noNtrl, &noNtrl, 5),
68  new BinOp("\\hiderel{\\neq}","neq_vec","neq_scal", &neNode, &noNtrl, &noNtrl, 5),
69 
70  new BinOp("\\wedge","and_vec","and_scal", &andNode, &isMinusOne, &isMinusOne, 8),
71  new BinOp("\\vee","or_vec","or_scal", &orNode, &isZero, &isZero, 7),
72  new BinOp("\\veebar","xor_vec","xor_scal", &xorNode, &noNtrl, &noNtrl, 8)
73 };
const Node leNode(const Node &x, const Node &y)
Definition: node.hh:299
bool isZero(Tree a)
Definition: signals.hh:188
const Node eqNode(const Node &x, const Node &y)
Definition: node.hh:302
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node addNode(const Node &x, const Node &y)
Definition: node.hh:241
bool isOne(Tree a)
Definition: signals.hh:191
const Node divExtendedNode(const Node &x, const Node &y)
Definition: node.hh:250
const Node remNode(const Node &x, const Node &y)
Definition: node.hh:255
bool isMinusOne(Tree a)
Definition: signals.hh:192
const Node xorNode(const Node &x, const Node &y)
Definition: node.hh:284
BinOp * gBinOpLateqTable[]
Definition: binop.cpp:52
static bool noNtrl(const Node &n)
Definition: binop.cpp:26
const Node gtNode(const Node &x, const Node &y)
Definition: node.hh:290
const Node ltNode(const Node &x, const Node &y)
Definition: node.hh:293
const Node rshNode(const Node &x, const Node &y)
Definition: node.hh:272
const Node mulNode(const Node &x, const Node &y)
Definition: node.hh:247
const Node geNode(const Node &x, const Node &y)
Definition: node.hh:296
const Node neNode(const Node &x, const Node &y)
Definition: node.hh:305
const Node subNode(const Node &x, const Node &y)
Definition: node.hh:244
BinOp * gBinOpTable[]
Definition: binop.cpp:28
const Node lshNode(const Node &x, const Node &y)
Definition: node.hh:269
Definition: binop.hh:32
const Node andNode(const Node &x, const Node &y)
Definition: node.hh:278
const Node orNode(const Node &x, const Node &y)
Definition: node.hh:281