// // Connect two nodes through an index operator, where the left node is the base // of an array or struct, and the right node is a direct or indirect offset. // // Returns the added node. // The caller should set the type of the returned node. // TIntermTyped *TIntermediate::addIndex(TOperator op, TIntermTyped *base, TIntermTyped *index, const TSourceLoc &line, TDiagnostics *diagnostics) { TIntermBinary *node = new TIntermBinary(op, base, index); node->setLine(line); TIntermTyped *folded = node->fold(diagnostics); if (folded) { return folded; } return node; }
// // Connect two nodes with a new parent that does a binary operation on the nodes. // // Returns the added node. // TIntermTyped *TIntermediate::addBinaryMath( TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &line) { // // Need a new node holding things together then. Make // one and promote it to the right type. // TIntermBinary *node = new TIntermBinary(op); node->setLine(line); node->setLeft(left); node->setRight(right); if (!node->promote(mInfoSink)) return NULL; // See if we can fold constants. TIntermTyped *foldedNode = node->fold(mInfoSink); if (foldedNode) return foldedNode; return node; }