From: handa Date: Thu, 5 Nov 2009 07:50:29 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23b585b36105b04ff5019a2b6115750d204627f6;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/XmlExpr.cs b/XmlExpr.cs index 2db0b43..0168e3f 100644 --- a/XmlExpr.cs +++ b/XmlExpr.cs @@ -46,7 +46,7 @@ namespace System.Xml public static Symbol UncaughtThrow = "uncaught-throw"; private readonly Symbol name; - private Term term = Zero; + private Term[] stack; private XmlNode node; public Error (Symbol name, XmlNode node, string fmt, params object[] args) @@ -62,9 +62,15 @@ namespace System.Xml this.name = name; } - public Symbol ErrorName { get { return name; } } - public XmlNode ErrorNode { get { return node; } set { node = value; } } - public Term ErrorTerm { get { return term; } set { term = value; } } + public Symbol Name { get { return name; } } + public XmlNode Node { + get { return node; } + internal set { node = value; } + } + public Term[] Stack { + get { return stack; } + internal set { stack = value; } + } } public struct Symbol : IEquatable @@ -469,36 +475,42 @@ namespace System.Xml Term result = Zero; int limit = max_args >= 0 ? args.Length : args.Length - 1; - for (int i = 0; i < limit; i++) - { - result = args[i].Eval (domain); - if (domain.Thrown) - return result; - domain.Bind (this.args[i], result); - } - if (max_args < 0) - { - List list = new List (); - list.InsertRange (0, args[result].Listval); - - for (int i = 0; i < list.Count; i++) + try { + for (int i = 0; i < limit; i++) + { + result = args[i].Eval (domain); + if (domain.Thrown) + return result; + domain.Bind (this.args[i], result); + } + if (max_args < 0) + { + List list = new List (); + list.InsertRange (0, args[result].Listval); + + for (int i = 0; i < list.Count; i++) + { + result = list[i].Eval (domain); + if (domain.Thrown) + return result; + list[i] = result; + } + domain.Bind (this.args[limit], new Term (list)); + } + try { + domain.Catch (CatchTag.Return); + foreach (Term term in body) { - result = list[i].Eval (domain); - if (domain.Thrown) + result = term.Eval (domain); + if (domain.Thrown ()) return result; - list[i] = result; } - domain.Bind (this.args[limit], new Term (list)); - } - domain.Catch (CatchTag.Return); - foreach (Term term in body) - { - result = term.Eval (domain); - if (domain.Thrown ()) - return result; + } finally { + domain.Uncatch (); } - domain.Uncatch (); - domain.UnboundTo (current); + } finally { + domain.UnboundTo (current); + } return result; } } @@ -526,17 +538,23 @@ namespace System.Xml Bindings current = domain.bindings; Term result = Zero; - for (int i = 0; i < args.Length; i++) - domain.Bind (this.args[i], args[i]); - domain.Catch (CatchTag.Return); - foreach (Term term in body) - { - result = term.Eval (domain); - if (domain.Thrown ()) - break; + try { + for (int i = 0; i < args.Length; i++) + domain.Bind (this.args[i], args[i]); + try { + domain.Catch (CatchTag.Return); + foreach (Term term in body) + { + result = term.Eval (domain); + if (domain.Thrown ()) + break; + } + } finally { + domain.Uncatch (); } - domain.Uncatch (); - domain.UnboundTo (current); + } finally { + domain.UnboundTo (current); + } return result; } } @@ -1091,8 +1109,7 @@ namespace System.Xml private static Term Fset (Domain domain, Variable vari, Term[] args) { if (vari == null) - return new Term (new ErrorTerm (Error.NoVariableName, - "No variable name to set")); + throw new Error (Error.NoVariableName, "No variable name to set")); vari.SetValue (args[0]); return args[0]; } @@ -1823,7 +1840,10 @@ namespace System.Xml return new ErrorTerm (ename, message); } - public Term[] CallStack { get { return stack; } set { stack = value; } } + public Term[] CallStack { + get { return stack; } + internal set { stack = value; } + } public override TermValue Clone () { @@ -1833,15 +1853,9 @@ namespace System.Xml public override bool Equals (object obj) { ErrorTerm e = obj as ErrorTerm; - if (e == null || e.ename != ename || e.message != message - || (e.stack == null ? stack != null - : (stack == null || e.stack.Length != stack.Length))) - return false; - if (stack != null) - for (int i = 0; i < stack.Length; i++) - if (! stack[i].Equals (e.stack[i])) - return false; - return true; + return (e != null && e.ename = ename && e.message != message + && (e.stack == null ? stack == null + : (stack != null && e.stack.Length == stack.Length))) } public override int GetHashCode ()