• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JSExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: MakeLhsForAssignment

        public static JSExpression MakeLhsForAssignment (JSExpression rhs) {
            var fa = rhs as JSFieldAccess;
            var pa = rhs as JSPropertyAccess;
            if ((fa != null) && (fa.IsWrite == false))
                return new JSFieldAccess(fa.ThisReference, fa.Field, true);
            else if ((pa != null) && (pa.IsWrite == false))
                return new JSPropertyAccess(
                    pa.ThisReference, pa.Property, true, pa.TypeQualified, pa.OriginalType, pa.OriginalMethod, pa.IsVirtualCall
                );

            return rhs;
        }
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:12,代码来源:DecomposeMutationOperators.cs


示例17: MakeReadVersion

        public static JSExpression MakeReadVersion (JSExpression e) {
            var fa = e as JSFieldAccess;
            var pa = e as JSPropertyAccess;
            if ((fa != null) && fa.IsWrite)
                return new JSFieldAccess(fa.ThisReference, fa.Field, false);
            else if ((pa != null) && pa.IsWrite)
                return new JSPropertyAccess(
                    pa.ThisReference, pa.Property, false, pa.TypeQualified, pa.OriginalType, pa.OriginalMethod, pa.IsVirtualCall
                );

            return e;
        }
开发者ID:cbsistem,项目名称:JSIL,代码行数:12,代码来源:DecomposeMutationOperators.cs


示例18: IsCopyNeededForAssignmentTarget

        protected bool IsCopyNeededForAssignmentTarget (JSExpression target) {
            if (!OptimizeCopies)
                return true;

            if (IsImmutable(target))
                return false;

            var variable = target as JSVariable;
            if (variable != null)
                return SecondPass.ModifiedVariables.Contains(variable.Name);

            return true;
        }
开发者ID:kboga,项目名称:JSIL,代码行数:13,代码来源:EmulateStructAssignment.cs


示例19: VisitNode

        public void VisitNode (JSPropertySetterInvocation psi) {
            if (ParentNode is JSExpressionStatement) {
                VisitChildren(psi);
                return;
            }

            var thisReference = psi.Invocation.ThisReference;
            var valueType = psi.GetActualType(TypeSystem);
            var thisType = thisReference.GetActualType(TypeSystem);

            JSExpression tempThis;
            JSExpression[] tempArguments = new JSExpression[psi.Invocation.Arguments.Count];
            var commaElements = new List<JSExpression>();

            tempThis = Hoist(thisReference, thisType, commaElements);

            for (var i = 0; i < tempArguments.Length; i++) {
                var arg = psi.Invocation.Arguments[i];
                var argType = arg.GetActualType(TypeSystem);

                tempArguments[i] = Hoist(arg, argType, commaElements);
            }

            var resultInvocation = psi.Invocation;

            if ((tempThis != null) || tempArguments.Any(ta => ta != null)) {
                resultInvocation = psi.Invocation.FilterArguments(
                    (i, a) => {
                        if ((i >= 0) && (tempArguments[i] != null))
                            return tempArguments[i];
                        else if ((i == -1) && (tempThis != null))
                            return tempThis;
                        else
                            return a;
                    }
                );
            }

            commaElements.Add(resultInvocation);

            if (tempArguments.Last() != null)
                commaElements.Add(tempArguments.Last());
            else
                commaElements.Add(psi.Value);

            var replacement = new JSCommaExpression(commaElements.ToArray());

            ParentNode.ReplaceChild(psi, replacement);
            VisitReplacement(replacement);
        }
开发者ID:Don191,项目名称:JSIL,代码行数:50,代码来源:SynthesizePropertySetterReturnValues.cs


示例20: EmitField

        public void EmitField(DecompilerContext context, IAstEmitter astEmitter, FieldDefinition field, JSRawOutputIdentifier dollar, JSExpression defaultValue)
        {
            var fieldInfo = Translator.TypeInfoProvider.GetField(field);
            var typeKeyword = WasmUtil.PickTypeKeyword(fieldInfo.FieldType);

            // Unhandled type
            if (typeKeyword == null)
                return;

            Switch(PrecedingType.Global);

            Formatter.WriteRaw("(global ${0} {1})", WasmUtil.EscapeIdentifier(fieldInfo.Name), typeKeyword);
            Formatter.ConditionalNewLine();
        }
开发者ID:nanexcool,项目名称:ilwasm,代码行数:14,代码来源:AssemblyEmitter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JSNode类代码示例发布时间:2022-05-24
下一篇:
C# JSContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap