Exemple #1
0
 public virtual Declaration VisitTypeSynonymDecl(TypeSynonymDecl node) {
   Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<Declaration>() != null);
   return this.VisitDeclaration(node);
 }
Exemple #2
0
 public override Declaration VisitTypeSynonymDecl(TypeSynonymDecl node)
 {
     Contract.Ensures(Contract.Result<Declaration>() == node);
     return this.VisitDeclaration(node);
 }
Exemple #3
0
	void UserDefinedType(out Declaration/*!*/ decl, QKeyValue kv) {
		Contract.Ensures(Contract.ValueAtReturn(out decl) != null); IToken/*!*/ id; List<IToken>/*!*/ paramTokens = new List<IToken> ();
		Bpl.Type/*!*/ body = dummyType; bool synonym = false; 
		Ident(out id);
		if (la.kind == 1) {
			WhiteSpaceIdents(out paramTokens);
		}
		if (la.kind == 32) {
			Get();
			Type(out body);
			synonym = true; 
		}
		if (synonym) {
		 List<TypeVariable>/*!*/ typeParams = new List<TypeVariable>();
		 foreach(Token/*!*/ t in paramTokens){
		   Contract.Assert(t != null);
		   typeParams.Add(new TypeVariable(t, t.val));}
		 decl = new TypeSynonymDecl(id, id.val, typeParams, body, kv);
		} else {
		 decl = new TypeCtorDecl(id, id.val, paramTokens.Count, kv);
		}
		
	}
Exemple #4
0
        void OtherTypeDecl(ModuleDefinition module, out TopLevelDecl td)
        {
            IToken id;
            Attributes attrs = null;
            var eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
            var typeArgs = new List<TypeParameter>();
            td = null;
            Type ty;

            Expect(80);
            while (la.kind == 46) {
            Attribute(ref attrs);
            }
            NoUSIdent(out id);
            if (la.kind == 50) {
            Get();
            Expect(54);
            Expect(51);
            eqSupport = TypeParameter.EqualitySupportValue.Required;
            if (la.kind == 52) {
                GenericParameters(typeArgs);
            }
            } else if (StartOf(4)) {
            if (la.kind == 52) {
                GenericParameters(typeArgs);
            }
            if (la.kind == 67) {
                Get();
                Type(out ty);
                td = new TypeSynonymDecl(id, id.val, typeArgs, module, ty, attrs);
            }
            } else SynErr(146);
            if (td == null) {
             td = new OpaqueTypeDecl(id, id.val, module, eqSupport, typeArgs, attrs);
            }

            if (la.kind == 28) {
            while (!(la.kind == 0 || la.kind == 28)) {SynErr(147); Get();}
            Get();
            errors.Warning(t, "the semi-colon that used to terminate an opaque-type declaration has been deprecated; in the new syntax, just leave off the semi-colon");
            }
        }
Exemple #5
0
        void OtherTypeDecl(DeclModifierData dmod, ModuleDefinition module, out TopLevelDecl td)
        {
            IToken id, bvId;
            Attributes attrs = null;
            var eqSupport = TypeParameter.EqualitySupportValue.Unspecified;
            var typeArgs = new List<TypeParameter>();
            td = null;
            Type ty = null;
            Expression constraint;
            var kind = "Opaque type";

            Expect(85);
            while (la.kind == 50) {
            Attribute(ref attrs);
            }
            NoUSIdent(out id);
            if (la.kind == 54) {
            Get();
            Expect(58);
            Expect(55);
            eqSupport = TypeParameter.EqualitySupportValue.Required;
            if (la.kind == 56) {
                GenericParameters(typeArgs);
            }
            } else if (StartOf(7)) {
            if (la.kind == 56) {
                GenericParameters(typeArgs);
            }
            if (la.kind == 74) {
                Get();
                if (IsIdentColonOrBar()) {
                    NoUSIdent(out bvId);
                    if (la.kind == 22) {
                        Get();
                        Type(out ty);
                    }
                    if (ty == null) { ty = new InferredTypeProxy(); }
                    Expect(24);
                    Expression(out constraint, false, true);
                    td = new SubsetTypeDecl(id, id.val, typeArgs, module, new BoundVar(bvId, bvId.val, ty), constraint, attrs);
                    kind = "Subset type";

                } else if (StartOf(6)) {
                    Type(out ty);
                    td = new TypeSynonymDecl(id, id.val, typeArgs, module, ty, attrs);
                    kind = "Type synonym";

                } else SynErr(160);
            }
            } else SynErr(161);
            if (td == null) {
             td = new OpaqueTypeDecl(id, id.val, module, eqSupport, typeArgs, attrs);
            }

            CheckDeclModifiers(dmod, kind, AllowedDeclModifiers.None);
            if (la.kind == 30) {
            while (!(la.kind == 0 || la.kind == 30)) {SynErr(162); Get();}
            Get();
            errors.Deprecated(t, "the semi-colon that used to terminate an opaque-type declaration has been deprecated; in the new syntax, just leave off the semi-colon");
            }
        }