当前位置: 首页>>代码示例>>C#>>正文


C# JSExpression类代码示例

本文整理汇总了C#中JSExpression的典型用法代码示例。如果您正苦于以下问题:C# JSExpression类的具体用法?C# JSExpression怎么用?C# JSExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JSExpression类属于命名空间,在下文中一共展示了JSExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MatchesConstructedReference

        protected bool MatchesConstructedReference (JSExpression lhs, JSVariable rhs) {
            var jsv = lhs as JSVariable;
            if ((jsv != null) && (jsv.Identifier == rhs.Identifier))
                return true;

            return false;
        }
开发者ID:cbsistem,项目名称:JSIL,代码行数:7,代码来源:IntroduceVariableReferences.cs

示例2: EliminateVariable

        protected void EliminateVariable (JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) {
            {
                var replacer = new VariableEliminator(
                    variable,
                    JSChangeTypeExpression.New(replaceWith, variable.GetActualType(TypeSystem), TypeSystem)
                );
                replacer.Visit(context);
            }

            {
                var replacer = new VariableEliminator(variable, replaceWith);
                var assignments = (from a in FirstPass.Assignments where 
                                       variable.Equals(a.NewValue) ||
                                       a.NewValue.SelfAndChildrenRecursive.Any(variable.Equals)
                                       select a).ToArray();

                foreach (var a in assignments) {
                    if (!variable.Equals(a.NewValue))
                        replacer.Visit(a.NewValue);
                }
            }

            Variables.Remove(variable.Identifier);
            FunctionSource.InvalidateFirstPass(method);
        }
开发者ID:Don191,项目名称:JSIL,代码行数:25,代码来源:EliminateSingleUseTemporaries.cs

示例3: Coalesce

 public JSInvocationExpression Coalesce(JSExpression left, JSExpression right, TypeReference expectedType)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot("Coalesce", expectedType),
         new[] { left, right }, true
     );
 }
开发者ID:c444b774,项目名称:JSIL,代码行数:7,代码来源:SpecialIdentifiers.cs

示例4: CheckType

 public JSInvocationExpression CheckType(JSExpression expression, TypeReference targetType)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot("CheckType", TypeSystem.Boolean),
         new[] { expression, new JSTypeOfExpression(targetType) }, true
     );
 }
开发者ID:robterrell,项目名称:JSIL,代码行数:7,代码来源:SpecialIdentifiers.cs

示例5: ExtractOffsetFromPointerExpression

        public static bool ExtractOffsetFromPointerExpression(JSExpression pointer, TypeSystem typeSystem, out JSExpression newPointer, out JSExpression offset)
        {
            offset = null;
            newPointer = pointer;

            var boe = pointer as JSBinaryOperatorExpression;
            if (boe == null)
                return false;

            var leftType = boe.Left.GetActualType(typeSystem);
            var rightType = boe.Right.GetActualType(typeSystem);
            var resultType = boe.GetActualType(typeSystem);

            if (!resultType.IsPointer)
                return false;

            if (!TypeUtil.IsIntegral(rightType))
                return false;

            if (boe.Operator != JSOperator.Add)
                return false;

            newPointer = boe.Left;
            offset = boe.Right;
            return true;
        }
开发者ID:rangerofthewest,项目名称:JSIL,代码行数:26,代码来源:UnsafeCodeTransforms.cs

示例6: CastToInteger

 protected JSInvocationExpression CastToInteger(JSExpression booleanExpression)
 {
     return JSInvocationExpression.InvokeMethod(
         JS.Number(TypeSystem.SByte),
         booleanExpression, null, true
     );
 }
开发者ID:shreedharcva,项目名称:JSIL,代码行数:7,代码来源:HandleBooleanAsInteger.cs

示例7: GetTypeFromAssembly

 public JSInvocationExpression GetTypeFromAssembly(JSExpression assembly, JSExpression typeName, JSExpression throwOnFail)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot("GetTypeFromAssembly", new TypeReference("System", "Type", TypeSystem.Object.Module, TypeSystem.Object.Scope)),
         new[] { assembly, typeName, new JSNullLiteral(TypeSystem.Object), throwOnFail }, true
     );
 }
