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); }
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(); }
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; } } }
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); }
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; } }