当前位置: 首页>>代码示例>>Java>>正文


Java OCLFeatureCall.getParameter方法代码示例

本文整理汇总了Java中net.ssehub.easy.varModel.cst.OCLFeatureCall.getParameter方法的典型用法代码示例。如果您正苦于以下问题:Java OCLFeatureCall.getParameter方法的具体用法?Java OCLFeatureCall.getParameter怎么用?Java OCLFeatureCall.getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.ssehub.easy.varModel.cst.OCLFeatureCall的用法示例。


在下文中一共展示了OCLFeatureCall.getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unpackConstraints

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Unpacks the constraints and extracts the values. This is currently just a workaround as long as the reasoner
 * is not able to work with that.
 * 
 * @param assng the attribute assignment to unpack
 * @param values the attribute-value-mapping (to be modified as a side effect)
 */
private void unpackConstraints(AttributeAssignment assng, Map<String, Value> values) {
    for (int r = 0; r < assng.getRealizingCount(); r++) {
        ConstraintSyntaxTree constr = assng.getRealizing(r).getConsSyntax();
        if (constr instanceof OCLFeatureCall) {
            OCLFeatureCall call = (OCLFeatureCall) constr;
            if (1 == call.getParameterCount() && OclKeyWords.ASSIGNMENT.equals(call.getOperation())) {
                ConstraintSyntaxTree p0 = call.getOperand();
                ConstraintSyntaxTree p1 = call.getParameter(0);
                if (p0 instanceof Variable && p1 instanceof ConstantValue) {
                    AbstractVariable var = ((Variable) p0).getVariable();
                    String key = var.getName();
                    if (!values.containsKey(key)) {
                        values.put(key, ((ConstantValue) p1).getConstantValue());
                    }
                }
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:DecisionVariable.java

示例2: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    if (null != call.getOperand()) { 
        if ((call.getOperand() instanceof Variable
            || call.getOperand() instanceof CompoundAccess)
            && call.getParameterCount() == 1
            && call.getOperation().equals(OclKeyWords.ASSIGNMENT)) {
            if (call.getParameter(0) instanceof ContainerInitializer) {
                isConstraintContainer = true;
                cst = call.getParameter(0);                    
            }
            if (call.getParameter(0) instanceof CompoundInitializer) {
                isCompoundInitializer = true;
                cst = call.getParameter(0);                     
            }
        }
        call.getOperand().accept(this);
        for (int i = 0; i < call.getParameterCount(); i++) {
            call.getParameter(i).accept(this);
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ContainerConstraintsFinder.java

示例3: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    if (null != call.getOperand()) {    
        // user def function returns operand null!
        if ((call.getOperand() instanceof Variable
            || call.getOperand() instanceof CompoundAccess)
            && call.getParameterCount() == 1
            && call.getOperation().equals(OclKeyWords.ASSIGNMENT)) {
            if (call.getParameter(0) instanceof ConstantValue
                || call.getParameter(0) instanceof ContainerInitializer
                || call.getParameter(0) instanceof CompoundInitializer) {
                isSimpleAssignment = true; 
            }
        } 
        call.getOperand().accept(this);
        for (int i = 0; i < call.getParameterCount(); i++) {
            call.getParameter(i).accept(this);
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:VariablesInConstraintsFinder.java

示例4: processModificationForCompoundAccess

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Process modification rules, where operand is a compound access.
 * @param call OCL Call.
 * @param constraintRule A string representation of Drools "not" of this this call.
 */
private void processModificationForCompoundAccess(OCLFeatureCall call, 
        String constraintRule) {
    compoundAccessSlot = "";
    call.getOperand().accept(this);
    assgnConstraintsCalls(call);
    
    compoundAccessSlot = "";
    CompoundAccess cac = (CompoundAccess) call.getOperand();
    boolean isContainer = cac.getResolvedSlot().getType().getTypeClass().equals(Sequence.class)
            || cac.getResolvedSlot().getType().getTypeClass().equals(Set.class);
    if (!(isContainer && (call.getParameter(0) instanceof ConstantValue))) {
        logger.info("");
        //TODO: NOT SURE, TO BE IMPLEMENTED
    }
    hardConstraints.add(constraintRule);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:DroolsVisitor.java

示例5: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    boolean operationIsEquals = (call.getOperation().equals(OclKeyWords.EQUALS));
    boolean operationIsImplies = call.getOperation().equals(OclKeyWords.IMPLIES);

    if (operationIsEquals) {
        if ((call.getOperand() instanceof Variable) || (call.getOperand() instanceof CompoundAccess)) {
            // logger.info("This constraint needs to be there.");
            acceptConstraint = true;
        }
    } else if (operationIsImplies) {
        if (call.getParameter(0).getClass().equals(call.getClass())) {
            OCLFeatureCall temp = (OCLFeatureCall) call.getParameter(0);
            if (temp.getOperation().equals(OclKeyWords.EQUALS)) {
                // logger.info("this should also be included.");
                acceptConstraint = true;
            }
        } else if (call.getParameter(0) instanceof Parenthesis) {
            OCLFeatureCall temp2 = new OCLFeatureCall(call.getOperand(), OclKeyWords.IMPLIES,
                    ((Parenthesis) call.getParameter(0)).getExpr());
            temp2.accept(this);
        }
    }

}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:26,代码来源:DroolsEvaluation.java

示例6: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    if (ruleItr == 0) {
        defaultStatus = call.getOperation().equals("=");
        call.getOperand().accept(this);
        rule += " ";
        if (call.getOperand() instanceof Variable && (call.getParameter(0) instanceof ConstantValue)) {
            ConstantValue val = (ConstantValue) call.getParameter(0);
            if (!(val.getConstantValue() instanceof CompoundValue)) {
                rule += "=";
            }
        } else {
            rule += "=";
        }
        ruleItr++;
        rule += "  ";
        boolean rhsIsConstantValue = call.getParameterCount() == 1 
                && call.getParameter(0) instanceof ConstantValue;
        if (rhsIsConstantValue && call.getOperation().equals("=")) {
            isGroup0 = true;
        } else if (rhsIsConstantValue && call.getOperation().equals("==")) {
            isGroup0 = false;
        }
        for (int i = 0; i < call.getParameterCount(); i++) {
            call.getParameter(i).accept(this);
        }
    } else {
        doModification(call);
    }
    
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:32,代码来源:DroolsAssignmentsVisitor.java

示例7: getCalltype

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
     * Method to identify the type of constraint.
     * @param call OCL call.
     * @return 0 if it is a soft constraint, 1 if it is a hard constraint.
     */
    private int getCalltype(OCLFeatureCall call) {
        int result = 0;
        String op = call.getOperation();
        boolean operationIsImplies = op.equals(OclKeyWords.IMPLIES);
        int params = call.getParameterCount();
        
        if (operationIsImplies && rhsIndicator == 0 && (params == 1) 
                && call.getParameter(0).getClass().equals(call.getClass())) {
            OCLFeatureCall temp = (OCLFeatureCall) call.getParameter(0);
            boolean operationisEquals = temp.getOperation().equals(OclKeyWords.EQUALS);
            if (operationisEquals && (ruleCounter == 0)
                    && (temp.getOperand() instanceof Variable)) {
                result = 0;
                
            } else if (temp.getOperation().equals(OclKeyWords.EQUALS) && (ruleCounter == 0)
                    && (temp.getOperand() instanceof CompoundAccess)) {
                result = 0;
            } else {
                rhsIndicator++;
                result = 1;
            }
        } else if (operationIsImplies && (rhsIndicator == 0) 
                && (call.getParameter(0) instanceof Parenthesis)) {
            rhsIndicator++;
            result = 1;
//            call1.accept(this);
        } else {
            rhsIndicator++;
            result = 1;
        }
        
        return result;
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:39,代码来源:DroolsConstraintVisitor.java

示例8: getCompoundConstraintType

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Type of call the constraint in the compound represents, modification or hard.
 * @param call OCL Call.
 * @return Returns the type of the call. 0 if modification, else 1.
 */
private int getCompoundConstraintType(OCLFeatureCall call) {
    
    boolean operationIsEquals = (call.getOperation().equals(OclKeyWords.EQUALS)); 
    boolean operationIsAssignment = (call.getOperation().equals(OclKeyWords.ASSIGNMENT));
    boolean isModification = operationIsEquals || operationIsAssignment;
    
    int operationTyp = 1;
    
    if (isModification) {
        if (call.getOperand() instanceof Variable) {
            operationTyp = 0;
        } else if (call.getOperand() instanceof CompoundAccess) {
            operationTyp = 0;
        } else {
            operationTyp = 1;
        }
    } else {
        
        if (call.getOperation().equals(OclKeyWords.IMPLIES)) {
            boolean theRHSisOCL = call.getParameter(0) instanceof OCLFeatureCall;
            if (theRHSisOCL) {
                OCLFeatureCall call2 = (OCLFeatureCall) call.getParameter(0);
                if (call2.getOperation().equals(OclKeyWords.EQUALS) && call2.getParameterCount() == 1) {
                    if (call2.getOperand() instanceof Variable || call2.getOperand() instanceof CompoundAccess) {
                        operationTyp = 2;
                    }
                }
            }
        } else {
            operationTyp = 1;
        }
    }
    
    return operationTyp;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:41,代码来源:DroolsVisitor.java

示例9: writeExpressionsWithDecisionvariables

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
     * Method to get the rules for decision variables in the implication calls.
     * @param call OCLFeatureCall
     */
    private void writeExpressionsWithDecisionvariables(OCLFeatureCall call) {
        OCLFeatureCall call1 = (OCLFeatureCall) call.getParameter(0);
        String varName = ((Variable) call1.getOperand()).getVariable().getName();
        //Stopping passing a hard constraint for implies based value modification.
//        addAssinmentConstraintsToMap(constraintRule, varName);
        droolsConstraintVis = new DroolsConstraintVisitor();
        droolsConstraintVis.setRuleCount(ruleCount);
        droolsConstraintVis.visitOclFeatureCall(call);
        String rule = droolsConstraintVis.getRule();
        addAssinmentConstraintsToMap(rule, varName);
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:16,代码来源:DroolsVisitor.java

示例10: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    if (!advancedOptimization || !call.getOperation().equals("=")) {
        traverseOCL(call);
    }
    if (advancedOptimization && call.getOperation().equals("=")) {
        if (call.getParameter(0) instanceof ConstraintSyntaxTree) {
            traverseOCL(call);   
        }
    }   
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:12,代码来源:DroolsVariablesPreProcessor.java

示例11: testFilterReferneceValueFromContainer

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Tests whether container values of references will be filtered correctly.
 * @throws ValueDoesNotMatchTypeException Must not occur, otherwise the {@link ValueFactory} or
 * {@link net.ssehub.easy.varModel.model.AbstractVariable#setValue(String)} are broken.
 * @throws CSTSemanticException Must not occur, otherwise
 * {@link Constraint#setConsSyntax(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree)} is broken.
 */
@Test
public void testFilterReferneceValueFromContainer() throws ValueDoesNotMatchTypeException, CSTSemanticException {
    // Create original project with two declaration and a set of pointers
    Project p = new Project("testProjectRefValues");
    IDatatype basisType = IntegerType.TYPE;
    DecisionVariableDeclaration declA = new DecisionVariableDeclaration("declarationA", basisType, p);
    p.add(declA);
    DecisionVariableDeclaration declB = new DecisionVariableDeclaration("declarationB", basisType, p);
    p.add(declB);
    Reference refType = new Reference("refType", basisType, p);
    Sequence seqType = new Sequence("seqType", refType, p);
    DecisionVariableDeclaration seqDecl = new DecisionVariableDeclaration("sequence", seqType, p);
    p.add(seqDecl);
    // Create ContainerValue pointing to both declarations
    Value refValueA = ValueFactory.createValue(refType, declA);
    Value refValueB = ValueFactory.createValue(refType, declB);
    Value containerValue = ValueFactory.createValue(seqType, new Object[] {refValueA, refValueB});
    Constraint assignment = new Constraint(p);
    OCLFeatureCall cst = new OCLFeatureCall(new Variable(seqDecl), OclKeyWords.ASSIGNMENT,
        new ConstantValue(containerValue));
    assignment.setConsSyntax(cst);
    p.add(assignment);
    // Project should be valid
    ProjectTestUtilities.validateProject(p);
    
    // Create copy while omitting the comment
    ProjectRewriteVisitor copynator = new ProjectRewriteVisitor(p, FilterType.NO_IMPORTS);
    copynator.addModelCopyModifier(new DeclarationNameFilter(new String[] {declA.getName(), seqDecl.getName()}));
    p.accept(copynator);
    
    // Filtered project should contain the declaration, but not the comment
    ProjectTestUtilities.validateProject(p);
    assertProjectContainment(p, declA, true, 3);
    assertProjectContainment(p, seqDecl, true, 3);
    assertProjectContainment(p, declB, false, 3);
    Constraint copiedAssignment = (Constraint) p.getElement(2);
    OCLFeatureCall copiedCall = (OCLFeatureCall) copiedAssignment.getConsSyntax();
    ConstantValue copiedValueCST = (ConstantValue) copiedCall.getParameter(0);
    ContainerValue copiedValue = (ContainerValue) copiedValueCST.getConstantValue();
    Assert.assertEquals("Error: Copied value has not the expected number of elements. ", 1,
        copiedValue.getElementSize());
    Assert.assertEquals(refValueA, copiedValue.getElement(0));
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:51,代码来源:ProjectRewriteVisitorTest.java

示例12: testSaveUserContentOnlyForCompounds

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Tests whether only user assigned slots of a compound will be saved inside the configuration.
 * @throws ConfigurationException 
 * @throws ValueDoesNotMatchTypeException Must not occur otherwise implementation of default values for compounds
 * has been changed.
 */
@Test
public void testSaveUserContentOnlyForCompounds() throws ConfigurationException, ValueDoesNotMatchTypeException {
    
    // Create project with a compound, one slot will be re-assigned by the user
    Compound dimType = new Compound("Dimension", project);
    project.add(dimType);
    DecisionVariableDeclaration widthDecl = new DecisionVariableDeclaration("width", IntegerType.TYPE, dimType);
    dimType.add(widthDecl);
    DecisionVariableDeclaration heightDecl = new DecisionVariableDeclaration("height", IntegerType.TYPE, dimType);
    dimType.add(heightDecl);
    DecisionVariableDeclaration cmpDecl = new DecisionVariableDeclaration("dimension", dimType, project);
    cmpDecl.setValue(new Object[] {"width", 1920, "height", 1080});
    project.add(cmpDecl);        
    
    // Verify project for testing and update configuration
    ProjectTestUtilities.validateProject(project);
    configuration.refresh();
    
    // Reassign one slot by the user
    IDecisionVariable cmpVar = configuration.getDecision(cmpDecl);
    IDecisionVariable widthSlot = null;
    IDecisionVariable heightSlot = null;
    for (int i = 0; i < cmpVar.getNestedElementsCount(); i++) {
        IDecisionVariable nestedVar = cmpVar.getNestedElement(i);
        if (widthDecl.getName().equals(nestedVar.getDeclaration().getName())) {
            widthSlot = nestedVar;
        } else if (heightDecl.getName().equals(nestedVar.getDeclaration().getName())) {
            heightSlot = nestedVar;
        }
    }
    Assert.assertNotNull(widthSlot);
    Assert.assertNotNull(heightSlot);
    widthSlot.setValue(ValueFactory.createValue(widthDecl.getType(), 1900), AssignmentState.ASSIGNED);
    
    // Save configuration into new project (easier for testing)
    Project confInNewProject = configuration.toProject(true);
    ProjectTestUtilities.validateProject(confInNewProject);
    
    // Saved configuration should only contain one assignment with one slot value (new value for width);
    Assert.assertEquals(1, confInNewProject.getElementCount());
    Constraint savedAssignment = (Constraint) confInNewProject.getElement(0);
    OCLFeatureCall savedSyntax = (OCLFeatureCall) savedAssignment.getConsSyntax();
    ConstantValue savedSlotAssignments = (ConstantValue) savedSyntax.getParameter(0);
    CompoundValue cmpValue = (CompoundValue) savedSlotAssignments.getConstantValue();
    
    // Verify value
    Value widthValue = cmpValue.getNestedValue(widthDecl.getName());
    Assert.assertNotNull(widthValue);
    Assert.assertEquals(1900, widthValue.getValue());
    Value heightValue = cmpValue.getNestedValue(heightDecl.getName());
    Assert.assertNull(heightValue);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:59,代码来源:ConfigurationTest.java

示例13: testSavePartialCompounds

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Tests whether partially configured compounds (containing slots with null values) can be saved.
 * Bug detected on 05.01.2016.
 * @throws ConfigurationException 
 * @throws ValueDoesNotMatchTypeException Must not occur otherwise implementation of default values for compounds
 * has been changed.
 */
@Test
public void testSavePartialCompounds() throws ConfigurationException, ValueDoesNotMatchTypeException {
    
    // Create project with a compound and a nested compound, one nested slot will must be undefined
    Compound dimType2 = new Compound("Dimension2D", project);
    project.add(dimType2);
    DecisionVariableDeclaration widthDecl = new DecisionVariableDeclaration("width", IntegerType.TYPE, dimType2);
    dimType2.add(widthDecl);
    DecisionVariableDeclaration heightDecl = new DecisionVariableDeclaration("height", IntegerType.TYPE, dimType2);
    dimType2.add(heightDecl);
    Compound dimType3 = new Compound("Dimension3D", project);
    project.add(dimType3);
    DecisionVariableDeclaration depthDecl = new DecisionVariableDeclaration("depth", IntegerType.TYPE, dimType3);
    dimType3.add(depthDecl);
    DecisionVariableDeclaration dim2DSlotDecl = new DecisionVariableDeclaration("dim2DSlot", dimType2, dimType3);
    dimType3.add(dim2DSlotDecl);
    dim2DSlotDecl.setValue(new Object[] {"width", 2});     
    DecisionVariableDeclaration cmpDecl = new DecisionVariableDeclaration("dimension3D", dimType3, project);
    project.add(cmpDecl);        
    
    // Verify project for testing and update configuration
    ProjectTestUtilities.validateProject(project);
    configuration.refresh();
    
    // Set manually a value for top slot by the user
    IDecisionVariable cmpVar = configuration.getDecision(cmpDecl);
    IDecisionVariable depthSlot = cmpVar.getNestedElement(0);
    depthSlot.setValue(ValueFactory.createValue(depthDecl.getType(), 1), AssignmentState.ASSIGNED);
    // Freeze complete nested compound to force that the complete declaration is considered
    // while saving the configuration.
    cmpVar.freeze(dim2DSlotDecl.getName());
    
    // Save configuration into new project (easier for testing)
    Project confInNewProject = configuration.toProject(true);
    ProjectTestUtilities.validateProject(confInNewProject);
    
    // Saved configuration should only contain one assignment with one slot value (new value for width);
    Assert.assertEquals(1, confInNewProject.getElementCount());
    Constraint savedAssignment = (Constraint) confInNewProject.getElement(0);
    OCLFeatureCall savedSyntax = (OCLFeatureCall) savedAssignment.getConsSyntax();
    ConstantValue savedSlotAssignments = (ConstantValue) savedSyntax.getParameter(0);
    CompoundValue cmpValue = (CompoundValue) savedSlotAssignments.getConstantValue();
    
    // Verify value
    Value depthValue = cmpValue.getNestedValue(depthDecl.getName());
    Assert.assertNotNull(depthValue);
    Assert.assertEquals(1, depthValue.getValue());
    CompoundValue dim2DSlotValue = (CompoundValue) cmpValue.getNestedValue(dim2DSlotDecl.getName());
    Assert.assertNotNull(dim2DSlotValue);
    Value widthValue = dim2DSlotValue.getNestedValue(widthDecl.getName());
    Value heightValue = dim2DSlotValue.getNestedValue(heightDecl.getName());
    Assert.assertNotNull(widthValue);
    Assert.assertEquals(2, widthValue.getValue());
    Assert.assertNull(heightValue);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:63,代码来源:ConfigurationTest.java

示例14: handleBinaryBoolean

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
/**
 * Handles an {@link BooleanType#AND}, {@link BooleanType#OR} or {@link BooleanType#XOR} operation. Should evaluate 
 * special situations like <code>undef OR true</code> to <code>true</code>. Dynamically changes evaluation sequence 
 * depending on {@link #containsIsDefined(ConstraintSyntaxTree)}.
 * 
 * @param operand The operand of the OR operation. The operand should already been visited.
 * @param call the call representing the OR operation
 * @return <tt>true</tt> the operation was evaluated successfully, <tt>false</tt> otherwise.
 */
private boolean handleBinaryBoolean(EvaluationAccessor operand, OCLFeatureCall call) {
    boolean hasBeenEvaluated = false;
    Operation op = call.getResolvedOperation();
    EvaluationAccessor operandAccessor = operand;
    EvaluationAccessor parameterAccessor = null;
    ConstraintSyntaxTree parameter = call.getParameter(0);
    if (containsIsDefined(call.getOperand())) {
        if (null != parameter) { // if there is no parameter then no change in result
            // change evaluation sequence - may not help if both contains an isDefined
            parameterAccessor = getAccessor(parameterAccessor, parameter);
            // re-evaluate operand!
            operandAccessor = getAccessor(operandAccessor, call.getOperand());
        }
    }
    if (op == BooleanType.AND) {
        if (null != operandAccessor && operandAccessor.getValue() == BooleanValue.FALSE) {
            result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.FALSE, operand.getContext());
            hasBeenEvaluated = true;
        } else if (null != operand && null != parameter) {
            parameterAccessor = getAccessor(parameterAccessor, parameter);
            if (null != parameterAccessor && parameterAccessor.getValue() == BooleanValue.FALSE) {
                result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.FALSE, operand.getContext());
                hasBeenEvaluated = true;
            }
        }
    } else if (op == BooleanType.OR) {
        if (null != operandAccessor && operandAccessor.getValue() == BooleanValue.TRUE) {
            result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.TRUE, operand.getContext());
            hasBeenEvaluated = true;
        } else if (null != operandAccessor && null != parameter) {
            parameterAccessor = getAccessor(parameterAccessor, parameter);
            if (null != parameterAccessor && parameterAccessor.getValue() == BooleanValue.TRUE) {
                result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.TRUE, operand.getContext());
                hasBeenEvaluated = true;
            }
        }
    } else { // xor
        if (null != operandAccessor && null != parameter) {
            parameterAccessor = getAccessor(parameterAccessor, parameter);
            if (null != parameterAccessor) {
                boolean xorRes = operand.getValue() == BooleanValue.TRUE ^ result.getValue() == BooleanValue.TRUE;
                result = ConstantAccessor.POOL.getInstance().bind(BooleanValue.toBooleanValue(xorRes), 
                    operand.getContext());
                hasBeenEvaluated = true;
            }
        }
    }
    if (null != parameterAccessor) {
        parameterAccessor.release();
    }
    if (operandAccessor != operand) { // we have a temporary operand
        operandAccessor.release();
    }
    return hasBeenEvaluated;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:65,代码来源:EvaluationVisitor.java

示例15: visitOclFeatureCall

import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入方法依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
    callStack.push(call);
    FormattingHint hint;
    Operation resolved = call.getResolvedOperation();
    if (null != resolved) {
        hint = resolved.getFormattingHint();
    } else {
        hint = FormattingHint.FUNCTION_CALL;
    }            
    String name = call.getOperation();
    switch (hint) {
    case FUNCTION_CALL:
        if (OclKeyWords.INDEX_ACCESS.equals(name) && 1 == call.getParameterCount()) {
            call.getOperand().accept(this);
            appendOutput("[");
            call.getParameter(0).accept(this);
            appendOutput("]");
        } else {
            appendOutput(name);
            appendOutput("(");
            ConstraintSyntaxTree operand = call.getOperand();
            if (null != operand) {
                operand.accept(this);
            }
            if (call.getParameterCount() > 0) {
                for (int p = 0; p < call.getParameterCount(); p++) {
                    ConstraintSyntaxTree param = call.getParameter(p);
                    if (null != operand || (null == operand && p > 0)) {
                        appendOutput(",");
                    }
                    if (null != param.getName()) {
                        appendOutput(WHITESPACE);
                        appendOutput(param.getName());
                        appendOutput(WHITESPACE);
                        appendOutput("=");
                    }
                    appendOutput(WHITESPACE);
                    param.accept(this);
                }
            }
            appendOutput(")");
        }
        break;
    case OPERATOR_INFIX:
        call.getOperand().accept(this);
        for (int p = 0; p < call.getParameterCount(); p++) {
            appendOutput(WHITESPACE);
            appendOutput(name);
            appendOutput(WHITESPACE);
            call.getParameter(p).accept(this);
        }
        break;
    case OPERATOR_PREFIX:
        appendOutput(name);
        appendOutput(WHITESPACE);
        call.getOperand().accept(this);
        // it is ensured that there are no more parameters
        break;
    case OPERATOR_POSTFIX:
        call.getOperand().accept(this);
        appendOutput(name);
        // it is ensured that there are no more parameters
        break;
    default:
        // should not occur
        break;
    }
    callStack.pop();
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:71,代码来源:IVMLWriter.java


注:本文中的net.ssehub.easy.varModel.cst.OCLFeatureCall.getParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。