/// <summary> /// Imports given constant. /// </summary> /// <param name="c">constant to import.</param> /// <returns>imported constant.</returns> public AbcConst <T> Import(AbcConst <T> c) { if (IsDefined(c)) { return(c); } return(Define(c.Value)); }
public AbcNamespace this[AbcConst <string> name, AbcConstKind kind] { get { string key = name.MakeKey(kind); return(this[key]); } }
internal AbcInstance ImportInstance(AbcConst <string> name) { if (name == null || string.IsNullOrEmpty(name.Value)) { return(null); } return(ImportInstance(name.Value)); }
public AbcNamespace(AbcConst <string> name, AbcConstKind kind, string key) { if (!kind.IsNamespace()) { throw new ArgumentException("Invalid namespace kind"); } Name = name; _kind = kind; _key = key; }
private AbcConst <string> DefineStringOrNull(string value) { AbcConst <string> c = null; if (!string.IsNullOrEmpty(value)) { c = DefineString(value); } return(c); }
/// <summary> /// Defines namespace with given name. /// </summary> /// <param name="kind">kind of namespace to define.</param> /// <param name="name">name of namespace to define.</param> /// <returns></returns> public AbcNamespace DefineNamespace(AbcConstKind kind, AbcConst <string> name) { string key = name.MakeKey(kind); var ns = Namespaces[key]; if (ns != null) { return(ns); } ns = new AbcNamespace(name, kind, key); Namespaces.Add(ns); return(ns); }
/// <summary> /// Imports given constant. /// </summary> /// <typeparam name="T">type of constant. Can be int,uint,double,string</typeparam> /// <param name="c">constant to import.</param> /// <returns>imported constant.</returns> public AbcConst <T> ImportConst <T>(AbcConst <T> c) { if (c == null) { return(null); } var pool = GetConstPool(c.Kind); if (pool != null) { return(((AbcConstPool <T>)pool).Import(c)); } return(c); }
public AbcConst <T> Add(T value) { int index = _list.Count; var c = new AbcConst <T>(value) { Index = index }; if (index != 0) { _index.Add(value, index); } _list.Add(c); return(c); }
public AbcMultiname DefineMultiname(AbcConstKind kind, AbcNamespaceSet nss, AbcConst <string> name) { string key = AbcMultiname.KeyOf(kind, nss, name); var mn = Multinames[key]; if (mn != null) { return(mn); } mn = new AbcMultiname(kind, nss, name) { Key = key }; Multinames.Add(mn); return(mn); }
private AbcConst <string> ImportType(AbcConst <string> name, out AbcInstance type) { type = null; if (name == null) { return(null); } if (IsImportTypeExternally) { return(ImportConst(name)); } type = ImportInstance(name); return(ImportConst(name)); }
public void Read(SwfReader reader) { int paramCount = (int)reader.ReadUIntEncoded(); ReturnType = reader.ReadMultiname(); //ret_type //U30 param_types[param_count] for (int i = 0; i < paramCount; ++i) { var type = reader.ReadMultiname(); _params.Add(new AbcParameter { Type = type }); } _name = reader.ReadAbcString(); //name_index Flags = (AbcMethodFlags)reader.ReadUInt8(); if ((Flags & AbcMethodFlags.HasOptional) != 0) { int optionalCount = (int)reader.ReadUIntEncoded(); int firstOptionalParam = paramCount - optionalCount; for (int i = 0; i < optionalCount; ++i) { int valueIndex = (int)reader.ReadUIntEncoded(); var valueKind = (AbcConstKind)reader.ReadUInt8(); var p = _params[firstOptionalParam + i]; p.Value = reader.ABC.GetConstant(valueKind, valueIndex); p.IsOptional = true; } } if ((Flags & AbcMethodFlags.HasParamNames) != 0) { for (int i = 0; i < paramCount; ++i) { _params[i].Name = reader.ReadAbcString(); } } }
private AbcMultiname ImportQName(AbcNamespace ns, AbcConst <string> name, bool isAttribute) { var kind = isAttribute ? AbcConstKind.QNameA : AbcConstKind.QName; string key = AbcMultiname.KeyOf(kind, ns, name); var mn = this[key]; if (mn != null) { return(mn); } name = _abc.ImportConst(name); ns = _abc.ImportConst(ns); mn = new AbcMultiname(kind, ns, name) { Key = key }; Add(mn); return(mn); }
public static string KeyOf(AbcConstKind kind, AbcNamespaceSet nss, AbcConst <string> name) { return("{" + nss.Key + "}." + name.Value + (int)kind); }
public static string KeyOf(AbcConstKind kind, AbcNamespace ns, AbcConst <string> name) { return(ns.Key + "." + name.Value + (int)kind); }
/// <summary> /// Defines protected namespace with given name. /// </summary> /// <param name="name">name of namespace to define.</param> /// <returns></returns> public AbcNamespace DefineProtectedNamespace(AbcConst <string> name) { return(DefineNamespace(AbcConstKind.ProtectedNamespace, name)); }
public void Add(AbcConst <string> key, AbcConst <string> value) { _keys.Add(key); _values.Add(value); }
public AbcParameter(AbcMultiname type, AbcConst <string> name) { Type = type; Name = name; }
public AbcNamespace(AbcConst <string> name, AbcConstKind kind) : this(name, kind, name.MakeKey(kind)) { }
/// <summary> /// Defines internal namespace with given name. /// </summary> /// <param name="name">name of namespace to define.</param> /// <returns></returns> public AbcNamespace DefineInternalNamespace(AbcConst <string> name) { return(DefineNamespace(AbcConstKind.InternalNamespace, name)); }
/// <summary> /// Defines package namespace with given name. /// </summary> /// <param name="name">name of namespace to define.</param> /// <returns></returns> public AbcNamespace DefinePackage(AbcConst <string> name) { return(DefineNamespace(AbcConstKind.PackageNamespace, name)); }
public AbcMultiname(AbcConstKind kind, AbcNamespaceSet nss, AbcConst <string> name) { Kind = kind; NamespaceSet = nss; Name = name; }
public AbcMultiname(AbcConstKind kind, AbcConst <string> name) { Kind = kind; Name = name; }
public void AddParam(AbcMultiname type, AbcConst <string> name) { Parameters.Add(new AbcParameter(type, name)); }