コード例 #1
0
        public override Expression visit(FAE f)
        {
            Debug.Assert(procedure != null);
//            if (f.ToString().Contains(@"read($h,read($h,$o,AVLTree.root),alloc)"))
//                Debugger.Break();

            Expression result = base.visit(f);

            var rfae = result as FAE;
            FunctionTemplate template = procedure.findFunctionTemplate(rfae.function.name);

            if (rfae != null && template != null && template.body != null && template.attributes.Contains(":inline  true"))
            {
                var fti = rfae.function as BasicFunctionTemplateInstance;
                Debug.Assert(fti != null);
                Debug.Assert(fti.template == template);
                var substitution = new ExpressionSubstitution();
                for (int i = 0; i < template.typeParameters.Length; i++)
                {
                    substitution.typeSubstitution.add(template.typeParameters[i], fti.typeArguments[i]);
                }
                for (int i = 0; i < rfae.arguments.count; i++)
                {
                    substitution.add(template.body.arguments[i].name, rfae.arguments[i]);
                }

                result = template.body.expression.substitute(substitution);
//                var r1 = result;
                result = result.visit(this);
//                if (!ReferenceEquals(r1, result) && r1.ToString().Contains(@"$inv"))
//                    Debugger.Break();
            }

            return(result);
        }
コード例 #2
0
        ///////////////////////////////////////////////////////////
        public BasicQuantifiedExpression(
            QuantifiedExpression other,
            ExpressionSubstitution s
            )
        {
            scope      = other.scope;
            quantifier = other.quantifier;
            variable   = scope.makeFreshBoundVariable(other.variable.name,
                                                      other.variable.type.substitute(s.typeSubstitution));
            s.add(other.variable.name, new BasicBoundVariableExpression(variable));
            expression = other.expression.substitute(s);
            triggers   = (from trs in other.triggers select trs.substitute(s)).ToArray();
            if (other.attributes != null)
            {
                attributes = (string)(other.attributes.Clone());
            }

            s.remove(other.variable.name);
        }