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