Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }