public void VisitNode(JSPassByReferenceExpression pbr) { if (GetConstructedReference(pbr) != null) ReferencesToTransform.Add(pbr); VisitChildren(pbr); }
public void VisitNode(JSPassByReferenceExpression pbr) { if (GetConstructedReference(pbr) != null) { ReferencesToTransform.Add(pbr); } VisitChildren(pbr); }
protected JSVariable GetConstructedReference(JSPassByReferenceExpression pbr) { JSVariable referentVariable; JSExpression referent; if (!JSReferenceExpression.TryMaterialize(JSIL, pbr.Referent, out referent)) { // If the reference can be dereferenced, but cannot be materialized, it is // a constructed reference. if (JSReferenceExpression.TryDereference(JSIL, pbr.Referent, out referent)) { referentVariable = referent as JSVariable; // Ignore variables we previously transformed. if ((referentVariable != null) && TransformedVariables.Contains(referentVariable.Identifier)) { return(null); } return(referentVariable); } else { return(null); } } referentVariable = referent as JSVariable; if (referentVariable == null) { return(null); } // Ignore variables we previously transformed. if (TransformedVariables.Contains(referentVariable.Identifier)) { return(null); } // If the variable does not match the one in the dictionary, it is a constructed // reference to a parameter. if (!referentVariable.Equals(Variables[referentVariable.Identifier])) { // If the parameter is a reference, we don't care about it. if (Variables[referentVariable.Identifier].IsReference) { return(null); } else { return(referentVariable); } } return(null); }
protected JSVariable GetReferentVariable (JSPassByReferenceExpression pbr) { JSVariable referentVariable; JSExpression referent; if (!JSReferenceExpression.TryMaterialize(JSIL, pbr.Referent, out referent)) { if (JSReferenceExpression.TryDereference(JSIL, pbr.Referent, out referent)) { referentVariable = referent as JSVariable; return referentVariable; } else return null; } referentVariable = referent as JSVariable; return referentVariable; }
protected JSVariable GetConstructedReference (JSPassByReferenceExpression pbr) { JSVariable referentVariable; JSExpression referent; if (!JSReferenceExpression.TryMaterialize(JSIL, pbr.Referent, out referent)) { // If the reference can be dereferenced, but cannot be materialized, it is // a constructed reference. if (JSReferenceExpression.TryDereference(JSIL, pbr.Referent, out referent)) { referentVariable = referent as JSVariable; // Ignore variables we previously transformed. if ((referentVariable != null) && TransformedVariables.Contains(referentVariable.Identifier)) return null; return referentVariable; } else return null; } referentVariable = referent as JSVariable; if (referentVariable == null) return null; // Ignore variables we previously transformed. if (TransformedVariables.Contains(referentVariable.Identifier)) return null; // If the variable does not match the one in the dictionary, it is a constructed // reference to a parameter. var theVariable = Variables[referentVariable.Identifier]; if (!referentVariable.Equals(theVariable)) { // If the parameter is a reference, we don't care about it. if (theVariable.IsReference) { // Unless it's the 'this' variable... if (theVariable.IsThis) { // But we handle that separately. return referentVariable; } else { return null; } } else return referentVariable; } return null; }
public void VisitNode(JSPassByReferenceExpression byref) { JSExpression referent; if (JSReferenceExpression.TryMaterialize(JSIL, byref.Referent, out referent)) { Output.Comment("ref"); Visit(referent); } else { Output.Identifier("JSIL.UnmaterializedReference", null); Output.LPar(); Output.RPar(); } }
protected JSVariable GetReferentVariable(JSPassByReferenceExpression pbr) { JSVariable referentVariable; JSExpression referent; if (!JSReferenceExpression.TryMaterialize(JSIL, pbr.Referent, out referent)) { if (JSReferenceExpression.TryDereference(JSIL, pbr.Referent, out referent)) { referentVariable = referent as JSVariable; return(referentVariable); } else { return(null); } } referentVariable = referent as JSVariable; return(referentVariable); }