开发者ID:zgramana,项目名称:JSIL,代码行数:7,代码来源:SpecialIdentifiers.cs

示例8: Cast

 public JSExpression Cast(JSExpression expression, TypeReference targetType)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot("Cast", targetType),
         new[] { expression, new JSTypeOfExpression(targetType) }, true
     );
 }
开发者ID:robterrell,项目名称:JSIL,代码行数:7,代码来源:SpecialIdentifiers.cs

示例9: Hoist

        private JSExpression Hoist (JSExpression expression, TypeReference type, List<JSExpression> commaElements) {
            if (expression is JSVariable)
                return null;
            else if (expression is JSLiteral)
                return null;

            var thisBoe = expression as JSBinaryOperatorExpression;
            if ((thisBoe != null) &&
                (thisBoe.Operator == JSOperator.Assignment) &&
                (thisBoe.Left is JSVariable)
            ) {
                // If the value is (x = y), insert 'x = y' and then set the value to 'x'
                commaElements.Add(thisBoe);
                return thisBoe.Left;
            } else {
                var tempVar = new JSRawOutputIdentifier(
                    type, "$temp{0:X2}", Function.TemporaryVariableCount++
                );

                commaElements.Add(new JSBinaryOperatorExpression(
                    JSOperator.Assignment, tempVar, expression, type
                ));

                return tempVar;
            }
        }
开发者ID:Don191,项目名称:JSIL,代码行数:26,代码来源:SynthesizePropertySetterReturnValues.cs

示例10: IsEffectivelyConstant

        protected bool IsEffectivelyConstant(JSExpression expression)
        {
            if (expression.IsConstant)
                return true;

            var invocation = expression as JSInvocationExpression;
            FunctionAnalysis2ndPass secondPass = null;
            if ((invocation != null) && (invocation.JSMethod != null)) {
                secondPass = FunctionSource.GetSecondPass(invocation.JSMethod);

                if ((secondPass != null) && secondPass.IsPure)
                    return true;

                var methodName = invocation.JSMethod.Method.Name;
                if ((methodName == "IDisposable.Dispose") || (methodName == "Dispose")) {
                    var thisType = invocation.ThisReference.GetActualType(TypeSystem);

                    if (thisType != null) {
                        var typeInfo = TypeInfo.GetExisting(thisType);

                        if ((typeInfo != null) && typeInfo.Metadata.HasAttribute("JSIL.Meta.JSPureDispose"))
                            return true;
                    }
                }
            }

            return false;
        }
开发者ID:nateleroux,项目名称:JSIL,代码行数:28,代码来源:EliminatePointlessFinallyBlocks.cs

示例11: CheckInvocationSafety

        public static void CheckInvocationSafety(MethodInfo method, JSExpression[] argumentValues, TypeSystem typeSystem)
        {
            if (method.Metadata.HasAttribute("JSIL.Meta.JSAllowPackedArrayArgumentsAttribute"))
                return;

            TypeReference temp;
            string[] argumentNames = GetPackedArrayArgumentNames(method, out temp);

            for (var i = 0; i < method.Parameters.Length; i++) {
                if (i >= argumentValues.Length)
                    continue;

                var valueType = argumentValues[i].GetActualType(typeSystem);

                if (!IsPackedArrayType(valueType)) {
                    if ((argumentNames != null) && argumentNames.Contains(method.Parameters[i].Name))
                        throw new ArgumentException(
                            "Invalid attempt to pass a normal array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
                            "This parameter must be a packed array."
                        );
                } else {
                    if ((argumentNames == null) || !argumentNames.Contains(method.Parameters[i].Name))
                        throw new ArgumentException(
                            "Invalid attempt to pass a packed array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
                            "If this is intentional, annotate the method with the JSPackedArrayArguments attribute."
                        );
                }
            }
        }
