예제 #1
0
 @Override
 public ICPPEvaluation computeForFunctionCall(
     CPPFunctionParameterMap parameterMap, int maxdepth, IASTNode point) {
   ICPPEvaluation eval = fValue.getEvaluation();
   if (eval == null) return this;
   eval = eval.computeForFunctionCall(parameterMap, maxdepth, point);
   if (eval == fValue.getEvaluation()) return this;
   return new EvalFixed(fType, fValueCategory, Value.create(eval));
 }
 public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation, IASTNode point) {
   Assert.isNotNull(evaluation);
   if (evaluation instanceof EvalFixed
       || point == null
       || evaluation.isTypeDependent()
       || evaluation.isValueDependent()) {
     fEvaluation = evaluation;
   } else {
     IValue value = evaluation.getValue(point);
     // Avoid nesting EvalFixed's as nesting causes the signature to be different.
     if (value.getEvaluation() instanceof EvalFixed) {
       fEvaluation = value.getEvaluation();
     } else {
       fEvaluation =
           new EvalFixed(
               evaluation.getTypeOrFunctionSet(point), evaluation.getValueCategory(point), value);
     }
   }
 }
예제 #3
0
  @Override
  public IValue getValue(IASTNode point) {
    if (isValueDependent()) return Value.create(this);

    if (getOverload(point) != null) {
      // TODO(sprigogin): Simulate execution of a function call.
      return Value.create(this);
    }

    switch (fOperator) {
      case op_sizeof:
        {
          SizeAndAlignment info =
              SizeofCalculator.getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
          return info == null ? Value.UNKNOWN : Value.create(info.size);
        }
      case op_alignOf:
        {
          SizeAndAlignment info =
              SizeofCalculator.getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
          return info == null ? Value.UNKNOWN : Value.create(info.alignment);
        }
      case op_noexcept:
        return Value.UNKNOWN; // TODO(sprigogin): Implement
      case op_sizeofParameterPack:
        return Value.UNKNOWN; // TODO(sprigogin): Implement
      case op_typeid:
        return Value.UNKNOWN; // TODO(sprigogin): Implement
      case op_throw:
        return Value.UNKNOWN; // TODO(sprigogin): Implement
    }

    IValue val = fArgument.getValue(point);
    if (val == null) return Value.UNKNOWN;

    Long num = val.numericalValue();
    if (num != null) {
      return Value.evaluateUnaryExpression(fOperator, num);
    }
    return Value.create(this);
  }
예제 #4
0
 public EvalFixed(IType type, ValueCategory cat, IValue value) {
   if (type instanceof CPPBasicType) {
     Long num = value.numericalValue();
     if (num != null) {
       CPPBasicType t = (CPPBasicType) type.clone();
       t.setAssociatedNumericalValue(num);
       type = t;
     }
   }
   fType = type;
   fValueCategory = cat;
   fValue = value;
 }
예제 #5
0
 private boolean isSatisfiedCaseStatement(
     ICPPExecution stmtExec,
     IValue controllerValue,
     ActivationRecord record,
     ConstexprEvaluationContext context) {
   if (stmtExec instanceof ExecCase) {
     ExecCase caseStmtExec = (ExecCase) stmtExec;
     caseStmtExec = (ExecCase) caseStmtExec.executeForFunctionCall(record, context);
     Number caseVal = caseStmtExec.getCaseExpressionEvaluation().getValue(null).numberValue();
     Number controllerVal = controllerValue.numberValue();
     return caseVal.equals(controllerVal);
   }
   return stmtExec instanceof ExecDefault;
 }
예제 #6
0
 @Override
 public String toString() {
   if (fValue != null) return fValue.toString();
   return fType.toString();
 }
예제 #7
0
 public boolean isSameValue(ICPPTemplateArgument arg) {
   if (fValue != null) {
     return fValue.equals(arg.getNonTypeValue());
   }
   return fType.isSameType(arg.getTypeValue());
 }