Exemplo n.º 1
0
ex_expr::exp_return_type ExpLOBselect::eval(char *op_data[],
					    CollHeap*h,
					    ComDiagsArea** diagsArea)
{
  char * result = op_data[0];
  Lng32 rc = 0;
  Int64 uid;
  Lng32 lobType;
  Lng32 lobNum;
  Int64 descKey;
  Int16 flags;
  Int64 descTS = -1;
  short schNameLen = 0;
  char  schName[500];
  LobsSubOper so;
  Lng32 waitedOp = 0;
  Int64 lobLen = 0; 
  char *lobData = NULL;
  Lng32 cliError = 0;
  Lng32 lobOperStatus = checkLobOperStatus();
  if (lobOperStatus == DO_NOTHING_)
    return ex_expr::EXPR_OK;
  Int32 handleLen = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
  char * lobHandle = op_data[1];
  extractFromLOBhandle(&flags, &lobType, &lobNum, &uid,
		       &descKey, &descTS, 
		       &schNameLen, schName,
		       lobHandle);
  // select returns lobhandle only
  str_pad(result, getOperand(0)->getLength());
  str_cpy_all(result, lobHandle, strlen(lobHandle));
  
  return ex_expr::EXPR_OK;
}
ex_expr::exp_return_type ex_function_substring_doublebyte::eval(char *op_data[],
						 CollHeap* heap,
						 ComDiagsArea** diagsArea)
{
#pragma nowarn(1506)   // warning elimination 
  Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
#pragma warn(1506)  // warning elimination 

  len1 /= sizeof(NAWchar); // len1 now counts in terms of number of NCHARs.
  
  // Get the starting position from operand 2.
  Int64 start = *(Lng32 *)op_data[2];  
  
  // If operand 3 exists, get the length of substring from operand 3.
  // Otherwise, length of the substring is (len1 - start + 1).
  Int64 len = 0;
  Int64 temp = 0;
  if (getNumOperands() == 4)
    {
      len = *(Lng32 *)op_data[3];
      temp = start + len;
    }
  else
    {
      if (start > (len1 + 1)) 
	temp = start;
      else
	temp = len1 + 1;
    }
  
  // Check for error conditions.
  if (temp < start)
    {
      ExRaiseSqlError(heap, diagsArea, EXE_SUBSTRING_ERROR);
      return ex_expr::EXPR_ERROR;
    }
  
  Lng32 len0 = 0;
  if ((start <= len1) && (temp > 0)) 
    {
      if (start < 1)
        start = 1;
      if (temp > (len1 + 1))
        temp = len1 + 1;
      len0 = int64ToInt32(temp - start);     
    }

  len0 *= sizeof(NAWchar);  // convert the length back into the number of octets.
  
  // Result is always a varchar, so store the length of substring 
  // in the varlen indicator.
  getOperand(0)->setVarLength(len0, op_data[-MAX_OPERANDS]);
  
  // Now, copy the substring of operand 1 from the starting position into
  // operand 0, if len0 is greater than 0.
  if (len0 > 0) 
    str_cpy_all(op_data[0], &op_data[1][sizeof(NAWchar)*(int64ToInt32(start) - 1)], len0); 
  
  return ex_expr::EXPR_OK;
}
Exemplo n.º 3
0
//возвращает команду(5 цифр)
Comand getCmd(const string &str){
	Comand ret, buffer;
	init(buffer);
	char space = ' ';
	unsigned int buf = 0;
	int currentPos = 0;
	string word = getKeyword(str, currentPos);//возвращает ключевое слово
	buf =  getKeywordCode(word);//получаем код слова
	if(!buf){
		throw BadKeyword();
	}
	buffer.action = (unsigned short int)buf;//присвыаиваем номер команды
	currentPos++;
	if(isspace(str[currentPos])){
		throw SyntErrorSpace();
	}
	unsigned short int type; // переменная для типа
	buf =  getOperand(str, type, currentPos);//возвращает значение и тип операнда
	buffer.typeFirstOperand = type;
	buffer.firstOperand = buf;
	if(currentPos < str.size() && str[currentPos] != space){
		throw SyntErrorSpace();
	}
	currentPos++;
	if(currentPos < str.size()){
		buf =  getOperand(str,type, currentPos);
		buffer.typeSecondOperand = type;
		buffer.secondOperand = buf;
	}
	ret = buffer;//команда
	return ret;
}
ex_expr::exp_return_type ex_function_lower_unicode::eval(char *op_data[],
						 CollHeap*,
						 ComDiagsArea**)
{
  Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
  
  getOperand(0)->setVarLength(len1, op_data[-MAX_OPERANDS]);
  
  // Now, copy the contents of operand 1 after the case change into
  // operand 0.

  NAWchar* target = (NAWchar*)op_data[0];
  NAWchar* source = (NAWchar*)op_data[1];
  Int32 wc_len = len1/sizeof(NAWchar);

  for (Int32 i = 0; i < wc_len; i++)
    {
      //op_data[0][i] =  TOLOWER(op_data[1][i]); 
      //op_data[0][i] = '1';
      
     target[i] = unicode_char_set::to_lower(source[i]);
    }         
  
  return ex_expr::EXPR_OK;
};
Exemplo n.º 5
0
//  Implements the following "truth" table for the count aggregate (A=B+A).
//  A  B  result
//  x  y  call eval to compute A=1+A
//  x  N  do nothing (A=x)
//  N  y  set a to nonnull and zero and call eval to compute A=1+0
//  N  N  do nothing (A=N)
//
// LCOV_EXCL_START
ex_expr::exp_return_type 
ex_arith_count_clause::processNulls(char *null_data[],
				    CollHeap *heap,
				    ComDiagsArea **diagsArea)
{
  // If the first arg (B of A=B+A) is NULL, then do nothing
  //
  if(!null_data[1])
  {
    return ex_expr::EXPR_NULL;
  }

  // If the second arg (A of A=B+A) is NULL, zero it and call eval
  //
  if(!null_data[2])
  {
    ExpTupleDesc::clearNullValue(null_data[0],
                                 getOperand(0)->getNullBitIndex(),
                                 getOperand(0)->getTupleFormat() );
    str_pad(null_data[2*MAX_OPERANDS],getOperand(0)->getLength(), '\0');
    return ex_expr::EXPR_OK;
  }

  return ex_expr::EXPR_OK;
}
Exemplo n.º 6
0
/*
 * global function name(...)
 *      |
 *    *szData
 */
