Beispiel #1
0
 public void check(TypeFactory.Context context)
 {
     foreach (var a in arguments)
     {
         a.check(context);
     }
 }
        ///////////////////////////////////////////////////////
        private void addTypes()
        {
            foreach (var d in boogieProgram.TopLevelDeclarations)
            {
                var t = d as TypeCtorDecl;
                var s = d as TypeSynonymDecl;
                if (t == null && s == null)
                {
                    continue;
                }

                if (t != null)
                {
                    program.addTypeConstructor(t.Name, new TypeConstructor(t.Name, t.Arity));
                    continue;
                }
                if (s != null)
                {
                    var context = new TypeFactory.Context();
                    TypeFactory.pushTypeVariables(ref context, s.TypeParameters);

                    program.addTypeSynonym(s.Name, TypeFactory.makeTypeVariables(context, s.TypeParameters),
                                           makeTypeI(context, s.Body));
//                    procedure.addTypeAlias(si.Name, makeType(si.Body));
                }
            }
        }
        private void addFunctionBodies()
        {
            var ef = new ExpressionFactory(program);

            foreach (var d in boogieProgram.TopLevelDeclarations)
            {
                var t = d as Function;
                if (t == null)
                {
                    continue;
                }
                if (t.Body == null)
                {
                    continue;
                }

                FunctionTemplate template = program.findFunctionTemplate(t.Name);
                var arguments             = new BoundVariable[template.signature.argumentTypes.Count()];
                for (int i = 0; i < arguments.Length; i++)
                {
                    arguments[i] = program.makeFreshBoundVariable(t.InParams[i].Name,
                                                                  template.signature.argumentTypes[i]);
                }
//                Debug.Assert(template.body != null);

                var context = new TypeFactory.Context();
                context.push();
                foreach (var tp in template.typeParameters)
                {
                    context.add(tp);
                }
                for (int i = 0; i < arguments.Length; i++)
                {
                    context.add(t.InParams[i].Name, arguments[i]);
                }

                Expression expression = ef.makeExpression(t.Body, context, false);
                template.body = new FunctionBody(arguments, expression);
            }
        }
Beispiel #4
0
        public void check(TypeFactory.Context context)
        {
            context.push();
            foreach (var tp in typeParameters)
            {
                Debug.Assert(!ReferenceEquals(context.lookupTypeVariable(tp.name), tp));
            }

            foreach (var tp in typeParameters)
            {
                context.add(tp);
            }

            {
                foreach (var d in domain)
                {
                    d.check(context);
                }
                range.check(context);
            }

            context.pop();
        }
        ///////////////////////////////////////////////////////
        private void addFunctions()
        {
            foreach (var d in boogieProgram.TopLevelDeclarations)
            {
                var t = d as Function;
                if (t == null)
                {
                    continue;
                }

                var context = new TypeFactory.Context();
                TypeFactory.pushTypeVariables(ref context, t.TypeParameters);
                TypeVariable[] typeParameters = TypeFactory.makeTypeVariables(context, t.TypeParameters);

                IType resultType    = program.typeFactory.makeTypeI(t.OutParams[0].TypedIdent.Type, context);
                var   argumentTypes = new IType[t.InParams.Count];
                for (int i = 0; i < t.InParams.Count; i++)
                {
                    argumentTypes[i] = program.typeFactory.makeTypeI(t.InParams[i].TypedIdent.Type, context);
                }

                var signature = new BasicFunctionSignature(resultType, argumentTypes);

                string attributes = ExpressionFactory.getAttributes(t.Attributes);

                program.addFunctionTemplate(
                    new BFunctionTemplate(
                        t.Name,
                        attributes,
                        typeParameters,
                        signature,
                        null
                        )
                    );
            }
        }
 private IType makeTypeI(TypeFactory.Context context, Type type)
 {
     return(program.typeFactory.makeTypeI(type, context));
 }
Beispiel #7
0
 public void check(TypeFactory.Context context)
 {
     Debug.Assert(context.lookupTypeVariable(typeVariable.name) != null);
 }
Beispiel #8
0
 ////////////////////////////////////////////////////////////////////////////////////
 public Expression makeExpression(Expr e, TypeFactory.Context context, bool old)
 {
     this.context = context;
     return(makeExpression(e, false));
 }
Beispiel #9
0
        public ExpressionFactory(Scope scope)
        {
            this.scope = scope;
//            boundVariables     = new Dictionary<string, BoundVariable>();
            context = new TypeFactory.Context();
        }
Beispiel #10
0
 public void check(TypeFactory.Context context)
 {
 }