Beispiel #1
0
 public void WriteToFile(string path)
 {
     using (var writer = new StreamWriter(path))
     {
         CurrentClass.Write(new IndentedStreamWriter(writer));
     }
 }
Beispiel #2
0
        public Background()
        {
            description = new List <string>();

            theBornClass      = new BornClass();
            theCurrentClass   = new CurrentClass();
            theWorkExperience = new WorkExperience();
        }
        public object VisitIdentifier(Identifier basetype)
        {
            object identifierValue;
            string identifierName = basetype.value;

            if (CurrentClass == null)
            {
                if (CurrentMethod == null)
                {
                    // Global scope
                    identifierValue = Environment.FindIdentifier(identifierName);
                }
                else
                {
                    // Method in global scope
                    identifierValue = CurrentMethod.FindIdentifier(identifierName);
                }
            }
            else
            {
                // In a class
                if (CurrentMethod != null)
                {
                    // In a method within a class
                    // Try to find it within the method
                    identifierValue = CurrentMethod.FindIdentifier(identifierName);

                    if (identifierValue == null)
                    {
                        // It could also be in the class
                        identifierValue = identifierValue = CurrentClass.FindIdentifier(identifierName);
                    }
                }
                else
                {
                    // In a class and not in a method
                    identifierValue = CurrentClass.FindIdentifier(identifierName);
                }
            }

            if (identifierValue is Variable v)
            {
                return(v.Value);
            }
            else if (identifierValue is Method m)
            {
                return(m.MethodName);
            }
            else if (identifierValue is Class c)
            {
                return(c.ClassName);
            }
            else
            {
                new CompilerException("Identifier: " + identifierName + " is an unknown type");
            }
            return(null);
        }
Beispiel #4
0
 public void FinishCurrentConstructor(bool cascade = true)
 {
     if (cascade)
     {
         FinishCurrentLine(isCtorLine: true);
     }
     CurrentClass.AddCtor(currentCtor);
     ClearCurrentConstructor(cascade);
 }
