public void AddTrait(Trait t) { this.traits.Add(t); }
/// <summary> /// Adds a trait to this method. /// </summary> /// <param name="t">The trait to add.</param> public void AddTrait(Trait t) { this.traits.Add(t); }
private void WriteTraitInfo(ABCDataTypeWriter writer, Trait t) { writer.WriteU30Packed((uint)this.MultinameID(t.Name)); writer.WriteUI8((uint)t.Kind); switch (t.Kind) { case TraitKind.Slot: case TraitKind.Const: SlotTrait st = (SlotTrait)t; writer.WriteU30Packed(st.SlotID); writer.WriteU30Packed((uint)this.MultinameID(st.TypeName)); if (st.Val == null) { writer.WriteU30Packed(0); } else { switch (st.ValKind) { case ConstantKind.ConInt: writer.WriteU30Packed((uint)this.intMarshal.GetIDFor((int)st.Val)); break; case ConstantKind.ConUInt: writer.WriteU30Packed((uint)this.uintMarshal.GetIDFor((uint)st.Val)); break; case ConstantKind.ConDouble: writer.WriteU30Packed((uint)this.doubleMarshal.GetIDFor((ulong)st.Val)); break; case ConstantKind.ConUtf8: writer.WriteU30Packed((uint)this.stringMarshal.GetIDFor((string)st.Val)); break; case ConstantKind.ConTrue: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(11); break; case ConstantKind.ConFalse: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(10); break; case ConstantKind.ConNull: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(12); break; case ConstantKind.ConUndefined: /* Through observation, true, false and null all seem to have ignored but * specific values. I haven't seen one for undefined, but I'm guessing it's * 13. Really want to know what these number are. The don't seem to relate * the string or multiname tables. */ writer.WriteU30Packed(13); break; case ConstantKind.ConNamespace: case ConstantKind.ConPackageNamespace: case ConstantKind.ConPackageInternalNs: case ConstantKind.ConProtectedNamespace: case ConstantKind.ConExplicitNamespace: case ConstantKind.ConStaticProtectedNs: case ConstantKind.ConPrivateNs: writer.WriteU30Packed((uint)this.NamespaceID((Namespace)st.Val)); break; default: throw new SWFModellerException( SWFModellerError.Internal, "Unsupported constant type: " + st.ValKind.ToString()); } writer.WriteUI8((uint)st.ValKind); } break; case TraitKind.Method: case TraitKind.Getter: case TraitKind.Setter: MethodTrait mt = (MethodTrait)t; if (mt.OverriddenMethod != null) { writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(mt.OverriddenMethod)); } else { writer.WriteU30Packed(0); } writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(mt.Fn)); break; case TraitKind.Class: ClassTrait ct = (ClassTrait)t; writer.WriteU30Packed((uint)ct.SlotID); writer.WriteU30Packed((uint)this.classMarshal.GetIDFor(ct.As3class)); break; case TraitKind.Function: FunctionTrait ft = (FunctionTrait)t; writer.WriteU30Packed((uint)ft.SlotID); writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(ft.Fn)); break; default: /* ISSUE 73 */ throw new SWFModellerException( SWFModellerError.UnimplementedFeature, "Unsupported trait kind: " + t.Kind.ToString()); } }
/// <summary> /// This is just for processing whilst rebuilding tables, it doesn't /// serialize anything. /// </summary> /// <param name="t">The trait to process.</param> private void ProcessTrait(Trait t) { switch (t.Kind) { case TraitKind.Method: Method m = ((MethodTrait)t).Fn; this.AssembleMethod(m); break; case TraitKind.Slot: this.ProcessSlot((SlotTrait)t); break; case TraitKind.Class: /* Skip this. It will already have been picked up in the class * list in ReBuildTables */ break; case TraitKind.Getter: case TraitKind.Setter: case TraitKind.Function: case TraitKind.Const: default: /* ISSUE 73 */ throw new SWFModellerException( SWFModellerError.UnimplementedFeature, "Unsupported assembly of trait kind " + t.Kind.ToString()); } }
/// <summary> /// Adds a new static trait /// </summary> /// <param name="trait">The trait to add</param> public void AddClassTrait(Trait trait) { this.classTraits.Add(trait); }
/// <summary> /// Adds a new instance trait /// </summary> /// <param name="trait">The trait to add</param> public void AddInstanceTrait(Trait trait) { this.instanceTraits.Add(trait); }