XElement IActionVisitor <XElement, XElement> .Visit(ActionTry action, XElement param) { var res = new XElement(XActionNames.FromAction(action)); if (action.Reserved != 0) { res.Add(new XAttribute("reserved", action.Reserved)); } if (action.CatchInRegister) { res.Add(new XAttribute("catchReg", action.CatchRegister)); } else { res.Add(new XAttribute("catchName", action.CatchName)); } res.Add(XAction.ToXml(action.Try, new XElement("try"))); if (action.CatchBlock) { res.Add(XAction.ToXml(action.Catch, new XElement("catch"))); } if (action.FinallyBlock) { res.Add(XAction.ToXml(action.Finally, new XElement("finally"))); } return(res); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionDefineFunction action, XElement param) { var res = new XElement(XActionNames.FromAction(action)); res.Add(new XAttribute("name", action.Name), new XAttribute("argc", action.Args.Count) ); var args = new XElement("args"); foreach (var arg in action.Args) { args.Add(new XElement("String", new XAttribute("value", arg))); } res.Add(args); if (action.Actions.Count > 0) { var xActions = new XElement("actions"); foreach (var subaction in action.Actions) { xActions.Add(XAction.ToXml(subaction)); } res.Add(xActions); } return(res); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionConstantPool action, XElement param) { var res = new XElement(XActionNames.FromAction(action)); var strings = new XElement("strings"); foreach (var item in action.ConstantPool) { strings.Add(new XElement("String", new XAttribute("value", item))); } res.Add(strings); return(res); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionGotoFrame2 action, XElement param) { var res = new XElement(XActionNames.FromAction(action), new XAttribute("play", CommonFormatter.Format(action.Play))); if (action.SceneBias.HasValue) { res.Add(new XAttribute("bias", action.SceneBias.Value)); } if (action.Reserved != 0) { res.Add(new XAttribute("reserved", action.Reserved)); } return(res); }
public XElement Visit(ActionEnd action, XElement arg) { return(new XElement(XActionNames.FromAction(action))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionImplementsOp action, XElement param) { return(new XElement(XActionNames.FromAction(action))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionStoreRegister action, XElement arg) { return(new XElement(XActionNames.FromAction(action), new XAttribute("reg", action.RegisterNumber))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionGetProperty action, XElement param) { return(new XElement(XActionNames.FromAction(action))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionGetURL2 action, XElement param) { return(new XElement(XActionNames.FromAction(action), new XAttribute("flags", action.Flags))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionSetVariable action, XElement param) { return(new XElement(XActionNames.FromAction(action))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionJump action, XElement param) { return(new XElement(XActionNames.FromAction(action), new XAttribute("byteOffset", FormatBranchOffset(action.BranchOffset)))); }
XElement IActionVisitor <XElement, XElement> .Visit(ActionGotoFrame action, XElement param) { return(new XElement(XActionNames.FromAction(action), new XAttribute("frame", action.Frame))); }
/// <summary> /// Serializes action to xml node. /// </summary> /// <param name="action">Action to serialize.</param> /// <returns>Xml node representing action.</returns> public XElement Serialize(ActionBase action) { var xAction = new XElement(XActionNames.FromAction(action)); return(action.AcceptVisitor(this, xAction)); }