JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / com / stevesoft / pat / OrMark.js
1 Clazz.declarePackage ("com.stevesoft.pat");\r
2 Clazz.load (["com.stevesoft.pat.Or", "$.SubMark"], "com.stevesoft.pat.OrMark", null, function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.sm = null;\r
5 this.id = 0;\r
6 Clazz.instantialize (this, arguments);\r
7 }, com.stevesoft.pat, "OrMark", com.stevesoft.pat.Or);\r
8 Clazz.prepareFields (c$, function () {\r
9 this.sm =  new com.stevesoft.pat.SubMark ();\r
10 });\r
11 Clazz.makeConstructor (c$, \r
12 function (i) {\r
13 Clazz.superConstructor (this, com.stevesoft.pat.OrMark, []);\r
14 this.sm.om = this;\r
15 this.id = i;\r
16 }, "~N");\r
17 Clazz.overrideMethod (c$, "leftForm", \r
18 function () {\r
19 return "(";\r
20 });\r
21 Clazz.defineMethod (c$, "getNext", \r
22 function () {\r
23 return this.sm;\r
24 });\r
25 Clazz.defineMethod (c$, "matchInternal", \r
26 function (pos, pt) {\r
27 this.sm.next = Clazz.superCall (this, com.stevesoft.pat.OrMark, "getNext", []);\r
28 if (pt.marks == null) {\r
29 var n2 = 2 * pt.nMarks + 2;\r
30 pt.marks =  Clazz.newIntArray (n2, 0);\r
31 for (var i = 0; i < n2; i++) {\r
32 pt.marks[i] = -1;\r
33 }\r
34 }pt.marks[this.id] = pos;\r
35 var ret = Clazz.superCall (this, com.stevesoft.pat.OrMark, "matchInternal", [pos, pt]);\r
36 if (ret < 0) {\r
37 pt.marks[this.id] = -1;\r
38 } else if (pt.marks[this.id] > pt.marks[this.id + pt.nMarks]) {\r
39 var swap = pt.marks[this.id];\r
40 pt.marks[this.id] = pt.marks[this.id + pt.nMarks] + 1;\r
41 pt.marks[this.id + pt.nMarks] = swap + 1;\r
42 }return ret;\r
43 }, "~N,com.stevesoft.pat.Pthings");\r
44 Clazz.overrideMethod (c$, "clone1", \r
45 function (h) {\r
46 var om =  new com.stevesoft.pat.OrMark (this.id);\r
47 h.put (om, om);\r
48 h.put (this, om);\r
49 for (var i = 0; i < this.v.size (); i++) {\r
50 om.v.addElement ((this.v.elementAt (i)).clone (h));\r
51 }\r
52 return om;\r
53 }, "java.util.Hashtable");\r
54 });\r