コード例 #1
0
ファイル: ESolver.cpp プロジェクト: BenCaulfield/sygus-comp14
    Expression ESolver::CreateExpression(const string& OperatorName,
                                         const Expression& Exp1,
                                         const Expression& Exp2,
                                         const Expression& Exp3)
    {
        // special case for bv extract

        if (OperatorName == "bvextract") {
            if (Exp2->As<UserConstExpression>() == nullptr ||
                Exp3->As<UserConstExpression>() == nullptr) {
                throw TypeException((string)"bvextract can only be applied to constant indices");
            }
            if (Exp2->GetType() != IntType ||
                Exp3->GetType() != IntType) {
                throw TypeException((string)"bvextract can only be applied to constant integer indices");
            }

            auto OpName = BVLogic::GetExtractOpName(Exp1->GetType(), 
                                                    Exp2->GetOp()->As<ConstOperator>()->GetConstantValue()->GetValue(), 
                                                    Exp3->GetOp()->As<ConstOperator>()->GetConstantValue()->GetValue());
            // recurse with new name
            auto Op = LookupOperator(OpName);
            if (Op == nullptr) {
                LoadedBVLogic->InstantiateExtractOperator(Exp1->GetType(), 
                                                          Exp2->GetOp()->As<ConstOperator>()->GetConstantValue()->GetValue(), 
                                                          Exp3->GetOp()->As<ConstOperator>()->GetConstantValue()->GetValue());
                Op = LookupOperator(OpName);
            }
            vector<Expression> Children = { Exp1 };
            return CreateExpression(Op, Children);
        }

        vector<Expression> Children(3);
        Children[0] = Exp1;
        Children[1] = Exp2;
        Children[2] = Exp3;
        return CreateExpression(OperatorName, Children);
    }
コード例 #2
0
ファイル: ESolver.cpp プロジェクト: BenCaulfield/sygus-comp14
 Expression ESolver::CreateExpression(const string& OperatorName,
                                      const vector<Expression>& Children)
 {
     vector<const ESFixedTypeBase*> ArgTypes;
     for(uint32 i = 0; i < Children.size(); ++i) {
         ArgTypes.push_back(Children[i]->GetType());
     }
     const OperatorBase* OpInfo = LookupOperator(OperatorName, ArgTypes);
     if(OpInfo == NULL) {
         throw TypeException((string)"No overloaded operator found for operator name: \"" +
                             OperatorName + "\"");
     }
     return CreateExpression(OpInfo, Children);
 }
コード例 #3
0
void
nsMathMLOperators::LookupOperators(const nsString&       aOperator,
                                   nsOperatorFlags*      aFlags,
                                   float*                aLeftSpace,
                                   float*                aRightSpace)
{
  if (!gInitialized) {
    InitGlobals();
  }

  aFlags[NS_MATHML_OPERATOR_FORM_INFIX] = 0;
  aLeftSpace[NS_MATHML_OPERATOR_FORM_INFIX] = 0.0f;
  aRightSpace[NS_MATHML_OPERATOR_FORM_INFIX] = 0.0f;

  aFlags[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0;
  aLeftSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0.0f;
  aRightSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = 0.0f;

  aFlags[NS_MATHML_OPERATOR_FORM_PREFIX] = 0;
  aLeftSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = 0.0f;
  aRightSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = 0.0f;

  if (gOperatorTable) {
    // a lookup with form=0 will put all the variants in gOperatorFound[]
    float dummy;
    nsOperatorFlags flags = 0;
    LookupOperator(aOperator, /*form=*/0, &flags, &dummy, &dummy);
    // if the operator was found, gOperatorFound contains all its variants
    OperatorData* found;
    found = gOperatorFound[NS_MATHML_OPERATOR_FORM_INFIX];
    if (found) {
      aFlags[NS_MATHML_OPERATOR_FORM_INFIX] = found->mFlags;
      aLeftSpace[NS_MATHML_OPERATOR_FORM_INFIX] = found->mLeftSpace;
      aRightSpace[NS_MATHML_OPERATOR_FORM_INFIX] = found->mRightSpace;
    }
    found = gOperatorFound[NS_MATHML_OPERATOR_FORM_POSTFIX];
    if (found) {
      aFlags[NS_MATHML_OPERATOR_FORM_POSTFIX] = found->mFlags;
      aLeftSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = found->mLeftSpace;
      aRightSpace[NS_MATHML_OPERATOR_FORM_POSTFIX] = found->mRightSpace;
    }
    found = gOperatorFound[NS_MATHML_OPERATOR_FORM_PREFIX];
    if (found) {
      aFlags[NS_MATHML_OPERATOR_FORM_PREFIX] = found->mFlags;
      aLeftSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = found->mLeftSpace;
      aRightSpace[NS_MATHML_OPERATOR_FORM_PREFIX] = found->mRightSpace;
    }
  }
}