Ejemplo n.º 1
0
        int[] GetIds(Player p, string[] parts, CommandData data, out string[] names)
        {
            int        count = Math.Max(1, parts.Length - 1);
            List <int> ids   = new List <int>();

            names = new string[count];

            for (int i = 0; i < names.Length; i++)
            {
                names[i] = PlayerDB.MatchNames(p, parts[i]);
                if (names[i] == null)
                {
                    return(null);
                }

                Group grp = PlayerInfo.GetGroup(names[i]);
                if (!p.name.CaselessEq(names[i]))
                {
                    if (!CheckRank(p, data, grp.Permission, "undo", false))
                    {
                        return(null);
                    }
                }

                ids.AddRange(NameConverter.FindIds(names[i]));
            }
            return(ids.ToArray());
        }
Ejemplo n.º 2
0
        protected override void AddHeader(StringBuilder builder)
        {
            builder.Append(string.Format(@"using NSubstitute;
using NUnit.Framework;

namespace MyModule.{0}
{{
    public class {0}ModelTest
    {{   
        private {0}Model {1}Model;
        private {0}Presenter {1}Presenter;

        [SetUp]
        public void SetUp()
        {{
            {1}Presenter = Substitute.For<{0}Presenter>();
            {1}Model = new {0}Model();
            {1}Model.SetPresenter({1}Presenter);
            throw new System.NotImplementedException();
        }}

        [Test]
        public void TestOnShow()
        {{
            {1}Model.OnShow();
            throw new System.NotImplementedException();
        }}", ModuleName, NameConverter.ConvertPrivateField(ModuleName)));
        }
Ejemplo n.º 3
0
 protected override void AddOnButtonClickMethod(StringBuilder builder, string gameObjectName)
 {
     builder.Append(string.Format(@"        private void OnClick{0} ()
 {{
     
 }}", gameObjectName, NameConverter.RemoveButton(gameObjectName)));
 }
Ejemplo n.º 4
0
        internal static void Create(Player p)
        {
            p.prefix     = "";
            p.time       = new TimeSpan(0, 0, 0, 1);
            p.title      = "";
            p.titlecolor = "";
            p.color      = p.group.color;
            p.money      = 0;

            p.firstLogin    = DateTime.Now;
            p.totalLogins   = 1;
            p.totalKicked   = 0;
            p.overallDeath  = 0;
            p.overallBlocks = 0;
            p.TotalDrawn    = 0;
            string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            Database.Backend.AddRow("Players", "Name, IP, FirstLogin, LastLogin, totalLogin, Title, " +
                                    "totalDeaths, Money, totalBlocks, totalKicked, TimeSpent",
                                    p.name, p.ip, now, now, 1, "", 0, 0, 0, 0, p.time.ToDBTime());

            using (DataTable ids = Database.Backend.GetRows("Players",
                                                            "ID", "WHERE Name = @0", p.name)) {
                if (ids.Rows.Count > 0)
                {
                    string id = ids.Rows[0]["ID"].ToString();
                    p.UserID = PlayerData.ParseInt(id);
                }
                else
                {
                    p.UserID = NameConverter.InvalidNameID(p.name);
                }
            }
        }
Ejemplo n.º 5
0
 protected override void AddOnButtonClickMethod(StringBuilder builder, string gameObjectName)
 {
     builder.Append(string.Format(@"        public void {0} ()
 {{
     throw new System.NotImplementedException();
 }}", NameConverter.RemoveButton(gameObjectName)));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Create a type defrinition for the given class file and all inner classes.
        /// </summary>
        public override void CreateType(NetTypeDefinition declaringType, NetModule module, TargetFramework target)
        {
            if (declaringType == null)
            {
                throw new ArgumentNullException("declaringType");
            }
            docClass = target.GetXmlClass(cf);

            var name = NameConverter.UpperCamelCase(inner.IsAnonymous ? cf.Name : inner.Name);

            name = CreateTypeName(declaringType, cf, name, null);

            var finalFullName = parentFullName + "/" + name;

            var attributes = GetAttributes(cf);

            typeDef = new NetTypeDefinition(cf, target, module.Scope)
            {
                Name = name, Attributes = attributes
            };
            typeDef.OriginalJavaClassName = cf.ClassName;
            typeDef.Description           = (docClass != null) ? docClass.Description : null;
            parent.AddNestedType(typeDef, "", module, ref finalFullName);

            // Prepare generics
            CreateGenericParameters(cf, typeDef);

            // Add mapping
            RegisterType(target, cf, typeDef);
            CreateNestedTypes(cf, typeDef, finalFullName, module, target);
        }
Ejemplo n.º 7
0
        public void ToCsharpTest()
        {
            User   user = new User();
            string test = "ar_id_a";

            System.Console.WriteLine(NameConverter.ToCsharp(test));
        }
Ejemplo n.º 8
0
 protected virtual string GenerateSubSelectSourceString(ISubSelect subSelect, IAlias alias = null)
 {
     return(string.Concat("(", GenerateSqlString(subSelect.SqlStatement), ")",
                          (alias != null) ? " As " + NameConverter.GenerateAliasNameString(alias) : string.Empty));
     //return string.Concat("(", GenerateSqlString(subSelect.SqlStatement), ")",
     //                     subSelect is IAlias ? " As " + NameConvertor.CheckedItemNameString(((IAlias)subSelect).Alias) : string.Empty);
 }
        private Tuple <string, string> GetFromRenderingItem(Rendering rendering, GetRendererArgs args)
        {
            Template renderingTemplate = args.RenderingTemplate;

            if (renderingTemplate == null)
            {
                return(null);
            }

            if (!renderingTemplate.DescendsFromOrEquals(TemplateIds.ControllerRendering))
            {
                return(null);
            }

            RenderingItem renderingItem = rendering.RenderingItem;

            if (renderingItem == null)
            {
                return(null);
            }

            string controllerName = renderingItem.InnerItem["Controller"];
            string actionName     = renderingItem.InnerItem["Controller Action"];

            if (controllerName.IsWhiteSpaceOrNull())
            {
                controllerName = NameConverter.ConvertItemNameToClassName(renderingItem.Name);
            }

            return(new Tuple <string, string>(controllerName, actionName));
        }
Ejemplo n.º 10
0
        private static string GetRangeSumFormula(int startRow, int endRow, int column)
        {
            string cellRangeString = NameConverter.ConvertCellIndexesToName(startRow, column, endRow, column);
            string sumFormula      = string.Format("=SUM({0})", cellRangeString);

            return(sumFormula);
        }
Ejemplo n.º 11
0
        void UndoLastDrawOp(Player p)
        {
            UndoDrawOpEntry[] entries = p.DrawOps.Items;
            if (entries.Length == 0)
            {
                p.Message("You have no draw operations to undo.");
                p.Message("Try using %T/Undo [timespan] %Sinstead.");
                return;
            }

            for (int i = entries.Length - 1; i >= 0; i--)
            {
                UndoDrawOpEntry entry = entries[i];
                if (entry.DrawOpName == "UndoSelf")
                {
                    continue;
                }
                p.DrawOps.Remove(entry);

                UndoSelfDrawOp op = new UndoSelfDrawOp();
                op.who = p.name; op.ids = NameConverter.FindIds(p.name);

                op.Start = entry.Start; op.End = entry.End;
                DrawOpPerformer.Do(op, null, p, new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal });
                p.Message("Undo performed.");
                return;
            }

            p.Message("Unable to undo any draw operations, as all of the " +
                      "past 50 draw operations are %T/Undo %Sor %T/Undo [timespan]");
            p.Message("Try using %T/Undo [timespan] %Sinstead");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create a type defrinition for the given class file and all inner classes.
        /// </summary>
        public override void CreateType(NetTypeDefinition declaringType, NetModule module, TargetFramework target)
        {
            if (declaringType != null)
            {
                throw new ArgumentException("Declaring type should be null");
            }
            docClass = target.GetXmlClass(cf);

            var fullName = GetFullName();
            var dotIndex = fullName.LastIndexOf('.');
            var ns       = (dotIndex > 0) ? NameConverter.UpperCamelCase(fullName.Substring(0, dotIndex)) : String.Empty;
            var name     = (dotIndex > 0) ? NameConverter.UpperCamelCase(fullName.Substring(dotIndex + 1)) : fullName;

            name = CreateTypeName(null, cf, name, ns);

            typeDef                        = new NetTypeDefinition(cf, target, module.Scope);
            typeDef.Name                   = name;
            typeDef.Namespace              = ns;
            typeDef.OriginalJavaClassName  = cf.ClassName;
            typeDef.Attributes             = GetAttributes(cf, cf.Fields.Any());
            typeDef.IgnoreGenericArguments = !AddGenericParameters;
            typeDef.Description            = (docClass != null) ? docClass.Description : null;
            module.Types.Add(typeDef);

            // Prepare generics
            CreateGenericParameters(cf, typeDef);

            // Add mapping
            var finalFullName = string.IsNullOrEmpty(ns) ? name : ns + "." + name;

            RegisterType(target, cf, typeDef);
            CreateNestedTypes(cf, typeDef, finalFullName, module, target);
        }
Ejemplo n.º 13
0
        private void Add()
        {
            if (string.IsNullOrEmpty(AddData))
            {
                return;
            }

            var parts = AddData.Split(',');

            if (parts.Length != 2)
            {
                return;
            }

            var nameResult = NameConverter.ValidateName(parts[0]);
            var ageResult  = AgeConverter.ValidateAge(parts[1]);

            if (!nameResult || !ageResult)
            {
                MessageBox.Show("Error input");
                return;
            }

            var sytudent = new Student(parts[0], Convert.ToInt32(parts[1]));

            Students.Add(sytudent);
            OnPropertyChanged("Students");
        }
Ejemplo n.º 14
0
        public override void Use(Player p, string message, CommandData data)
        {
            TimeSpan delta = TimeSpan.Zero;
            bool area = message.CaselessStarts("area ");
            if (area) message = message.Substring("area ".Length);

            if (message.Length == 0) message = p.name;
            string[] parts = message.SplitSpaces();

            if (parts.Length >= 2) {
                if (!CommandParser.GetTimespan(p, parts[1], ref delta, "highlight the past", "s")) return;
            } else {
                delta = TimeSpan.FromMinutes(30);
            }

            parts[0] = PlayerDB.MatchNames(p, parts[0]);
            if (parts[0] == null) return;
            int[] ids = NameConverter.FindIds(parts[0]);

            if (!area) {
                Vec3S32[] marks = new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal };
                HighlightPlayer(p, delta, parts[0], ids, marks);
            } else {
                p.Message("Place or break two blocks to determine the edges.");
                HighlightAreaArgs args = new HighlightAreaArgs();
                args.ids = ids; args.who = parts[0]; args.delta = delta;
                p.MakeSelection(2,  "Selecting region for %SHighlight", args, DoHighlightArea);
            }
        }
Ejemplo n.º 15
0
        protected override void AddAwake(StringBuilder builder, IEnumerable <string> buttonGameObjects,
                                         IEnumerable <string> toggleGameObjects)
        {
            builder.Append(@"        private void Awake()
        {");
            builder.AppendLine();
            foreach (var gameObjectName in buttonGameObjects)
            {
                builder.Append(string.Format(@"            {0}.onClick.AddListener(OnClick{1});",
                                             NameConverter.ConvertPrivateField(gameObjectName), gameObjectName));
                builder.AppendLine();
            }

            foreach (var gameObjectName in toggleGameObjects)
            {
                builder.Append(string.Format(@"            foreach (var {0} in {1})
                {0}.onValueChanged.AddListener(On{2}Change);",
                                             NameConverter.ToCamel(gameObjectName.Replace("Group", "")),
                                             NameConverter.ConvertPrivateField(gameObjectName),
                                             NameConverter.RemoveGroup(gameObjectName)));
                builder.AppendLine();
            }


            builder.Append("        }");
            builder.AppendLine();
        }
Ejemplo n.º 16
0
        internal static void LoadPlayerLists()
        {
            agreed     = PlayerList.Load("ranks/agreed.txt");
            invalidIds = PlayerList.Load("extra/invalidids.txt");
            Player.Console.DatabaseID = NameConverter.InvalidNameID("(console)");

            bannedIP       = PlayerList.Load("ranks/banned-ip.txt");
            ircControllers = PlayerList.Load("ranks/IRC_Controllers.txt");
            hidden         = PlayerList.Load("ranks/hidden.txt");
            vip            = PlayerList.Load("text/vip.txt");
            noEmotes       = PlayerList.Load("text/emotelist.txt");
            lockdown       = PlayerList.Load("text/lockdown.txt");

            models      = PlayerExtList.Load("extra/models.txt");
            skins       = PlayerExtList.Load("extra/skins.txt");
            reach       = PlayerExtList.Load("extra/reach.txt");
            rotations   = PlayerExtList.Load("extra/rotations.txt");
            modelScales = PlayerExtList.Load("extra/modelscales.txt");

            muted     = PlayerExtList.Load("ranks/muted.txt");
            frozen    = PlayerExtList.Load("ranks/frozen.txt");
            tempRanks = PlayerExtList.Load(Paths.TempRanksFile);
            tempBans  = PlayerExtList.Load(Paths.TempBansFile);

            if (Server.Config.WhitelistedOnly)
            {
                whiteList = PlayerList.Load("ranks/whitelist.txt");
            }
        }
Ejemplo n.º 17
0
        int[] GetIds(Player p, string[] parts, out string[] names)
        {
            int        count = Math.Max(1, parts.Length - 1);
            List <int> ids   = new List <int>();

            names = new string[count];

            for (int i = 0; i < names.Length; i++)
            {
                names[i] = PlayerInfo.FindOfflineNameMatches(p, parts[i]);
                if (names[i] == null)
                {
                    return(null);
                }

                Group grp     = Group.GroupIn(names[i]);
                bool  canUndo = p == null || grp.Permission < p.Rank || p.name.CaselessEq(names[i]);
                if (!canUndo)
                {
                    MessageTooHighRank(p, "undo", false); return(null);
                }

                ids.AddRange(NameConverter.FindIds(names[i]));
            }
            return(ids.ToArray());
        }
Ejemplo n.º 18
0
 protected override void AddOnToggleChangeMethod(StringBuilder builder, string gameObjectName)
 {
     builder.Append(string.Format(@"        public void TurnOn{0}(int index)
 {{
     throw new System.NotImplementedException();
 }}", NameConverter.RemoveGroup(gameObjectName)));
 }
Ejemplo n.º 19
0
 protected override void AddOnToggleChangeMethod(StringBuilder builder, string gameObjectName)
 {
     builder.Append(string.Format(@"        public virtual void TurnOn{0}(int index)
 {{
     Model.TurnOn{0}(index);
 }}", NameConverter.RemoveGroup(gameObjectName)));
 }
Ejemplo n.º 20
0
 public void Apply(IOneToManyCollectionInstance instance)
 {
     instance.Key.Column(string.Format(CultureInfo.InvariantCulture, "{0}_id",
                                       NameConverter.ConvertName(instance.EntityType.Name)));
     instance.Key.ForeignKey(string.Format(CultureInfo.InvariantCulture, "fk_{0}_{1}",
                                           NameConverter.ConvertName(instance.Member.Name), NameConverter.ConvertName(instance.EntityType.Name)));
 }
Ejemplo n.º 21
0
        private static string GetCellsSumFormula(int cell1Row, int cell1Col, int cell2Row, int cell2Col)
        {
            string cell1Name  = NameConverter.ConvertCellIndexToName(cell1Row, cell1Col);
            string cell2Name  = NameConverter.ConvertCellIndexToName(cell2Row, cell2Col);
            string sumFormula = string.Format("={0}+{1}", cell1Name, cell2Name);

            return(sumFormula);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Add references to all implemented interfaces.
 /// </summary>
 protected virtual void ImplementInterfaces(Dex target, NameConverter nsConverter)
 {
     // Implement interfaces
     foreach (var intf in typeDef.Interfaces.Select(x => new ClassReference(x.ClassName)))
     {
         classDef.Interfaces.Add(intf);
     }
 }
Ejemplo n.º 23
0
 public Converter(DataType boxedJavaObject, IEssentials essentials, IILFactory ilFactory, ForeignHelpers helpers)
 {
     Essentials = essentials;
     Type       = new TypeConverter(this, boxedJavaObject, essentials, helpers);
     Name       = new NameConverter(this, ilFactory);
     Param      = new ParamConverter(this);
     Signature  = new SignatureConverter(this, essentials);
 }
        public override string Expand(ObjectClassAdmin @class, IVault vault)
        {
            var @type = vault.ObjectTypeOperations.GetObjectType(@class.ObjectType);

            return(Template
                   ?.Replace("{Class}", NameConverter.ToString(@class.Name))
                   ?.Replace("{ObjectType}", NameConverter.ToString(@type.NameSingular)));
        }
        public void Apply(IIdentityInstance instance)
        {
            var sequenceName = string.Format(CultureInfo.InvariantCulture, "{0}_id_seq", NameConverter.ConvertName(instance.EntityType.Name));
            var columnName   = string.Format(CultureInfo.InvariantCulture, "{0}", NameConverter.ConvertName(instance.Property.Name));

            instance.GeneratedBy.Native(sequenceName);
            instance.Column(columnName);
        }
Ejemplo n.º 26
0
        public ContentCollectionType(ContentCollection contentCollection, Func <IContentStore> getContentStore, string[] languages, string defaultLanguage)
        {
            if (NameConverter.TryConvertToGraphQLName(contentCollection.Name, out string graphQLName))
            {
                Name        = graphQLName;
                Description = "A collection that contains content of a specific type.";

                Field(cc => cc.Id).Description("The id of the content collection.");
                Field(cc => cc.Name).Description("The name of the content collection.");
                Field(cc => cc.Version).Description("The version of the content collection.");
                Field <ContentTypeType>("ContentType");

                var contentItemType = new ContentItemType(contentCollection, languages, defaultLanguage);
                var itemsType       = new ListGraphType(contentItemType);
                this.Field("items",
                           itemsType,
                           arguments: new QueryArguments(
                               new QueryArgument <StringGraphType>()
                {
                    Name = "contentKeyStartsWith"
                },
                               new QueryArgument <IntGraphType>()
                {
                    Name = "first"
                },
                               new QueryArgument <IntGraphType>()
                {
                    Name = "offset"
                }
                               ),
                           resolve: ctx =>
                {
                    var collection = ctx.Source as ContentCollection;
                    if (collection != null)
                    {
                        var contentStore     = getContentStore();
                        var contentItemQuery = new ContentItemQuery
                        {
                            AppId                = contentCollection.ContentType.AppId,
                            CollectionId         = collection.Id,
                            ContentKeyStartsWith = ctx.GetArgument <string>("contentKeyStartsWith"),
                            First                = ctx.GetArgument <int?>("first"),
                            Offset               = ctx.GetArgument <int?>("offset")
                        };
                        return(contentStore.GetContentItems(contentItemQuery));
                    }
                    else
                    {
                        return(null);
                    }
                });
            }
            else
            {
                // TODO: log that a graphQL name could not be generated.
            }
        }
Ejemplo n.º 27
0
        protected override void AddOnButtonClickMethod(StringBuilder builder, string gameObjectName)
        {
            var method = string.Format(@"        public virtual void {0} ()
        {{
            Model.{0}();
        }}", NameConverter.RemoveButton(gameObjectName));

            builder.Append(method);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public DelegateType(AssemblyCompiler compiler, XTypeDefinition delegateType, ClassDefinition interfaceClass, Dex target, NameConverter nsConverter)
        {
            this.compiler = compiler;
            this.delegateType = delegateType;
            this.interfaceClass = interfaceClass;

            // Build invoke prototype
            invokeMethod = delegateType.Methods.First(x => x.EqualsName("Invoke"));
        }
Ejemplo n.º 29
0
        public static bool ShouldWarn(PythonContext/*!*/ context, OverloadInfo/*!*/ method, out WarningInfo info) {
            Assert.NotNull(method);

            ObsoleteAttribute[] os = (ObsoleteAttribute[])method.ReflectionInfo.GetCustomAttributes(typeof(ObsoleteAttribute), true);
            if (os.Length > 0) {
                info = new WarningInfo(
                    PythonExceptions.DeprecationWarning,
                    String.Format("{0}.{1} has been obsoleted.  {2}",
                        NameConverter.GetTypeName(method.DeclaringType),
                        method.Name,
                        os[0].Message
                    )
                );

                return true;
            }

            if (context.PythonOptions.WarnPython30) {
                Python3WarningAttribute[] py3kwarnings = (Python3WarningAttribute[])method.ReflectionInfo.GetCustomAttributes(typeof(Python3WarningAttribute), true);
                if (py3kwarnings.Length > 0) {
                    info = new WarningInfo(
                        PythonExceptions.DeprecationWarning,
                        py3kwarnings[0].Message
                    );

                    return true;
                }
            }

#if FEATURE_APARTMENTSTATE
            // no apartment states on Silverlight
            if (method.DeclaringType == typeof(Thread)) {
                if (method.Name == "Sleep") {
                    info = new WarningInfo(
                        PythonExceptions.RuntimeWarning,
                        "Calling Thread.Sleep on an STA thread doesn't pump messages.  Use Thread.CurrentThread.Join instead.",
                        Expression.Equal(
                            Expression.Call(
                                Expression.Property(
                                    null,
                                    typeof(Thread).GetProperty("CurrentThread")
                                ),
                                typeof(Thread).GetMethod("GetApartmentState")
                            ),
                            AstUtils.Constant(ApartmentState.STA)
                        )
                    );

                    return true;
                }
            }
#endif

            info = null;
            return false;
        }
Ejemplo n.º 30
0
// ReSharper disable VirtualMemberNeverOverriden.Global
        protected virtual string GenerateSourceString(ISource source)
        {
            if (source is ISourceAlias && (((ISourceAlias)source).Source) is ISubSelect)
            {
                return(GenerateSubSelectSourceString((ISubSelect)((ISourceAlias)source).Source, (IAlias)source));
            }
            return(source is ISubSelect
                       ? GenerateSubSelectSourceString((ISubSelect)source)
                       : NameConverter.GenerateSourceNameString(source));
        }
Ejemplo n.º 31
0
        public void Apply(IManyToOneInstance instance)
        {
            var entityName = NameConverter.ConvertName(instance.EntityType.Name);
            var columnName = NameConverter.ConvertName(instance.Name);
            var keyName    = string.Format("fk_{0}_{1}", columnName, entityName);

            instance.ForeignKey(keyName);
            instance.Column(string.Format(CultureInfo.InvariantCulture, "{0}_id", columnName));
            instance.Index(string.Format(CultureInfo.InvariantCulture, "ix_{0}_{1}_id", entityName, columnName));
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public DelegateType(AssemblyCompiler compiler, XTypeDefinition delegateType, ClassDefinition interfaceClass, Dex target, NameConverter nsConverter)
        {
            this.compiler = compiler;
            this.delegateType = delegateType;
            this.interfaceClass = interfaceClass;

            // Build invoke prototype
            invokeMethod = delegateType.Methods.First(x => x.EqualsName("Invoke"));
            XTypeDefinition baseType = delegateType;
            while ((null != baseType) && !baseType.Methods.Any(x => x.EqualsName("Equals")))
            {
                baseType = baseType.BaseType as XTypeDefinition;
            }
            if (null != baseType)
            {
                equalsMethod = baseType.Methods.First(x => x.EqualsName("Equals"));
            }
        }
Ejemplo n.º 33
0
 /// <summary>
 /// TODO: the list of parameters has gotten way to long.
 /// </summary>
 public AssemblyCompiler(CompilationMode mode, List<AssemblyDefinition> assemblies, 
                         List<AssemblyDefinition> references, Table resources, NameConverter nameConverter, 
                         bool generateDebugInfo, AssemblyClassLoader assemblyClassLoader, 
                         Func<AssemblyDefinition, string> assemblyToFilename, DexMethodBodyCompilerCache ccache,
                         HashSet<string> rootClassNames, XModule module, bool generateSetNextInstructionCode)
 {
     this.mode = mode;
     this.assemblies = assemblies;
     this.references = references;
     this.resources = resources;
     this.generateDebugInfo = generateDebugInfo;
     this.assemblyClassLoader = assemblyClassLoader;
     this.assemblyToFilename = assemblyToFilename;
     this.rootClassNames = rootClassNames;
     this.module = module;
     this.generateSetNextInstructionCode = generateDebugInfo && generateSetNextInstructionCode;
     targetPackage = new Target.Dex.DexTargetPackage(nameConverter, this);
     methodBodyCompilerCache = ccache;
     StopAtFirstError = true;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Implement make minor fixes after the implementation phase.
 /// </summary>
 public void FixUp(Dex target, NameConverter nsConverter)
 {
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Add references to all implemented interfaces.
 /// </summary>
 protected virtual void ImplementInterfaces(Dex target, NameConverter nsConverter)
 {
     // Implement interfaces
     foreach(var intf in typeDef.Interfaces.Select(x => new ClassReference(x.ClassName)))
         classDef.Interfaces.Add(intf);
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Create the current type as class definition.
        /// </summary>
        protected virtual void CreateClassDefinition(Dex target, NameConverter nsConverter, ClassDefinition parent, ClassFile parentClass)
        {
            // Create classdef
            classDef = new ClassDefinition();
            classDef.MapFileId = compiler.GetNextMapFileId();
            classDef.Namespace = nsConverter.GetConvertedNamespace(typeDef);
            var name = NameConverter.GetConvertedName(typeDef);
            classDef.Name = (parent != null) ? parent.Name + "$" + name : name;

            // Set access flags
            //if (typeDef.IsPublic) classDef.IsPublic = true;
            //else classDef.IsPrivate = true;
            classDef.IsPublic = true;
            if (typeDef.IsFinal) classDef.IsFinal = true;
            if (typeDef.IsInterface)
            {
                classDef.IsInterface = true;
                classDef.IsAbstract = true;
            }
            else if (typeDef.IsAbstract)
            {
                classDef.IsAbstract = true;
            }
            if (typeDef.Interfaces.Any(x => x.ClassName == "java/lang/annotation/Annotation"))
            {
                classDef.IsAnnotation = true;
            }

            if (parent != null)
            {
                // Add to parent if this is a nested type
                classDef.Owner = parent;
                parent.InnerClasses.Add(classDef);
            }
            else
            {
                // Add to dex if it is a root class
                target.AddClass(classDef);
            }
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Create the nested classes for this type.
 /// </summary>
 protected virtual void CreateNestedClasses(Dex target, NameConverter nsConverter, ClassDefinition parent)
 {
     nestedBuilders = typeDef.InnerClasses.Where(x => x.InnerClassFile.IsReachable && (x.InnerClassFile.DeclaringClass == typeDef)).Select(x => Create(compiler, x.InnerClassFile)).ToList();
     nestedBuilders.ForEach(x => x.Create(target, nsConverter, classDef, typeDef, xType));
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Implement make minor fixes after the implementation phase.
 /// </summary>
 public void FixUp(Dex target, NameConverter nsConverter)
 {
     FixUpInnerClasses(target, nsConverter);
     FixUpMethods(target, nsConverter);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Set the super class of the class definition.
 /// </summary>
 protected void ImplementSuperClass(Dex target, NameConverter nsConverter)
 {
     // Set base type
     var baseType = typeDef.SuperClass;
     if (baseType != null)
     {
         classDef.SuperClass = new ClassReference(baseType.ClassName);
     }
     else if (typeDef.IsInterface)
     {
         classDef.SuperClass = new ClassReference("java/lang/Object");
     }
     else
     {
         throw new ArgumentException(string.Format("Type {0} has no base type", typeDef.ClassName));
     }
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Add references to all implemented interfaces.
 /// </summary>
 protected virtual void ImplementInterfaces(Dex target, NameConverter nsConverter)
 {
     // Implement interfaces
     classDef.Interfaces.AddRange(typeDef.Interfaces.Select(x => new ClassReference(x.ClassName)));
 }
Ejemplo n.º 41
0
 /// <summary>
 /// FixUp all nested types.
 /// </summary>
 protected virtual void FixUpInnerClasses(Dex target, NameConverter nsConverter)
 {
     // FixUp nested type
     nestedBuilders.ForEach(x => x.FixUp(target, nsConverter));
 }
Ejemplo n.º 42
0
 /// <summary>
 /// FixUp all methods.
 /// </summary>
 protected virtual void FixUpMethods(Dex target, NameConverter nsConverter)
 {
     // FixUp methods
     methodBuilders.ForEach(x => x.FixUp(target, nsConverter));
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Create the current type as class definition.
 /// </summary>
 public void Create(Dex target, NameConverter nsConverter)
 {
     Create(target, nsConverter, null, null, null);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Create the current type as class definition.
 /// </summary>
 protected void Create(Dex target, NameConverter nsConverter, ClassDefinition parent, ClassFile parentClass, XTypeDefinition parentXType)
 {
     xType = new XBuilder.JavaTypeDefinition(compiler.Module, parentXType, typeDef);
     CreateClassDefinition(target, nsConverter, parent, parentClass);
     CreateNestedClasses(target, nsConverter, parent);
 }