import { Utils } from './Utils' ; import { InvariantExpression } from './expressions/InvariantExpression' ; import { ContextExpression } from './expressions/context/ContextExpression' ; import { OclParser } from './parser/OclParser' ; export class OclExecutionContext { private evaluationResult : any = undefined ; private failedInvariants : Array < InvariantExpression > = [ ] ; private registeredTypes : any ; private registeredEnumerations : any ; private targetTypeName : string ; private evaluatedContexts : Array < ContextExpression > = [ ] ; constructor ( private obj , private labelsToExecute = [ ] ) { this . targetTypeName = Utils . getClassName ( obj ) ; this . registeredTypes = OclParser . registeredTypes ; } addFailedInvariant ( inv ) { this . failedInvariants . push ( inv ) ; } setObjectToEvaluate ( obj ) { this . obj = obj ; return this ; } getObjectToEvaluate ( ) { return this . obj ; } getRegisteredType ( targetTypeName ) { return this . registeredTypes [ targetTypeName ] ; } setTargetTypeName ( name ) { this . targetTypeName = name ; } getTargetTypeName ( ) { return this . targetTypeName ; } registerTypes ( types ) { this . registeredTypes = { ... this . registeredTypes , ... types } ; } setRegisteredEnumerations ( enumerations ) { this . registeredEnumerations = { ... this . registeredEnumerations , ... enumerations } ; } getRegisteredEnumeration ( key ) { return this . registeredEnumerations [ key ] || [ ] ; } getFailedInvariants ( ) { return this . failedInvariants ; } getLabelsToExecute ( ) { return this . labelsToExecute ; } getEvaluationResult ( ) { return this . evaluationResult ; } setEvaluationResult ( evaluationResult ) { this . evaluationResult = evaluationResult ; } addEvaluatedContext ( context ) { this . evaluatedContexts . push ( context ) ; } getEvaluatedContexts ( ) { return this . evaluatedContexts ; } }