1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements.  See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22package com.sun.org.apache.xpath.internal.compiler;
23
24/**
25 * Operations codes for XPath.
26 *
27 * Code for the descriptions of the operations codes:
28 * [UPPER CASE] indicates a literal value,
29 * [lower case] is a description of a value,
30 *      ([length] always indicates the length of the operation,
31 *       including the operations code and the length integer.)
32 * {UPPER CASE} indicates the given production,
33 * {description} is the description of a new production,
34 *      (For instance, {boolean expression} means some expression
35 *       that should be resolved to a boolean.)
36 *  * means that it occurs zero or more times,
37 *  + means that it occurs one or more times,
38 *  ? means that it is optional.
39 *
40 * returns: indicates what the production should return.
41 */
42public class OpCodes
43{
44
45  /**
46   * [ENDOP]
47   * Some operators may like to have a terminator.
48   * @xsl.usage advanced
49   */
50  public static final int ENDOP = -1;
51
52  /**
53   * [EMPTY]
54   * Empty slot to indicate NULL.
55   */
56  public static final int EMPTY = -2;
57
58  /**
59   * [ELEMWILDCARD]
60   * Means ELEMWILDCARD ("*"), used instead
61   * of string index in some places.
62   * @xsl.usage advanced
63   */
64  public static final int ELEMWILDCARD = -3;
65
66  /**
67   * [OP_XPATH]
68   * [length]
69   *  {expression}
70   *
71   * returns:
72   *  XNodeSet
73   *  XNumber
74   *  XString
75   *  XBoolean
76   *  XRTree
77   *  XObject
78   * @xsl.usage advanced
79   */
80  public static final int OP_XPATH = 1;
81
82  /**
83   * [OP_OR]
84   * [length]
85   *  {boolean expression}
86   *  {boolean expression}
87   *
88   * returns:
89   *  XBoolean
90   * @xsl.usage advanced
91   */
92  public static final int OP_OR = 2;
93
94  /**
95   * [OP_AND]
96   * [length]
97   *  {boolean expression}
98   *  {boolean expression}
99   *
100   * returns:
101   *  XBoolean
102   * @xsl.usage advanced
103   */
104  public static final int OP_AND = 3;
105
106  /**
107   * [OP_NOTEQUALS]
108   * [length]
109   *  {expression}
110   *  {expression}
111   *
112   * returns:
113   *  XBoolean
114   * @xsl.usage advanced
115   */
116  public static final int OP_NOTEQUALS = 4;
117
118  /**
119   * [OP_EQUALS]
120   * [length]
121   *  {expression}
122   *  {expression}
123   *
124   * returns:
125   *  XBoolean
126   * @xsl.usage advanced
127   */
128  public static final int OP_EQUALS = 5;
129
130  /**
131   * [OP_LTE] (less-than-or-equals)
132   * [length]
133   *  {number expression}
134   *  {number expression}
135   *
136   * returns:
137   *  XBoolean
138   * @xsl.usage advanced
139   */
140  public static final int OP_LTE = 6;
141
142  /**
143   * [OP_LT] (less-than)
144   * [length]
145   *  {number expression}
146   *  {number expression}
147   *
148   * returns:
149   *  XBoolean
150   * @xsl.usage advanced
151   */
152  public static final int OP_LT = 7;
153
154  /**
155   * [OP_GTE] (greater-than-or-equals)
156   * [length]
157   *  {number expression}
158   *  {number expression}
159   *
160   * returns:
161   *  XBoolean
162   * @xsl.usage advanced
163   */
164  public static final int OP_GTE = 8;
165
166  /**
167   * [OP_GT] (greater-than)
168   * [length]
169   *  {number expression}
170   *  {number expression}
171   *
172   * returns:
173   *  XBoolean
174   * @xsl.usage advanced
175   */
176  public static final int OP_GT = 9;
177
178  /**
179   * [OP_PLUS]
180   * [length]
181   *  {number expression}
182   *  {number expression}
183   *
184   * returns:
185   *  XNumber
186   * @xsl.usage advanced
187   */
188  public static final int OP_PLUS = 10;
189
190  /**
191   * [OP_MINUS]
192   * [length]
193   *  {number expression}
194   *  {number expression}
195   *
196   * returns:
197   *  XNumber
198   * @xsl.usage advanced
199   */
200  public static final int OP_MINUS = 11;
201
202  /**
203   * [OP_MULT]
204   * [length]
205   *  {number expression}
206   *  {number expression}
207   *
208   * returns:
209   *  XNumber
210   * @xsl.usage advanced
211   */
212  public static final int OP_MULT = 12;
213
214  /**
215   * [OP_DIV]
216   * [length]
217   *  {number expression}
218   *  {number expression}
219   *
220   * returns:
221   *  XNumber
222   * @xsl.usage advanced
223   */
224  public static final int OP_DIV = 13;
225
226  /**
227   * [OP_MOD]
228   * [length]
229   *  {number expression}
230   *  {number expression}
231   *
232   * returns:
233   *  XNumber
234   * @xsl.usage advanced
235   */
236  public static final int OP_MOD = 14;
237
238  /**
239   * [OP_QUO]
240   * [length]
241   *  {number expression}
242   *  {number expression}
243   *
244   * returns:
245   *  XNumber
246   * @xsl.usage advanced
247   */
248  public static final int OP_QUO = 15;
249
250  /**
251   * [OP_NEG]
252   * [length]
253   *  {number expression}
254   *
255   * returns:
256   *  XNumber
257   * @xsl.usage advanced
258   */
259  public static final int OP_NEG = 16;
260
261  /**
262   * [OP_STRING] (cast operation)
263   * [length]
264   *  {expression}
265   *
266   * returns:
267   *  XString
268   * @xsl.usage advanced
269   */
270  public static final int OP_STRING = 17;
271
272  /**
273   * [OP_BOOL] (cast operation)
274   * [length]
275   *  {expression}
276   *
277   * returns:
278   *  XBoolean
279   * @xsl.usage advanced
280   */
281  public static final int OP_BOOL = 18;
282
283  /**
284   * [OP_NUMBER] (cast operation)
285   * [length]
286   *  {expression}
287   *
288   * returns:
289   *  XBoolean
290   * @xsl.usage advanced
291   */
292  public static final int OP_NUMBER = 19;
293
294  /**
295   * [OP_UNION]
296   * [length]
297   *  {PathExpr}+
298   *
299   * returns:
300   *  XNodeSet
301   * @xsl.usage advanced
302   */
303  public static final int OP_UNION = 20;
304
305  /**
306   * [OP_LITERAL]
307   * [3]
308   * [index to token]
309   *
310   * returns:
311   *  XString
312   * @xsl.usage advanced
313   */
314  public static final int OP_LITERAL = 21;
315
316  /** The low opcode for nodesets, needed by getFirstPredicateOpPos and
317   *  getNextStepPos.          */
318  static final int FIRST_NODESET_OP = 22;
319
320  /**
321   * [OP_VARIABLE]
322   * [4]
323   * [index to namespace token, or EMPTY]
324   * [index to function name token]
325   *
326   * returns:
327   *  XString
328   * @xsl.usage advanced
329   */
330  public static final int OP_VARIABLE = 22;
331
332  /**
333   * [OP_GROUP]
334   * [length]
335   *  {expression}
336   *
337   * returns:
338   *  XNodeSet
339   *  XNumber
340   *  XString
341   *  XBoolean
342   *  XRTree
343   *  XObject
344   * @xsl.usage advanced
345   */
346  public static final int OP_GROUP = 23;
347
348  /**
349   * [OP_EXTFUNCTION] (Extension function.)
350   * [length]
351   * [index to namespace token]
352   * [index to function name token]
353   *  {OP_ARGUMENT}
354   *
355   * returns:
356   *  XNodeSet
357   *  XNumber
358   *  XString
359   *  XBoolean
360   *  XRTree
361   *  XObject
362   * @xsl.usage advanced
363   */
364  public static final int OP_EXTFUNCTION = 24;
365
366  /**
367   * [OP_FUNCTION]
368   * [length]
369   * [FUNC_name]
370   *  {OP_ARGUMENT}
371   * [ENDOP]
372   *
373   * returns:
374   *  XNodeSet
375   *  XNumber
376   *  XString
377   *  XBoolean
378   *  XRTree
379   *  XObject
380   * @xsl.usage advanced
381   */
382  public static final int OP_FUNCTION = 25;
383
384  /** The last opcode for stuff that can be a nodeset.         */
385  static final int LAST_NODESET_OP = 25;
386
387  /**
388   * [OP_ARGUMENT] (Function argument.)
389   * [length]
390   *  {expression}
391   *
392   * returns:
393   *  XNodeSet
394   *  XNumber
395   *  XString
396   *  XBoolean
397   *  XRTree
398   *  XObject
399   * @xsl.usage advanced
400   */
401  public static final int OP_ARGUMENT = 26;
402
403  /**
404   * [OP_NUMBERLIT] (Number literal.)
405   * [3]
406   * [index to token]
407   *
408   * returns:
409   *  XString
410   * @xsl.usage advanced
411   */
412  public static final int OP_NUMBERLIT = 27;
413
414  /**
415   * [OP_LOCATIONPATH]
416   * [length]
417   *   {FROM_stepType}
418   * | {function}
419   * {predicate}
420   * [ENDOP]
421   *
422   * (Note that element and attribute namespaces and
423   * names can be wildcarded '*'.)
424   *
425   * returns:
426   *  XNodeSet
427   * @xsl.usage advanced
428   */
429  public static final int OP_LOCATIONPATH = 28;
430
431  // public static final int LOCATIONPATHEX_MASK = 0x0000FFFF;
432  // public static final int LOCATIONPATHEX_ISSIMPLE = 0x00010000;
433  // public static final int OP_LOCATIONPATH_EX = (28 | 0x00010000);
434
435  /**
436   * [OP_PREDICATE]
437   * [length]
438   *  {expression}
439   * [ENDOP] (For safety)
440   *
441   * returns:
442   *  XBoolean or XNumber
443   * @xsl.usage advanced
444   */
445  public static final int OP_PREDICATE = 29;
446
447  /**
448   * [OP_MATCHPATTERN]
449   * [length]
450   *  {PathExpr}+
451   *
452   * returns:
453   *  XNodeSet
454   * @xsl.usage advanced
455   */
456  public static final int OP_MATCHPATTERN = 30;
457
458  /**
459   * [OP_LOCATIONPATHPATTERN]
460   * [length]
461   *   {FROM_stepType}
462   * | {function}{predicate}
463   * [ENDOP]
464   * returns:
465   *  XNodeSet
466   * @xsl.usage advanced
467   */
468  public static final int OP_LOCATIONPATHPATTERN = 31;
469
470  /**
471   * [NODETYPE_COMMENT]
472   * No size or arguments.
473   * Note: must not overlap function OP number!
474   *
475   * returns:
476   *  XBoolean
477   * @xsl.usage advanced
478   */
479  public static final int NODETYPE_COMMENT = 1030;
480
481  /**
482   * [NODETYPE_TEXT]
483   * No size or arguments.
484   * Note: must not overlap function OP number!
485   *
486   * returns:
487   *  XBoolean
488   * @xsl.usage advanced
489   */
490  public static final int NODETYPE_TEXT = 1031;
491
492  /**
493   * [NODETYPE_PI]
494   * [index to token]
495   * Note: must not overlap function OP number!
496   *
497   * returns:
498   *  XBoolean
499   * @xsl.usage advanced
500   */
501  public static final int NODETYPE_PI = 1032;
502
503  /**
504   * [NODETYPE_NODE]
505   * No size or arguments.
506   * Note: must not overlap function OP number!
507   *
508   * returns:
509   *  XBoolean
510   * @xsl.usage advanced
511   */
512  public static final int NODETYPE_NODE = 1033;
513
514  /**
515   * [NODENAME]
516   * [index to ns token or EMPTY]
517   * [index to name token]
518   *
519   * returns:
520   *  XBoolean
521   * @xsl.usage advanced
522   */
523  public static final int NODENAME = 34;
524
525  /**
526   * [NODETYPE_ROOT]
527   * No size or arguments.
528   *
529   * returns:
530   *  XBoolean
531   * @xsl.usage advanced
532   */
533  public static final int NODETYPE_ROOT = 35;
534
535  /**
536   * [NODETYPE_ANY]
537   * No size or arguments.
538   *
539   * returns:
540   *  XBoolean
541   * @xsl.usage advanced
542   */
543  public static final int NODETYPE_ANYELEMENT = 36;
544
545  /**
546   * [NODETYPE_ANY]
547   * No size or arguments.
548   *
549   * returns:
550   *  XBoolean
551   * @xsl.usage advanced
552   */
553  public static final int NODETYPE_FUNCTEST = 1034;
554
555  /**
556   * [FROM_stepType]
557   * [length, including predicates]
558   * [length of just the step, without the predicates]
559   * {node test}
560   * {predicates}?
561   *
562   * returns:
563   *  XBoolean
564   * @xsl.usage advanced
565   */
566  public static final int AXES_START_TYPES = 37;
567
568  /** ancestor axes opcode.         */
569  public static final int FROM_ANCESTORS = 37;
570
571  /** ancestor-or-self axes opcode.         */
572  public static final int FROM_ANCESTORS_OR_SELF = 38;
573
574  /** attribute axes opcode.         */
575  public static final int FROM_ATTRIBUTES = 39;
576
577  /** children axes opcode.         */
578  public static final int FROM_CHILDREN = 40;
579
580  /** descendants axes opcode.         */
581  public static final int FROM_DESCENDANTS = 41;
582
583  /** descendants-of-self axes opcode.         */
584  public static final int FROM_DESCENDANTS_OR_SELF = 42;
585
586  /** following axes opcode.         */
587  public static final int FROM_FOLLOWING = 43;
588
589  /** following-siblings axes opcode.         */
590  public static final int FROM_FOLLOWING_SIBLINGS = 44;
591
592  /** parent axes opcode.         */
593  public static final int FROM_PARENT = 45;
594
595  /** preceding axes opcode.         */
596  public static final int FROM_PRECEDING = 46;
597
598  /** preceding-sibling axes opcode.         */
599  public static final int FROM_PRECEDING_SIBLINGS = 47;
600
601  /** self axes opcode.         */
602  public static final int FROM_SELF = 48;
603
604  /** namespace axes opcode.         */
605  public static final int FROM_NAMESPACE = 49;
606
607  /** '/' axes opcode.         */
608  public static final int FROM_ROOT = 50;
609
610  /**
611   * For match patterns.
612   * @xsl.usage advanced
613   */
614  public static final int MATCH_ATTRIBUTE = 51;
615
616  /**
617   * For match patterns.
618   * @xsl.usage advanced
619   */
620  public static final int MATCH_ANY_ANCESTOR = 52;
621
622  /**
623   * For match patterns.
624   * @xsl.usage advanced
625   */
626  public static final int MATCH_IMMEDIATE_ANCESTOR = 53;
627
628  /** The end of the axes types.    */
629  public static final int AXES_END_TYPES = 53;
630
631  /** The next free ID.  Please keep this up to date.  */
632  private static final int NEXT_FREE_ID = 99;
633}
634