public void run() { QvtOperationalEvaluationEnv oldEvalEnv = myVisitor.getOperationalEvaluationEnv(); myVisitor.setOperationalEvaluationEnv(myEvalEnv); Object resolveResult = getResolveResult(); try { AssignExp assignExp = QvtResolveUtil.getDeferredAssignmentFor(myResolveExp); if (assignExp != null && myLvalue != null) { myEvalEnv.callSetter( myLvalue.getEObject(), myLvalue.getEStructuralFeature(), resolveResult, QvtOperationalUtil.isUndefined(resolveResult, myEvalEnv), assignExp.isIsReset()); if (myListener != null) { myListener.notifyAfterDeferredAssign(assignExp, resolveResult); } } else { // there was not appropriate assignment to receive the value } } finally { myVisitor.setOperationalEvaluationEnv(oldEvalEnv); } }
public void doInstancePropertyInit(Object instance, QvtOperationalEvaluationVisitor evalVisitor) { if (false == instance instanceof EObject) { return; } EObject eInstance = (EObject) instance; EClass intermediateClass = eInstance.eClass(); Map<EStructuralFeature, OCLExpression<EClassifier>> clsFeatures = myClassifierInitializations.get(intermediateClass); if (clsFeatures == null) { return; } for (EStructuralFeature eFeature : intermediateClass.getEAllStructuralFeatures()) { IntermediateStaticFieldAdapter adapter = (IntermediateStaticFieldAdapter) EcoreUtil.getAdapter(eFeature.eAdapters(), IntermediateStaticFieldAdapter.class); if (adapter != null && adapter.isInitialized()) { continue; } OCLExpression<EClassifier> expression = clsFeatures.get(eFeature); Object evalResult = expression != null ? evalVisitor.visitExpression(expression) : null; if (evalResult == null) { // no init expression specified for a single-valued feature, or init expression evaluated to // null EClassifier featureType = evalVisitor.getEnvironment().getUMLReflection().getOCLType(eFeature); evalResult = EvaluationUtil.createInitialValue( featureType, evalVisitor.getEnvironment().getOCLStandardLibrary(), evalVisitor.getEvaluationEnvironment()); } // temporary switch off read-only property boolean isChangeable = eFeature.isChangeable(); eFeature.setChangeable(true); boolean isUndefined = QvtOperationalUtil.isUndefined(evalResult, evalVisitor.getEvaluationEnvironment()); evalVisitor .getOperationalEvaluationEnv() .callSetter(eInstance, eFeature, evalResult, isUndefined, true); eFeature.setChangeable(isChangeable); } }