public override bool Visit(ClassLiteralExp node) { /* Class literals we can't handle yet */ isSuitable = false; violatingExpression = node; return(false); }
public override OclExpression Visit(ClassLiteralExp node) { /* Class literals we can't handle yet */ isSuitable = false; notSupportedExpression = node; throw new OclConstructNotAvailableInPSM(node); }
public void Visit(ClassLiteralExp node) { foreach (KeyValuePair <string, TupleLiteralPart> kvp in node.Parts) { Expressions.Add(kvp.Value.Value); kvp.Value.Value.Accept(this); } }
public override void Visit(ClassLiteralExp node) { base.Visit(node); PSMPath psmPath = PSMPathBuilder.BuildPSMPath(node, OclContext, VariableNamer, buildPathParams); string xpath = psmPath.ToXPath(); TranslationOption option = new TranslationOption(); option.FormatString = xpath; SubexpressionTranslations.AddTranslationOption(node, option, psmPath.SubExpressions.ToArray()); }
public static PSMPath BuildPSMPath(ClassLiteralExp classLiteral, IConstraintsContext constraintsContext, VariableNamer variableNamer, BuildPSMPathParams buildPsmPathParams) { PSMPath path = new PSMPath(); path.Context.ConstraintContext = constraintsContext; path.Context.VariableNamer = variableNamer; path.TupleLiteralToXPathCallback = buildPsmPathParams.TupleLiteralToXPathCallback; path.ClassLiteralToXPathCallback = buildPsmPathParams.ClassLiteralToXPathCallback; path.GenericExpressionToXPathCallback = buildPsmPathParams.GenericExpressionToXPathCallback; ClassLiteralStep classLiteralStep = new ClassLiteralStep(path) { ClassLiteralExpression = classLiteral }; path.Steps.Insert(0, classLiteralStep); return(path); }
public void Visit(ClassLiteralExp node) { sb.Append("new "); sb.Append(node.Type.ToString()); sb.Append(" {"); PrintArgs(node.Parts, ",", (v) => { if (v.Value.Type != null) { sb.AppendFormat("{0} : {1} = ", v.Key, v.Value.Type.Name); } else { sb.AppendFormat("{0} = ", v.Key); } v.Value.Value.Accept(this); }); sb.Append("} "); }
protected override string ClassLiteralToXPath(ClassLiteralExp tupleLiteral, List <OclExpression> subExpressions) { StringBuilder formatBuilder = new StringBuilder(); string elementName = EvolutionAssignmentStack.Peek() != null ? (EvolutionAssignmentStack.Peek().PSMAssociation != null ? EvolutionAssignmentStack.Peek().PSMAssociation.Name: string.Empty): string.Empty; formatBuilder.AppendFormat("oclX:genericConstructor('{0}', map {{{{", elementName); foreach (KeyValuePair <string, TupleLiteralPart> kvp in tupleLiteral.Parts) { kvp.Value.Value.Accept(this); formatBuilder.AppendFormat("'{0}' := {{{1}}}, ", kvp.Key, subExpressions.Count); subExpressions.Add(kvp.Value.Value); } if (formatBuilder.Length > 0) { formatBuilder.Length = formatBuilder.Length - 2; } formatBuilder.Append("}} )"); TranslationOption option = new TranslationOption(); option.FormatString = formatBuilder.ToString(); SubexpressionTranslations.AddTranslationOption(tupleLiteral, option, subExpressions.ToArray()); return(option.FormatString); }
protected override string ClassLiteralToXPath(ClassLiteralExp classLiteral, List <OclExpression> subExpressions) { throw new ExpressionNotSupportedInXPath(classLiteral, "Class literals are supported only in 'functional' schemas. "); }
public override void Visit(ClassLiteralExp node) { base.Visit(node); throw new ExpressionNotSupportedInXPath(node, "Class literals are supported only in 'functional' schemas. "); }
protected abstract string ClassLiteralToXPath(ClassLiteralExp classLiteral, List <OclExpression> subExpressions);
public virtual void Visit(ClassLiteralExp node) { AssignIsPartOfIteratorBody(node); }
private string ClassLiteralToXPathCallback(ClassLiteralExp tupleLiteral, List <OclExpression> subExpressions) { return(string.Empty); }
public void Visit(ClassLiteralExp node) { throw new NotImplementedException(); }
public abstract TType Visit(ClassLiteralExp node);
public static PSMPath BuildPSMPath(PropertyCallExp node, IConstraintsContext constraintsContext, VariableNamer variableNamer, BuildPSMPathParams buildPsmPathParams) { PSMPath path = new PSMPath(); path.TupleLiteralToXPathCallback = buildPsmPathParams.TupleLiteralToXPathCallback; path.GenericExpressionToXPathCallback = buildPsmPathParams.GenericExpressionToXPathCallback; path.GetRelativeXPathEvolutionCallback = buildPsmPathParams.GetRelativeXPathEvolutionCallback; path.Context.ConstraintContext = constraintsContext; path.Context.VariableNamer = variableNamer; OclExpression s; if (buildPsmPathParams.Evolution && IsEvolutionPrevStep(node)) { PSMEvolutionPrevStep prevStep = new PSMEvolutionPrevStep(path); if (node.ReferredProperty is PSMBridgeAttribute) { prevStep.StepAttributeNewVersion = ((PSMBridgeAttribute)node.ReferredProperty).SourceAttribute; } else if (node.ReferredProperty is PSMBridgeAssociation) { prevStep.StepAssociationNewVersion = ((PSMBridgeAssociation)node.ReferredProperty).SourceAsscociation; } else { throw new InvalidOperationException(); } PrevOperationTag tag = (PrevOperationTag)((OperationCallExp)node.Source).ReferredOperation.Tag; prevStep.PSMAssociationMemberTargetVersion = (PSMAssociationMember)tag.TargetVersionClassifier.Tag; prevStep.PSMAssociationMemberSourceVersion = (PSMAssociationMember)tag.SourceVersionClassifier.Tag; path.Steps.Add(prevStep); OclExpression prevSource = ((OperationCallExp)node.Source).Source; if (prevSource is VariableExp && ((VariableExp)prevSource).referredVariable == constraintsContext.Self) { s = null; } else { s = prevSource; } } else if (node.ReferredProperty is PSMBridgeAssociation) { s = node; } else if (node.Source is TupleLiteralExp) { TuplePartStep tuplePartStep = new TuplePartStep(path) { TupleExpresion = (TupleLiteralExp)node.Source }; tuplePartStep.TuplePart = tuplePartStep.TupleExpresion.Parts[node.ReferredProperty.Name]; path.Steps.Add(tuplePartStep); s = node.Source; } else { PSMAttribute a = (PSMAttribute)node.ReferredProperty.Tag; PSMPathAttributeStep pathAttributeStep = new PSMPathAttributeStep(path) { Attribute = a }; path.Steps.Add(pathAttributeStep); s = node.Source; } while (s is PropertyCallExp) { PSMPathAssociationStep step = new PSMPathAssociationStep(path); var sp = ((PropertyCallExp)s); // HACK: WFJT turn class tag into association tag PSMBridgeAssociation bridgeAssociation = (PSMBridgeAssociation)sp.ReferredProperty; step.Association = bridgeAssociation.SourceAsscociation; if (bridgeAssociation.Direction == PSMBridgeAssociation.AssociationDirection.Down) { step.From = bridgeAssociation.SourceAsscociation.Parent; step.To = bridgeAssociation.SourceAsscociation.Child; step.IsUp = false; } else { step.From = bridgeAssociation.SourceAsscociation.Child; step.To = bridgeAssociation.SourceAsscociation.Parent; step.IsUp = true; } path.Steps.Insert(0, step); s = sp.Source; } if (s is VariableExp) { VariableExp variableExp = (VariableExp)s; PSMPathVariableStep pathVariableStep = new PSMPathVariableStep(path) { VariableExp = variableExp }; if (string.IsNullOrEmpty(variableExp.referredVariable.Name)) { variableExp.referredVariable.Name = path.Context.VariableNamer.GetName(variableExp.referredVariable.PropertyType); } path.Steps.Insert(0, pathVariableStep); } else if (s is TupleLiteralExp) { TupleLiteralExp tupleLiteralExp = (TupleLiteralExp)s; TupleLiteralStep tupleLiteralStep = new TupleLiteralStep(path); tupleLiteralStep.TupleExpresion = tupleLiteralExp; path.Steps.Insert(0, tupleLiteralStep); } else if (node.Source is ClassLiteralExp) { ClassLiteralExp classLiteralExp = (ClassLiteralExp)s; ClassLiteralStep tupleLiteralStep = new ClassLiteralStep(path); tupleLiteralStep.ClassLiteralExpression = classLiteralExp; path.Steps.Insert(0, tupleLiteralStep); } else if (s == null) { // do nothing } else { GeneralSubexpressionStep generalSubexpressionStep = new GeneralSubexpressionStep(path); generalSubexpressionStep.OclExpression = s; path.Steps.Insert(0, generalSubexpressionStep); } return(path); }