Beispiel #5
0
 public void FinishCurrentFunction(bool cascade = true)
 {
     if (cascade)
     {
         FinishCurrentLine();
     }
     CurrentClass.AddFunction(currentFunction);
     ClearCurrentFunction(cascade);
 }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="String"></param>
        /// <returns></returns>
        private FieldInfo GetStringPointerField(string String)
        {
            if (!StringCache.ContainsKey(String))
            {
                var FieldBuilder = CurrentClass.DefineField("$$__string_literal_" + (UniqueId++), typeof(sbyte *), FieldAttributes.Static | FieldAttributes.Public | FieldAttributes.InitOnly | FieldAttributes.HasDefault);

                this.StaticInitializerSafeILGenerator.Push(String);
                this.StaticInitializerSafeILGenerator.Call((CLibUtils.StringToPointerDelegate)CLibUtils.GetLiteralStringPointer);
                this.StaticInitializerSafeILGenerator.StoreField(FieldBuilder);
                StringCache[String] = FieldBuilder;
            }

            return(StringCache[String]);
        }
        /// <summary>
        /// Interpret an assignment
        /// </summary>
        /// <param name="basetype">The assignment</param>
        /// <returns>The value of the right side of the assignment (making it an expression)</returns>
        public object VisitAssignment(Assignment basetype)
        {
            // The name of the variable to assign to
            string variableName = (string)basetype.identifier.value;
            // The vale to assign t the variable
            object newValue = basetype.expression.Accept(this);

            // If we're not in a class (Global scope)
            if (CurrentClass == null)
            {
                // If we're not in a Method in the global scope
                if (CurrentMethod == null)
                {
                    // Assign the value to a variable in the global scope
                    Environment.FindVariable(variableName).Value = newValue;
                }
                // If we're in a method within the global scope
                else
                {
                    // Assign the value to the variable within the method (or above)
                    CurrentMethod.FindVariable(variableName).Value = newValue;
                }
            }
            // If we're within a class
            else
            {
                // If we're not in a method within a clas
                if (CurrentMethod != null)
                {
                    // Assign the value to a variable within the class (or above)
                    CurrentMethod.FindVariable(variableName).Value = newValue;
                }
                // If we're in a method within a class
                else
                {
                    // Assign the value to the variable within the method within the class (or above)
                    CurrentClass.FindVariable(variableName).Value = newValue;
                }
            }

            // Return the value of the assignment
            return(newValue);
        }
        public override FrameworkElement CreateLogIcon()
        {
            var current_source = IconUtils.GetImageSource(CurrentClass.ToLowerInvariant());
            var old_source     = IconUtils.GetImageSource(OldClass.ToLowerInvariant());
            var arrow_source   = IconUtils.GetImageSource("icon_arrow");

            var color = IconUtils.GetTeamColor(Player.Team);

            var old_image = new Image
            {
                Source              = old_source,
                Stretch             = Stretch.Uniform,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin              = new Thickness(2),
                Width = 26,
            };

            var arrow_image = new Image
            {
                Source              = arrow_source,
                Stretch             = Stretch.Uniform,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin              = new Thickness(2),
                Width = 26,
            };

            var current_image = new Image
            {
                Source              = current_source,
                Stretch             = Stretch.Uniform,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin              = new Thickness(2),
                Width = 26,
            };

            var grid = IconUtils.CreateBaseLogIcon(color);

            grid.Children.Add(current_image);
            grid.Children.Add(arrow_image);
            grid.Children.Add(old_image);

            return(grid);
        }
        public static void UpdateActiveSkills()
        {
            //Core.Logger.Debug($"UpdateActiveSkills: BotMain.BotThread.ThreadState={BotMain.BotThread?.ThreadState} BotMain.BotThread.IsAlive={BotMain.BotThread?.IsAlive} BotMain.IsRunning={BotMain.IsRunning} BotEvents.IsBotRunning={BotEvents.IsBotRunning}");

            //if (!BotEvents.IsBotRunning && ZetaDia.Service.IsInGame)
            //{
            //    Core.Logger.Debug($"UpdateActiveSkills: Before UpdateActors: BotMain.BotThread.ThreadState={BotMain.BotThread?.ThreadState} BotMain.BotThread.IsAlive={BotMain.BotThread?.IsAlive} BotMain.IsRunning={BotMain.IsRunning} BotEvents.IsBotRunning={BotEvents.IsBotRunning}");

            //    ZetaDia.Actors.Update();

            //    Core.Logger.Debug($"UpdateActiveSkills: Before AcquireFrame: BotMain.BotThread.ThreadState={BotMain.BotThread?.ThreadState} BotMain.BotThread.IsAlive={BotMain.BotThread?.IsAlive} BotMain.IsRunning={BotMain.IsRunning} BotEvents.IsBotRunning={BotEvents.IsBotRunning}");

            //    using (ZetaDia.Memory.AcquireFrame())
            //    {
            //        Core.Logger.Debug($"UpdateActiveSkills: Before Hotbar.Update: BotMain.BotThread.ThreadState={BotMain.BotThread?.ThreadState} BotMain.BotThread.IsAlive={BotMain.BotThread?.IsAlive} BotMain.IsRunning={BotMain.IsRunning} BotEvents.IsBotRunning={BotEvents.IsBotRunning}");

            Core.Hotbar.Update();
            //    }
            //}
            _lastUpdatedActiveSkills = DateTime.UtcNow;
            _active    = CurrentClass.Where(s => Core.Hotbar.ActivePowers.Contains(s.SNOPower)).ToList();
            _activeIds = Core.Hotbar.ActivePowers;
        }
Beispiel #10
0
 /// <summary>
 /// Refresh active skills collections with the latest data
 /// </summary>
 private static void UpdateActiveSkills()
 {
     _lastUpdatedActiveSkills = DateTime.UtcNow;
     _active    = CurrentClass.Where(s => CacheData.Hotbar.ActivePowers.Contains(s.SNOPower)).ToList();
     _activeIds = CacheData.Hotbar.ActivePowers;
 }
        public override FrameworkElement CreateMapIcon()
        {
            var current_source = IconUtils.GetImageSource(CurrentClass.ToLowerInvariant());

            return(IconUtils.CreateMapIcon(Player, current_source));
        }