Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }