internal COWValue(COWValueInternal backer) { this.backer = backer; #if UDONSHARP_DEBUG stackTrace = new System.Diagnostics.StackTrace(true); #endif backer.AddRef(this); }
public COWValue GetCOWValue(ASTVisitorContext visitorContext) { if (cowValue != null) { if (cowValue.visitorContext != visitorContext) { // Hmm... new compilation context? Dirty it and get a new one. cowValue.MarkDirty(); cowValue = null; } else if (cowValue.isDirty || cowValue.referenceCount == 0) { // If the reference count is 0, we've probably moved scopes. We clear out the cowValue here to make sure that a cowValue is only used in one scope at a time. cowValue = null; } else { return(new COWValue(cowValue)); } } cowValue = new COWValueInternal(visitorContext, this); return(new COWValue(cowValue)); }