开发者ID:jean80it,项目名称:JSIL,代码行数:29,代码来源:PackedStructArray.cs

示例12: IsImmutable

        protected bool IsImmutable (JSExpression target) {
            while (target is JSReferenceExpression)
                target = ((JSReferenceExpression)target).Referent;

            var fieldAccess = target as JSFieldAccess;
            if (fieldAccess != null) {
                return fieldAccess.Field.Field.Metadata.HasAttribute("JSIL.Meta.JSImmutable");
            }

            var dot = target as JSDotExpressionBase;
            if (dot != null) {
                if (IsImmutable(dot.Target))
                    return true;
                else if (IsImmutable(dot.Member))
                    return true;
            }

            var indexer = target as JSIndexerExpression;
            if (indexer != null) {
                if (IsImmutable(indexer.Target))
                    return true;
            }

            return false;
        }
开发者ID:rangerofthewest,项目名称:JSIL,代码行数:25,代码来源:EmulateStructAssignment.cs

示例13: FilterInvocationResult

        public static JSExpression FilterInvocationResult(
            MethodReference methodReference, MethodInfo method, 
            JSExpression result, 
            ITypeInfoSource typeInfo, TypeSystem typeSystem
        )
        {
            if (method == null)
                return result;

            var resultType = result.GetActualType(typeSystem);
            var resultIsPackedArray = PackedArrayUtil.IsPackedArrayType(resultType);
            var returnValueAttribute = method.Metadata.GetAttribute("JSIL.Meta.JSPackedArrayReturnValueAttribute");

            if (returnValueAttribute != null) {
                if (TypeUtil.IsOpenType(resultType)) {
                    // FIXME: We need to restrict substitution to when the result type is a generic parameter owned by the invocation...
                    resultType = JSExpression.SubstituteTypeArgs(typeInfo, resultType, methodReference);
                }

                if (!resultIsPackedArray)
                    return JSChangeTypeExpression.New(result, PackedArrayUtil.MakePackedArrayType(resultType, returnValueAttribute.Entries.First().Type), typeSystem);
            }

            return result;
        }
开发者ID:kboga,项目名称:JSIL,代码行数:25,代码来源:PackedStructArray.cs

示例14: Cast

        public JSExpression Cast(JSExpression expression, TypeReference targetType)
        {
            var currentType = ILBlockTranslator.DereferenceType(expression.GetExpectedType(TypeSystem));
            targetType = ILBlockTranslator.DereferenceType(targetType);

            if (targetType.MetadataType == MetadataType.Char) {
                return JSInvocationExpression.InvokeStatic(JS.fromCharCode, new[] { expression }, true);
            } else if (
                (currentType.MetadataType == MetadataType.Char) &&
                ILBlockTranslator.IsIntegral(targetType)
            ) {
                return JSInvocationExpression.InvokeMethod(JS.charCodeAt, expression, new[] { JSLiteral.New(0) }, true);
            } else if (
                ILBlockTranslator.IsEnum(currentType) &&
                ILBlockTranslator.IsIntegral(targetType)
            ) {
                return new JSDotExpression(
                    expression, new JSStringIdentifier("value", targetType)
                );
            } else {
                return JSInvocationExpression.InvokeStatic(
                    Dot("Cast", targetType),
                    new [] { expression, new JSType(targetType) }, true
                );
            }
        }
开发者ID:robashton,项目名称:JSIL,代码行数:26,代码来源:SpecialIdentifiers.cs

示例15: FixupThisArgument

        protected JSExpression FixupThisArgument(JSExpression thisArgument, TypeSystem typeSystem)
        {
            var expectedType = thisArgument.GetActualType(typeSystem);
            if (expectedType.FullName == "System.Type")
                return new JSPublicInterfaceOfExpression(thisArgument);

            return thisArgument;
        }
开发者ID:shreedharcva,项目名称:JSIL,代码行数:8,代码来源:DynamicCallSites.cs


注:本文中的JSExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。