Esempio n. 1
0
        public override void Visit(OperationCallExp node)
        {
            if (node.ReferredOperation != null && node.ReferredOperation.Tag is NextOperationTag)
            {
                node.Source.Accept(this);
                TranslationOption option = new TranslationOption();
                option.FormatString = "oclX:apply-templates({0})";
                SubexpressionTranslations.AddTranslationOption(node, option, node.Source);
                return;
            }

            base.Visit(node);

            if (OperationRewritings.IsEmpty())
            {
                OperationRewritings[OperationHelper.firstOperationInfo] = AddFirstRewritings;
                OperationRewritings[OperationHelper.lastOperationInfo]  = AddLastRewritings;
                OperationRewritings[OperationHelper.atOperationInfo]    = AddAtRewritings;
            }

            {
                TranslationOption standardTranslation = SubexpressionTranslations.GetSubexpressionTranslation(node);
                OperationInfo?    operationInfo       = OperationHelper.LookupOperation(node, standardTranslation.OptionsContainer.SubExpressions.ToArray());
                if (operationInfo != null && OperationRewritings.ContainsKey(operationInfo.Value))
                {
                    OperationRewritings[operationInfo.Value](node, operationInfo.Value);
                }
            }
        }
Esempio n. 2
0
        public string TranslateExpression(OclExpression expression)
        {
            OperationHelper           = new OperationHelper();
            OperationHelper.PSMSchema = Bridge.Schema;
            OperationHelper.Log       = Log;
            OperationHelper.ExplicitCastAtomicOperands = !Settings.SchemaAware;
            OperationHelper.PSMBridge = Bridge;
            OperationHelper.InitStandard();
            TranslatedOclExpression   = expression;
            VariableNamer             = new VariableNamer();
            SubexpressionTranslations = new SubexpressionTranslations {
                XPathContextVariableReplacementMode = ContextVariableReplacementMode
            };
            SubexpressionTranslations.Log = Log;
            expression.Accept(this);
            SubexpressionTranslations.SelfVariableDeclaration = OclContext.Self;
            string result = SubexpressionTranslations.GetSubexpressionTranslation(expression).GetString(true);

            return(result);
        }