Exemplo n.º 1
0
        // used to start when just filtering.. uses a fixed event list .. must provide a call back to obtain names associated with an event

        public void InitFilter(string t, Icon ic, List <string> events, AdditionalNames a, List <string> varfields, ConditionLists j = null)
        {
            onAdditionalNames = a;
            this.eventlist    = events;
            events.Add("All");
            Init(t, ic, events, varfields, true);
            LoadConditions(j);
        }
Exemplo n.º 2
0
        public override void WriteText(Assembler aAssembler, TextWriter aOutput)
        {
            if (RawAsm != null)
            {
                aOutput.WriteLine(RawAsm);
                return;
            }

            if (RawDefaultValue != null)
            {
                if (RawDefaultValue.Length == 0)
                {
                    aOutput.Write(Name);
                    aOutput.Write(":");
                    return;
                }
                if (RawDefaultValue.Length < 250 ||
                    (from item in RawDefaultValue
                     group item by item
                     into i
                     select i).Count() > 1)
                {
                    if (IsGlobal)
                    {
                        aOutput.Write("\tglobal ");
                        aOutput.WriteLine(Name);

                        if (AdditionalNames != null && AdditionalNames.Count() > 0)
                        {
                            foreach (var xName in AdditionalNames)
                            {
                                aOutput.Write("\tglobal");
                                aOutput.WriteLine(xName);
                            }
                        }
                    }

                    aOutput.WriteLine(Name + ":");

                    if (AdditionalNames != null && AdditionalNames.Count() > 0)
                    {
                        foreach (var xName in AdditionalNames)
                        {
                            aOutput.WriteLine("\t" + xName + ":");
                        }
                    }

                    aOutput.Write("\t  db ");
                    for (int i = 0; i < (RawDefaultValue.Length - 1); i++)
                    {
                        aOutput.Write(RawDefaultValue[i]);
                        aOutput.Write(", ");
                    }
                    aOutput.Write(RawDefaultValue.Last());
                }
                else
                {
                    if (IsGlobal)
                    {
                        aOutput.Write("global ");
                        aOutput.WriteLine(Name);

                        if (AdditionalNames != null && AdditionalNames.Count() > 0)
                        {
                            foreach (var xName in AdditionalNames)
                            {
                                aOutput.Write("\tglobal");
                                aOutput.WriteLine(xName);
                            }
                        }
                    }

                    if (AdditionalNames != null && AdditionalNames.Count() > 0)
                    {
                        aOutput.WriteLine(Name + ":");
                        foreach (var xName in AdditionalNames)
                        {
                            aOutput.WriteLine("\t" + xName + ":");
                        }
                    }
                    else
                    {
                        aOutput.Write(Name + ":");
                    }

                    aOutput.Write("\t  TIMES ");
                    aOutput.Write(RawDefaultValue.Length);
                    aOutput.Write(" db ");
                    aOutput.Write(RawDefaultValue[0]);
                }
                return;
            }
            if (UntypedDefaultValue != null)
            {
                if (IsGlobal)
                {
                    aOutput.Write("global ");
                    aOutput.WriteLine(Name);
                }
                aOutput.Write(Name);

                aOutput.Write(" " + GetStringFromType(UntypedDefaultValue[0].GetType()) + " ");

                Func <object, string> xGetTextForItem = delegate(object aItem)
                {
                    if (!(aItem is ElementReference xElementRef))
                    {
                        return((aItem ?? 0).ToString());
                    }

                    if (xElementRef.Offset == 0)
                    {
                        return(xElementRef.Name);
                    }
                    return(xElementRef.Name + " + " + xElementRef.Offset);
                };
                for (int i = 0; i < (UntypedDefaultValue.Length - 1); i++)
                {
                    aOutput.Write(xGetTextForItem(UntypedDefaultValue[i]));
                    aOutput.Write(", ");
                }
                aOutput.Write(xGetTextForItem(UntypedDefaultValue.Last()));
                return;
            }

            if (StringValue != null)
            {
                if (Type != null)
                {
                    aOutput.Write(Name);
                    aOutput.Write(" ");
                    aOutput.Write(GetStringFromType(Type));
                    aOutput.Write(" ");
                    aOutput.Write(StringValue);
                }
                else if (Size != null)
                {
                    aOutput.Write(Name);
                    aOutput.Write(" ");
                    aOutput.Write(Size);
                    aOutput.Write(" ");
                    aOutput.Write(StringValue);
                }
                else
                {
                    aOutput.Write(Name);
                    aOutput.Write(" ");
                    aOutput.Write(StringValue);
                }
                return;
            }

            throw new Exception("Situation unsupported!");
        }