# HG changeset patch # User korDen # Date 1283179115 -14400 # Node ID e95073e263566d39578d5d56ec91c5aa7b5d4695 # Parent 722df8e7509c042e51707d9952ba2fdd743da2f1 fixed a hack I used as a lack of copy ctor in D diff -r 722df8e7509c -r e95073e26356 dmd/AttribDeclaration.d --- a/dmd/AttribDeclaration.d Mon Aug 30 15:40:51 2010 +0200 +++ b/dmd/AttribDeclaration.d Mon Aug 30 18:38:35 2010 +0400 @@ -47,9 +47,7 @@ if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) { // create new one for changes - newsc = new Scope(sc); - newsc.offset = sc.offset; - newsc.scopesym = sc.scopesym; + newsc = sc.clone(); newsc.flags &= ~SCOPE.SCOPEfree; newsc.stc = stc; newsc.linkage = linkage; @@ -75,9 +73,7 @@ if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) { // create new one for changes - newsc = new Scope(sc); - newsc.offset = sc.offset; - newsc.scopesym = sc.scopesym; + newsc = sc.clone(); newsc.flags &= ~SCOPE.SCOPEfree; newsc.stc = stc; newsc.linkage = linkage; diff -r 722df8e7509c -r e95073e26356 dmd/Scope.d --- a/dmd/Scope.d Mon Aug 30 15:40:51 2010 +0200 +++ b/dmd/Scope.d Mon Aug 30 18:38:35 2010 +0400 @@ -165,6 +165,17 @@ this.docbuf = enclosing.docbuf; assert(this !is enclosing); /// huh? } + + Scope clone() + { + // similar code is used in Type.clone() + // TODO: move to Util or something... + size_t size = __traits(classInstanceSize, typeof(this)); + void* mem = malloc(size); + memcpy(mem, this, size); + + return cast(typeof(this))mem; + } Scope push() {