ptrdiff_t getGlobalFunctionName(char **szData, char *szFun) {
	char *p = *szData - 1;
	ptrdiff_t len = 0;

	szFun[0] = 0;
	char *pOp = getOperand(p, &len, true);
	if (len && !strncmp(pOp, "local", len))
		return 1;

	while (isSpace(*p))
		--p;
	while (isAlphaFun(*p))
		--p;

	*szData += 8; // strlen("function")
	p = *szData;

	while (*p && isSpace(*p))
		++p;

	if (*p) {
		char *pFunStart = p;
		while (*p && *p != '(')
			++p;
		while (*p && isSpace(*p))
			--p;
		size_t size = p - pFunStart;
		if (size)
			strncpy(szFun, pFunStart, size);
		szFun[size] = 0;
	}

	return p - *szData;
}
Exemplo n.º 7
0
// Subtracts the input from the specified register
// TODO: Verify overflow checking
bool SUR() {
  unsigned short int *reg = getRegister();
  unsigned short int addr = getAddrMode(machine.IR);
  unsigned short int operand = getOperand(machine.IR);
  int over = (int)*reg;

  *reg -= (addr == DIRECT ? main_memory[MMU(operand)] : operand);
  over -= (int)(addr == DIRECT ? main_memory[MMU(operand)] : operand);

  #ifdef DEBUG
  printDebug("SUR");
  #endif

  // Effect condition code; return false if overflow
  if (over == (int)*reg) {
    machine.CR = getCondCode(*reg);
  } else {
    #ifdef DEBUG_VERBOSE
    cerr << red;
    cerr << "!! OVERFLOW IN SUR()" << endl;
    cerr << normal;
    return false;
    #endif
  }
  return true;
}
Exemplo n.º 8
0
// Subtracts the input from rA
// TODO: Verify overflow checking
bool SUB() {
  unsigned short int addr = getAddrMode(machine.IR);
  unsigned short int operand = getOperand(machine.IR);
  int over = (int)machine.rA;

  machine.rA -= (addr == DIRECT ? main_memory[MMU(operand)] : operand);
  over -= (int)(addr == DIRECT ? main_memory[MMU(operand)] : operand);

  #ifdef DEBUG
  printDebug("SUB");
  #endif

  // If overflow occurs, return false
  if (over == (int)machine.rA) {
    machine.CR = getCondCode(machine.rA);
  } else {
    #ifdef DEBUG_VERBOSE
    cerr << red;
    cerr << "!! OVERFLOW IN SUB()" << endl;
    cerr << normal;
    return false;
    #endif
  }
  return true;
}
int traverse(struct enode* root)
{
	char op;
	int opnd1, opnd2;
	if (root == NULL)
	{
		return 0;
	}
	opnd1 = traverse(root->left);
	if (isOperator(root->data))
	{
		op = root->data[0];
	}
	else
	{
		opnd1 = getOperand(root->data);
		return opnd1;
	}
	opnd2 = traverse(root->right);
	switch (op)
	{
	case '+': return(opnd1 + opnd2); break;
	case '-':return(opnd1 - opnd2); break;
	case '*': return(opnd1*opnd2); break;
	}
}
Exemplo n.º 10
0
bool LLVMReachingDefsAnalysis::handleStoreInst(LLVMNode *storeNode, DefMap *df,
                                               PointsToSetT *&strong_update)
{
    bool changed = false;
    llvm::StoreInst *SI = cast<StoreInst>(storeNode->getValue());
    LLVMNode *ptrNode = getOperand(storeNode, SI->getPointerOperand(), 0);
    assert(ptrNode && "No pointer operand");

    // update definitions
    PointsToSetT& S = ptrNode->getPointsTo();
    // if we have only one concrete pointer (known pointer
    // with known offset), it is safe to do strong update
    if (S.size() == 1) {
        const Pointer& ptr = *S.begin();
        // NOTE: we don't have good mechanism to diferentiate
        // heap-allocated objects yet, so if the pointer points to heap,
        // we must do weak update
        if (ptr.isKnown() && !ptr.offset.isUnknown() && !ptr.pointsToHeap()) {
            changed |= df->update(ptr, storeNode);
            strong_update = &S;
            return changed;
        }

        // else fall-through to weak update
    }

    // weak update
    for (const Pointer& ptr : ptrNode->getPointsTo())
        changed |= df->add(ptr, storeNode);

    return changed;
}
Exemplo n.º 11
0
bool LLVMReachingDefsAnalysis::handleIntrinsicCall(LLVMNode *callNode,
                                                   CallInst *CI,
                                                   DefMap *df)
{
    bool changed = false;
    IntrinsicInst *I = cast<IntrinsicInst>(CI);
    Value *dest;

    switch (I->getIntrinsicID())
    {
        case Intrinsic::memmove:
        case Intrinsic::memcpy:
        case Intrinsic::memset:
            dest = I->getOperand(0);
            break;
        default:
            return handleUndefinedCall(callNode, CI, df);
    }

    LLVMNode *destNode = getOperand(callNode, dest, 1);
    assert(destNode && "No operand for intrinsic call");

    for (const Pointer& ptr : destNode->getPointsTo()) {
        // we could compute all the concrete offsets, but
        // these functions usually set the whole memory,
        // so if we use UNKNOWN_OFFSET, the effect is the same
        changed |= df->add(Pointer(ptr.obj, UNKNOWN_OFFSET), callNode);
    }

    return changed;
}
Exemplo n.º 12
0
bool LLVMReachingDefsAnalysis::handleUndefinedCall(LLVMNode *callNode,
                                                   CallInst *CI,
                                                   DefMap *df)
{
    bool changed = false;
    for (unsigned n = 1, e = callNode->getOperandsNum(); n < e; ++n) {
        Value *llvmOp = CI->getOperand(n - 1);
        if (!llvmOp->getType()->isPointerTy())
            continue;

        if (isa<Constant>(llvmOp->stripInBoundsOffsets()))
            continue;

        LLVMNode *op = getOperand(callNode, llvmOp, n);
        assert(op && "unhandled pointer operand in undef call");

        // with undefined call we must assume that any
        // memory that was passed via pointer was modified
        // and on unknown offset
        // XXX we should handle external globals too
        for (const Pointer& ptr : op->getPointsTo())
            changed |= df->add(Pointer(ptr.obj, UNKNOWN_OFFSET), callNode);
    }

    return changed;
}
Exemplo n.º 13
0
std::vector<Value *> User::getOperands() const {
  std::vector<Value *> OpV;
  for (unsigned OpN = 0; OpN < NumOperands; OpN++) {
    OpV.push_back(getOperand(OpN));
  }
  return OpV;
}
Exemplo n.º 14
0
const bool Expression::link(vector<Operator *> &expr)
{
	for(vector<Operator *>::iterator i = expr.begin(); i != expr.end(); i++)
	{
		switch((*i)->getFunc()->getArguments())
		{
		case 2:
			(*i)->setLeft(*getOperand(expr, i, 0));
		case 1:
			(*i)->setRight(*getOperand(expr, i, RIGHT));
		case 0:
			break;
		}
	}
	return true;
}
/**
* @brief Converts the given LLVM getelementptr instruction @a inst into
*        an expression in BIR.
*
* Note that @a inst type is @c llvm::User instead of @c llvm::GetElementPtrInst
* because this method can handle also constant getelementptr expression.
*/
ShPtr<Expression> LLVMInstructionConverter::convertGetElementPtrToExpression(
		llvm::User &inst) {
	auto pointedValue = inst.getOperand(0);

	if (auto globVar = llvm::dyn_cast<llvm::GlobalVariable>(pointedValue)) {
		if (getConverter()->storesStringLiteral(*globVar)) {
			return getInitializerAsConstString(globVar);
		}
	}

	auto it = llvm::gep_type_begin(inst);
	auto e = llvm::gep_type_end(inst);
	if (it != e) {
		ShPtr<Expression> base;
		auto index = getConverter()->convertValueToExpression(it.getOperand());
		auto cInt = cast<ConstInt>(index);
		if (cInt && cInt->isZero()) {
			base = getConverter()->convertValueToExpressionDirectly(pointedValue);
			++it;
		} else {
			base = getConverter()->convertValueToExpression(pointedValue);
		}

		return convertGEPIndices(base, it, e);
	}

	FAIL("unsupported getelementptr instruction: " << inst);
	return nullptr;
}
Exemplo n.º 16
0
int getLex()
{
    int n;

    /* --- skip spaces */
    while ( Pos < Len && S[Pos] == ' ' ) Pos++;
    if ( Pos >= Len ) return 0;

    /* --- check for operand */
    n = getOperand();

    /* --- check for function/variable/number */
    if ( n == 0 )
    {
        if ( isLetter(S[Pos]) )
        {
            getToken();
            n = getMathFunc();
            if ( n == 0 ) n = getVariable();
        }
        else if ( isDigit(S[Pos]) )
        {
            n = 7;
            Fvalue = getNumber();
        }
    }
    Pos++;
    PrevLex = CurLex;
    CurLex = n;
    return n;
}
Exemplo n.º 17
0
std::wstring Unary::put()
{
  return  getName() +
          putScripts() +
          L"(" +
          getOperand()->put() +
          L")";
}
Exemplo n.º 18
0
	void PartyShuffle::removeOperand()
	{
		try {
			xmmsv_coll_remove_operand( coll_, (*getOperand()).getColl() );
		}
		// don't throw an error if none
		catch (...) {}
	}
