示例#1
0
        public JSNewArrayElementReference NewElementReference(JSExpression target, JSExpression index)
        {
            var           arrayType = TypeUtil.DereferenceType(target.GetActualType(TypeSystem));
            TypeReference resultType;

            if (PackedArrayUtil.IsPackedArrayType(arrayType))
            {
                resultType = new ByReferenceType(
                    PackedArrayUtil.GetElementType(arrayType)
                    );
            }
            else if (TypeUtil.IsArray(arrayType))
            {
                resultType = new ByReferenceType(
                    TypeUtil.GetElementType(arrayType, true)
                    );
            }
            else
            {
                throw new ArgumentException("Cannot create a reference to an element of a value of type '" + arrayType.FullName + "'", target.ToString());
            }

            if (PackedArrayUtil.IsPackedArrayType(target.GetActualType(TypeSystem)))
            {
                return(new JSNewPackedArrayElementReference(resultType, target, index));
            }
            else
            {
                return(new JSNewArrayElementReference(resultType, target, index));
            }
        }
示例#2
0
        public void VisitNode(JSInvocationExpression invocation)
        {
            var        jsm    = invocation.JSMethod;
            MethodInfo method = null;

            if (jsm != null)
            {
                method = jsm.Method;
            }

            bool isOverloaded = (method != null) &&
                                method.IsOverloadedRecursive &&
                                !method.Metadata.HasAttribute("JSIL.Meta.JSRuntimeDispatch");

            if (isOverloaded && JavascriptAstEmitter.CanUseFastOverloadDispatch(method))
            {
                isOverloaded = false;
            }

            if ((method != null) && method.DeclaringType.IsInterface)
            {
                // HACK
                if (!PackedArrayUtil.IsPackedArrayType(jsm.Reference.DeclaringType))
                {
                    CacheInterfaceMember(jsm.Reference.DeclaringType, jsm.Identifier);
                }
            }

            if ((jsm != null) && (method != null) && isOverloaded)
            {
                CacheSignature(jsm.Reference, method.Signature, false);
            }

            VisitChildren(invocation);
        }
示例#3
0
        public void VisitNode(JSNewArrayExpression nae)
        {
            var parentBoe = ParentNode as JSBinaryOperatorExpression;

            if (parentBoe != null)
            {
                var leftField = parentBoe.Left as JSFieldAccess;
                if (
                    (leftField != null) &&
                    PackedArrayUtil.IsPackedArrayType(leftField.Field.Field.FieldType)
                    )
                {
                    JSNewPackedArrayExpression replacement;
                    if (nae.Dimensions != null)
                    {
                        replacement = new JSNewPackedArrayExpression(leftField.Field.Field.FieldType, nae.ElementType, nae.Dimensions, nae.SizeOrArrayInitializer);
                    }
                    else
                    {
                        replacement = new JSNewPackedArrayExpression(leftField.Field.Field.FieldType, nae.ElementType, nae.SizeOrArrayInitializer);
                    }
                    ParentNode.ReplaceChild(nae, replacement);
                    VisitReplacement(replacement);
                    return;
                }
            }

            VisitChildren(nae);
        }