Esempio n. 1
0
        private static bool DefineDebuggerDisplay(AbcGenerator generator, IType type, AbcInstance instance, ICustomAttribute attr)
        {
            if (attr.Arguments.Count != 1)
            {
                return(false);
            }
            var display = attr.Arguments[0].Value as string;

            if (string.IsNullOrEmpty(display))
            {
                return(false);
            }
            if (!display.CheckFormatBraceBalance())
            {
                CompilerReport.Add(Warnings.InvalidDebuggerDisplayString, display);
                return(false);
            }

            var name = generator.Abc.DefineName(QName.Global(DebugPropertyPrefix + "display$exp"));

            //TODO: Parse display string to build string
            var m = instance.DefineMethod(
                Sig.get(name, AvmTypeCode.String),
                code =>
            {
                code.PushString(display);
                code.ReturnValue();
            });

            m.Trait.IsVirtual  = !type.IsSealed;
            m.Trait.IsOverride = instance.FindSuperTrait(name, AbcTraitKind.Getter) != null;

            return(true);
        }
Esempio n. 2
0
        public void CheckApiCompatibility(ITypeMember m)
        {
            if (m == null)
            {
                return;
            }
            if (!IsSwf)
            {
                return;
            }

            int v = m.GetPlayerVersion();

            if (v < 0)
            {
                return;
            }

            if (v > PlayerVersion)
            {
                var method = m as IMethod;
                if (method != null)
                {
                    CompilerReport.Add(Errors.ABC.IncompatibleCall, method.GetFullName(), v);
                    return;
                }

                var f = m as IField;
                if (f != null)
                {
                    CompilerReport.Add(Errors.ABC.IncompatibleField, f.GetFullName(), v);
                    return;
                }
            }
        }
Esempio n. 3
0
        static void Serialize(IAssembly asm, string format)
        {
            try
            {
                string f = FilterCommandLine();
                f += string.Format(" /format:{0}", format);

                FlashLanguageInfrastructure.Serialize(asm, outpath, f);

                if (CompilerReport.HasErrors)
                {
                    CompilerReport.Log();
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                LogException(e, Errors.UnableToTranslateAssembly, asmpath);
                Environment.Exit(-1);
            }
            finally
            {
                DeleteBins(asmpath);
            }
        }
Esempio n. 4
0
        void SetLocales(CommandLine cl)
        {
            string s = cl.GetOption(PFCOptions.Locale);

            if (string.IsNullOrEmpty(s))
            {
                return;
            }

            var locales = s.Split(comma, StringSplitOptions.RemoveEmptyEntries);

            if (locales.Length == 0)
            {
                return;
            }

            var list = new List <string>();

            foreach (string locale in locales)
            {
                if (!locale.IsValidLocale())
                {
                    CompilerReport.Add(Warnings.InvalidLocale, locale);
                    continue;
                }
                list.Add(locale);
            }

            _locales = list.ToArray();
        }
Esempio n. 5
0
        private static void ResolveEmbed(SwfMovie lib, AbcInstance instance, AbcTrait trait)
        {
            if (instance.IsInterface)
            {
                return;
            }

            var superName = instance.BaseTypeName.FullName;

            if (!superName.EndsWith("Asset") || IsAssetClass(instance))
            {
                return;
            }

            string className = instance.FullName;
            var    asset     = lib.FindAsset(className);

            if (asset == null)
            {
                CompilerReport.Add(Warnings.UnableFindSwfAsset, className);
                return;
            }

            Embed.Apply(trait, asset, lib);
        }
Esempio n. 6
0
 internal AbcInstance ImportType(AbcFile abc, string fullname, bool safe)
 {
     try
     {
         return(abc.ImportType(AppAssembly, fullname));
     }
     catch (Exception)
     {
         if (safe)
         {
             CompilerReport.Add(Warnings.UnableImportType, fullname);
             return(null);
         }
         throw;
     }
 }