Exemplo n.º 19
0
	void Unary::removeOperand()
	{
		try {
			xmmsv_coll_remove_operand( coll_, (*getOperand()).getColl() );
		}
		/* don't throw an error if none */
		catch (...) {}
	}
Exemplo n.º 20
0
ex_expr::exp_return_type 
ExpLOBupdate::processNulls(char *null_data[], CollHeap *heap,
			   ComDiagsArea **diagsArea
			   )
{
  nullValue_ = 0;

  if ((getOperand(1)->getNullFlag()) &&    // nullable
      (! null_data[1]))                    // missing value 
    {
      ExpTupleDesc::setNullValue( null_data[0],
				  getOperand(0)->getNullBitIndex(),
				  getOperand(0)->getTupleFormat() );

      return ex_expr::EXPR_NULL;
    }
  
  if ((getOperand(2)->getNullFlag()) &&    // nullable
      (! null_data[2]))                    // missing value 
    {
      nullValue_ = 1;
    }

  // move 0 to the null bytes of result
  if (getOperand(0)->getNullFlag())
    {
      ExpTupleDesc::clearNullValue( null_data[0],
                                    getOperand(0)->getNullBitIndex(),
                                    getOperand(0)->getTupleFormat() );
    }

  return ex_expr::EXPR_OK;
}
Exemplo n.º 21
0
/////////////////////////////////////////////////
// class ex_aggr_min_max_clause
/////////////////////////////////////////////////
ex_expr::exp_return_type ex_aggr_min_max_clause::eval(char * op_data[],
						      CollHeap*,
						      ComDiagsArea **)
{
  ex_expr::exp_return_type retcode = ex_expr::EXPR_OK;
  
  // if the second expression is true, make child to be current
  // aggregate.
  if (*(Lng32 *)op_data[2] == 1)
    {
      if (getOperand(0)->getNullFlag())
        {
          // A pointer to the null indicators of the operands.
          //
          char **null_data = &op_data[-2 * ex_clause::MAX_OPERANDS];
          
	  if ((getOperand(1)->getNullFlag()) &&
	      (! null_data[1])) // missing value, indicates
	                        // child is null. Keep the current result.
	    return ex_expr::EXPR_OK;

          ExpTupleDesc::clearNullValue(null_data[0],
                                       getOperand(0)->getNullBitIndex(),
                                       getOperand(0)->getTupleFormat() );
        }

      if (getOperand(0)->getVCIndicatorLength() > 0)
	{
	  // variable length operand. Note that first child (operand1)
	  // and result have the SAME attributes for min/max aggr.
#pragma nowarn(1506)   // warning elimination 
	  Lng32 src_length = getOperand(1)->getLength(op_data[-MAX_OPERANDS + 1]);
#pragma warn(1506)  // warning elimination 
	  Lng32 tgt_length = getOperand(0)->getLength(); // max varchar length
	
	  str_cpy_all(op_data[0], op_data[1], src_length);
	  
	  // copy source length bytes to target length bytes.
	  // Note that the array index -MAX_OPERANDS will get to
	  // the corresponding varlen entry for that operand.
	  getOperand(0)->setVarLength(src_length, op_data[- MAX_OPERANDS]);
	}
      else
	{
	  str_cpy_all(op_data[0], op_data[1], getOperand(0)->getLength());
	}
    }
  
  return retcode;
}
Exemplo n.º 22
0
const Expression::OpIter Expression::getOperand(vector<Operator *> &expr, const Expression::OpIter &init, unsigned short flags)
{
	if(expr.empty())
	{
		printf("(from Expression::getOperand())\n > unprepared");
		return expr.end();
	}
	bool right = flags & RIGHT;
	bool skip = flags & SKIP;
	bool high = *(*init)->getLoc() == (right? '(':')');
	bool rep = true;
	OpIter i, best = expr.end();
	if(*((*init)->getLoc()-1) == ')' && !right && !skip)
	{
		i = getOperand(expr, init, SKIP);
		best = i;
		i--;
	}
	else
		i = init+(right? 1:-1);
	for( ; i != (right? expr.end():expr.begin()) && (rep? (!right? (*(*i)->getLoc() != '('):(*((*i)->getLoc()-1) != ')')):true); right? ++i:--i)
	{
		rep = true;
		if(!skip)
		{
			if(right? ((*i)->getFunc()->getPriority() >= (high? HIGH_PRIORITY:((*init)->getFunc()->getPriority()))):
				((*i)->getFunc()->getPriority() > (high? HIGH_PRIORITY:((*init)->getFunc()->getPriority()))))
				break;
			if((*i)->getFunc()->getPriority() <= (high? HIGH_PRIORITY:((*init)->getFunc()->getPriority())) &&
				(right? ((*i)->getFunc()->getPriority() >= (best == expr.end()? -1:(*best)->getFunc()->getPriority())):
				((*i)->getFunc()->getPriority() > (best == expr.end()? -1:(*best)->getFunc()->getPriority()))))
				best = i;
		}

		if(right? (*(*i)->getLoc() == '('):(*((*i)->getLoc()-1) == ')'))
		{
			i = getOperand(expr, i, (flags & RIGHT) | SKIP);
			right? i--:i++;
			rep = false;
		}
	}

	return skip? i:best;
}
Exemplo n.º 23
0
// Stores a value from a register to a memory location
bool STO() {
  unsigned short int operand = getOperand(machine.IR);
  unsigned short int *reg = getRegister();
  main_memory[MMU(operand)] = *reg;

  #ifdef DEBUG
  printDebug("STO");
  #endif
  return true;
}
Exemplo n.º 24
0
// Loads a value into a register
bool LOD() {
  unsigned short int addr = getAddrMode(machine.IR);
  unsigned short int operand = getOperand(machine.IR);
  unsigned short int *reg = getRegister();

  *reg = (addr == DIRECT ? main_memory[MMU(operand)] : operand);

  #ifdef DEBUG
  printDebug("LOD");
  #endif
  return true;
}
Exemplo n.º 25
0
// The IOR fuction will do the bitwise operation Or using the specified
// register, and the address of a value provided in the arguments
bool IOR() {
  unsigned short int *reg = getRegister();
  unsigned short int operand =  main_memory[MMU(getOperand(machine.IR))];
  unsigned short int result = (*reg | operand);

  *reg = result; // set the new result into the register specified

  machine.CR = getCondCode(*reg);

  #ifdef DEBUG
  printDebug("IOR");
  #endif
  return true;
}
Exemplo n.º 26
0
void User::replaceUsesOfWith(Value *From, Value *To) {
  if (From == To) return;   // Duh what?

  assert((!isa<Constant>(this) || isa<GlobalValue>(this)) &&
         "Cannot call User::replaceUsesOfWith on a constant!");

  for (unsigned i = 0, E = getNumOperands(); i != E; ++i)
    if (getOperand(i) == From) {  // Is This operand is pointing to oldval?
      // The side effects of this setOperand call include linking to
      // "To", adding "this" to the uses list of To, and
      // most importantly, removing "this" from the use list of "From".
      setOperand(i, To); // Fix it now...
    }
}
Exemplo n.º 27
0
ex_expr::exp_return_type ExpLOBfuncSubstring::eval(char *op_data[],
						   CollHeap *heap,
						   ComDiagsArea** diagsArea)
{

  Int32 len1_bytes = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
  Int32 startPos = *(Lng32 *)op_data[2];
  
  Int32 specifiedLen = len1_bytes;
  if (getNumOperands() == 4)
    specifiedLen = *(Lng32 *)op_data[3]; 

  return ex_expr::EXPR_OK;
}
Exemplo n.º 28
0
/* Direct addressing is allowed, provided the value in the memory location
is actually only using 8 bits. If the 8 highest-order bits contain anything,
that would be a reference to a memory location that does not exist (PC: 8bits)
and thus the JMP would return an error (essentially OutOfBounds) */
bool JMP() {
  unsigned short int addr = getAddrMode(machine.IR);
  unsigned short int jmpTo;
  if (addr == DIRECT) {
    jmpTo = main_memory[MMU(getOperand(machine.IR))];
    // Check high-order bits
    if ((jmpTo & 65280) != 0)
    return false;
  } else if (addr == IMMEDIATE) {
    jmpTo = getOperand(machine.IR);
  } else {
    return false;
  }

  // Set program counter to new address
  machine.PC = jmpTo;

  #ifdef DEBUG
  if (getOpcode(machine.IR) == 9)
  printDebug("JMP");
  #endif
  return true;
}
/**
* @brief Converts indices of LLVM getelementptr instruction.
*
* @param[in] base Pointed operand of LLVM getelementptr instruction converted
*                 to an expression in BIR.
* @param[in] start First index of LLVM getelementptr instruction to be converted.
* @param[in] end End of iterator through LLVM getelementptr instruction indices.
*/
ShPtr<Expression> LLVMInstructionConverter::convertGEPIndices(ShPtr<Expression> base,
		llvm::gep_type_iterator start, llvm::gep_type_iterator end) {
	auto indexOp = base;
	for (auto i = start; i != end; ++i) {
		auto index = getConverter()->convertValueToExpression(i.getOperand());
		if (i->isStructTy()) {
			auto indexInt = ucast<ConstInt>(index);
			indexOp = StructIndexOpExpr::create(indexOp, indexInt);
		} else {
			indexOp = ArrayIndexOpExpr::create(indexOp, index);
		}
	}

	return AddressOpExpr::create(indexOp);
}
Exemplo n.º 30
0
//  Implements the following "truth" table for the aggregate and
//  running sequence function sum.
//  A  B  result
//  x  y  call eval to compute A=x+y
//  x  N  set y to nonnull and zero and call eval to compute A=x+0
//  N  y  set x to nonnull and zero and call eval to compute A=0+y
//  N  N  set result to null.
//
ex_expr::exp_return_type 
ex_arith_sum_clause::processNulls(char *null_data[],
				  CollHeap *heap,
				  ComDiagsArea **diagsArea)
{
  // If both x and y are NULL, the result is NULL. Make it so and do not
  // call eval.
  //
  if(!null_data[1] && !null_data[2])
    {
      ExpTupleDesc::setNullValue(null_data[0],
                                 getOperand(0)->getNullBitIndex(),
                                 getOperand(0)->getTupleFormat() );
      return ex_expr::EXPR_NULL;
    }

  // If only x is NULL, then the result is y.
  //
  if(!null_data[1])
  {
    CopyAttributes(null_data[2*MAX_OPERANDS+0], null_data[0], 
		   null_data[MAX_OPERANDS+0], getOperand(0),
		   null_data[2*MAX_OPERANDS+2], null_data[2], 
		   null_data[MAX_OPERANDS+2], getOperand(2));
    return ex_expr::EXPR_NULL;
  }

  // If only y is NULL, then the result is x.
  //
  if(!null_data[2])
  {
    CopyAttributes(null_data[2*MAX_OPERANDS+0], null_data[0], 
		   null_data[MAX_OPERANDS+0], getOperand(0),
		   null_data[2*MAX_OPERANDS+1], null_data[1], 
		   null_data[MAX_OPERANDS+1], getOperand(1));
    return ex_expr::EXPR_NULL;
  }

  // Otherwise, set the result to not null and call eval to compute x+y.
  //
  ExpTupleDesc::clearNullValue(null_data[0],
                               getOperand(0)->getNullBitIndex(),
                               getOperand(0)->getTupleFormat() );
  return ex_expr::EXPR_OK;
}