private void translateStructDefaultValue(IDefaultValue defaultValue, ITypeReference typ) { // then it is a struct and gets special treatment // translate it as if it were a call to the nullary ctor for the struct type // (which doesn't actually exist, but gets generated for each struct type // encountered during translation) var tok = defaultValue.Token(); var loc = this.sink.CreateFreshLocal(typ); var locExpr = Bpl.Expr.Ident(loc); // First generate an Alloc() call this.StmtTraverser.StmtBuilder.Add(new Bpl.CallCmd(tok, this.sink.AllocationMethodName, new List<Bpl.Expr>(), new List<Bpl.IdentifierExpr>(new Bpl.IdentifierExpr[] {locExpr}))); // Second, generate the call to the appropriate ctor var proc = this.sink.FindOrCreateProcedureForDefaultStructCtor(typ); var invars = new List<Bpl.Expr>(); invars.Add(locExpr); this.StmtTraverser.StmtBuilder.Add(new Bpl.CallCmd(tok, proc.Name, invars, new List<Bpl.IdentifierExpr>())); // Generate an assumption about the dynamic type of the just allocated object this.sink.GenerateDynamicTypeAssume(this.StmtTraverser.StmtBuilder, tok, locExpr, typ); this.TranslatedExpressions.Push(locExpr); }