Ejemplo n.º 1
0
        public static void CheckAddInvocation(ICSharpCode.NRefactory.Semantics.MemberResolveResult res, string methodName)
        {
            var    member       = res.Member;
            string typeFullName = SkJs.GetEntityJsName(member.DeclaringType);
            bool   exported     = Sk.IsJsExported(member);

            if (!exported || typeDefaultIsExported.Contains(typeFullName))
            {
                InvocationLocation Loc = null;
                var firstNode          = res.GetFirstNode();
                if (firstNode != null)
                {
                    Loc = new InvocationLocation {
                        FileName = firstNode.GetFileName(), Line = firstNode.StartLocation.Line
                    }
                }
                ;

                if (Loc != null)
                {
                    if (member.IsStatic)
                    {
                        methodName = "Static_" + methodName;
                    }
                    AddInvocation(typeFullName, methodName, Loc);
                }
            }
        }
Ejemplo n.º 2
0
        public static JsMemberExpression EntityMethodToJsFunctionRef(IMethod me)
        {
            var ownerType = me.GetDeclaringTypeDefinition();

            if (Sk.IsGlobalMethod(me))
            {
                var member = Js.Member(SkJs.GetEntityJsName(me));
                return(member);
            }
            else
            {
                var member = SkJs.EntityToMember(ownerType);
                if (!me.IsStatic)
                {
                    if (Sk.IsNativeType(ownerType))
                    {
                        member = member.Member("prototype");
                    }
                    else
                    {
                        member = member.Member("commonPrototype");
                    }
                }
                member = member.Member(SkJs.GetEntityJsName(me));
                return(member);
            }
        }
Ejemplo n.º 3
0
 static string GetMethodPrefix(IMethod me)
 {
     if (me.IsExplicitInterfaceImplementation)
     {
         return(SkJs.GetEntityJsName(me.ImplementedInterfaceMembers.First().DeclaringType, true) + "$$"); //TODO: impl. of ns1.IName and ns2.IName (same name) will not work. Full path should added.
     }
     if (me.DeclaringType.Kind == TypeKind.Interface)
     {
         return(SkJs.GetEntityJsName(me.DeclaringType, true) + "$$");
     }
     return("");
 }
Ejemplo n.º 4
0
        public static void AddYieldReturn(ICSharpCode.NRefactory.CSharp.YieldReturnStatement node)
        {
            var result = node.Expression.Resolve() as ICSharpCode.NRefactory.Semantics.ConversionResolveResult;

            try
            {
                if (result != null)
                {
                    string k;
                    if (result.Input.Type.Kind == TypeKind.Null)
                    {
                        k = "null";
                    }
                    else
                    {
                        k = SkJs.GetEntityJsName(result.Input.Type);
                    }

                    InvocationLocation loc = new InvocationLocation {
                        FileName = node.GetFileName(), Line = node.StartLocation.Line
                    };
                    if (!YieldType2Location.ContainsKey(k))
                    {
                        YieldType2Location.Add(k, new List <InvocationLocation> {
                            loc
                        });
                    }
                    else
                    {
                        YieldType2Location[k].Add(loc);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }