1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xalan" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, Lotus
  53. * Development Corporation., http://www.lotus.com. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package org.apache.xpath.compiler;
  58. /**
  59. * Operations codes for XPath.
  60. *
  61. * Code for the descriptions of the operations codes:
  62. * [UPPER CASE] indicates a literal value,
  63. * [lower case] is a description of a value,
  64. * ([length] always indicates the length of the operation,
  65. * including the operations code and the length integer.)
  66. * {UPPER CASE} indicates the given production,
  67. * {description} is the description of a new production,
  68. * (For instance, {boolean expression} means some expression
  69. * that should be resolved to a boolean.)
  70. * * means that it occurs zero or more times,
  71. * + means that it occurs one or more times,
  72. * ? means that it is optional.
  73. *
  74. * returns: indicates what the production should return.
  75. */
  76. public class OpCodes
  77. {
  78. /**
  79. * <meta name="usage" content="advanced"/>
  80. * [ENDOP]
  81. * Some operators may like to have a terminator.
  82. */
  83. public static final int ENDOP = -1;
  84. /**
  85. * [EMPTY]
  86. * Empty slot to indicate NULL.
  87. */
  88. public static final int EMPTY = -2;
  89. /**
  90. * <meta name="usage" content="advanced"/>
  91. * [ELEMWILDCARD]
  92. * Means ELEMWILDCARD ("*"), used instead
  93. * of string index in some places.
  94. */
  95. public static final int ELEMWILDCARD = -3;
  96. /**
  97. * <meta name="usage" content="advanced"/>
  98. * [OP_XPATH]
  99. * [length]
  100. * {expression}
  101. *
  102. * returns:
  103. * XNodeSet
  104. * XNumber
  105. * XString
  106. * XBoolean
  107. * XRTree
  108. * XObject
  109. */
  110. public static final int OP_XPATH = 1;
  111. /**
  112. * <meta name="usage" content="advanced"/>
  113. * [OP_OR]
  114. * [length]
  115. * {boolean expression}
  116. * {boolean expression}
  117. *
  118. * returns:
  119. * XBoolean
  120. */
  121. public static final int OP_OR = 2;
  122. /**
  123. * <meta name="usage" content="advanced"/>
  124. * [OP_AND]
  125. * [length]
  126. * {boolean expression}
  127. * {boolean expression}
  128. *
  129. * returns:
  130. * XBoolean
  131. */
  132. public static final int OP_AND = 3;
  133. /**
  134. * <meta name="usage" content="advanced"/>
  135. * [OP_NOTEQUALS]
  136. * [length]
  137. * {expression}
  138. * {expression}
  139. *
  140. * returns:
  141. * XBoolean
  142. */
  143. public static final int OP_NOTEQUALS = 4;
  144. /**
  145. * <meta name="usage" content="advanced"/>
  146. * [OP_EQUALS]
  147. * [length]
  148. * {expression}
  149. * {expression}
  150. *
  151. * returns:
  152. * XBoolean
  153. */
  154. public static final int OP_EQUALS = 5;
  155. /**
  156. * <meta name="usage" content="advanced"/>
  157. * [OP_LTE] (less-than-or-equals)
  158. * [length]
  159. * {number expression}
  160. * {number expression}
  161. *
  162. * returns:
  163. * XBoolean
  164. */
  165. public static final int OP_LTE = 6;
  166. /**
  167. * <meta name="usage" content="advanced"/>
  168. * [OP_LT] (less-than)
  169. * [length]
  170. * {number expression}
  171. * {number expression}
  172. *
  173. * returns:
  174. * XBoolean
  175. */
  176. public static final int OP_LT = 7;
  177. /**
  178. * <meta name="usage" content="advanced"/>
  179. * [OP_GTE] (greater-than-or-equals)
  180. * [length]
  181. * {number expression}
  182. * {number expression}
  183. *
  184. * returns:
  185. * XBoolean
  186. */
  187. public static final int OP_GTE = 8;
  188. /**
  189. * <meta name="usage" content="advanced"/>
  190. * [OP_GT] (greater-than)
  191. * [length]
  192. * {number expression}
  193. * {number expression}
  194. *
  195. * returns:
  196. * XBoolean
  197. */
  198. public static final int OP_GT = 9;
  199. /**
  200. * <meta name="usage" content="advanced"/>
  201. * [OP_PLUS]
  202. * [length]
  203. * {number expression}
  204. * {number expression}
  205. *
  206. * returns:
  207. * XNumber
  208. */
  209. public static final int OP_PLUS = 10;
  210. /**
  211. * <meta name="usage" content="advanced"/>
  212. * [OP_MINUS]
  213. * [length]
  214. * {number expression}
  215. * {number expression}
  216. *
  217. * returns:
  218. * XNumber
  219. */
  220. public static final int OP_MINUS = 11;
  221. /**
  222. * <meta name="usage" content="advanced"/>
  223. * [OP_MULT]
  224. * [length]
  225. * {number expression}
  226. * {number expression}
  227. *
  228. * returns:
  229. * XNumber
  230. */
  231. public static final int OP_MULT = 12;
  232. /**
  233. * <meta name="usage" content="advanced"/>
  234. * [OP_DIV]
  235. * [length]
  236. * {number expression}
  237. * {number expression}
  238. *
  239. * returns:
  240. * XNumber
  241. */
  242. public static final int OP_DIV = 13;
  243. /**
  244. * <meta name="usage" content="advanced"/>
  245. * [OP_MOD]
  246. * [length]
  247. * {number expression}
  248. * {number expression}
  249. *
  250. * returns:
  251. * XNumber
  252. */
  253. public static final int OP_MOD = 14;
  254. /**
  255. * <meta name="usage" content="advanced"/>
  256. * [OP_QUO]
  257. * [length]
  258. * {number expression}
  259. * {number expression}
  260. *
  261. * returns:
  262. * XNumber
  263. */
  264. public static final int OP_QUO = 15;
  265. /**
  266. * <meta name="usage" content="advanced"/>
  267. * [OP_NEG]
  268. * [length]
  269. * {number expression}
  270. *
  271. * returns:
  272. * XNumber
  273. */
  274. public static final int OP_NEG = 16;
  275. /**
  276. * <meta name="usage" content="advanced"/>
  277. * [OP_STRING] (cast operation)
  278. * [length]
  279. * {expression}
  280. *
  281. * returns:
  282. * XString
  283. */
  284. public static final int OP_STRING = 17;
  285. /**
  286. * <meta name="usage" content="advanced"/>
  287. * [OP_BOOL] (cast operation)
  288. * [length]
  289. * {expression}
  290. *
  291. * returns:
  292. * XBoolean
  293. */
  294. public static final int OP_BOOL = 18;
  295. /**
  296. * <meta name="usage" content="advanced"/>
  297. * [OP_NUMBER] (cast operation)
  298. * [length]
  299. * {expression}
  300. *
  301. * returns:
  302. * XBoolean
  303. */
  304. public static final int OP_NUMBER = 19;
  305. /**
  306. * <meta name="usage" content="advanced"/>
  307. * [OP_UNION]
  308. * [length]
  309. * {PathExpr}+
  310. *
  311. * returns:
  312. * XNodeSet
  313. */
  314. public static final int OP_UNION = 20;
  315. /**
  316. * <meta name="usage" content="advanced"/>
  317. * [OP_LITERAL]
  318. * [3]
  319. * [index to token]
  320. *
  321. * returns:
  322. * XString
  323. */
  324. public static final int OP_LITERAL = 21;
  325. /** The low opcode for nodesets, needed by getFirstPredicateOpPos and
  326. * getNextStepPos. */
  327. static final int FIRST_NODESET_OP = 22;
  328. /**
  329. * <meta name="usage" content="advanced"/>
  330. * [OP_VARIABLE]
  331. * [4]
  332. * [index to namespace token, or EMPTY]
  333. * [index to function name token]
  334. *
  335. * returns:
  336. * XString
  337. */
  338. public static final int OP_VARIABLE = 22;
  339. /**
  340. * <meta name="usage" content="advanced"/>
  341. * [OP_GROUP]
  342. * [length]
  343. * {expression}
  344. *
  345. * returns:
  346. * XNodeSet
  347. * XNumber
  348. * XString
  349. * XBoolean
  350. * XRTree
  351. * XObject
  352. */
  353. public static final int OP_GROUP = 23;
  354. /**
  355. * <meta name="usage" content="advanced"/>
  356. * [OP_EXTFUNCTION] (Extension function.)
  357. * [length]
  358. * [index to namespace token]
  359. * [index to function name token]
  360. * {OP_ARGUMENT}
  361. *
  362. * returns:
  363. * XNodeSet
  364. * XNumber
  365. * XString
  366. * XBoolean
  367. * XRTree
  368. * XObject
  369. */
  370. public static final int OP_EXTFUNCTION = 24;
  371. /**
  372. * <meta name="usage" content="advanced"/>
  373. * [OP_FUNCTION]
  374. * [length]
  375. * [FUNC_name]
  376. * {OP_ARGUMENT}
  377. * [ENDOP]
  378. *
  379. * returns:
  380. * XNodeSet
  381. * XNumber
  382. * XString
  383. * XBoolean
  384. * XRTree
  385. * XObject
  386. */
  387. public static final int OP_FUNCTION = 25;
  388. /** The last opcode for stuff that can be a nodeset. */
  389. static final int LAST_NODESET_OP = 25;
  390. /**
  391. * <meta name="usage" content="advanced"/>
  392. * [OP_ARGUMENT] (Function argument.)
  393. * [length]
  394. * {expression}
  395. *
  396. * returns:
  397. * XNodeSet
  398. * XNumber
  399. * XString
  400. * XBoolean
  401. * XRTree
  402. * XObject
  403. */
  404. public static final int OP_ARGUMENT = 26;
  405. /**
  406. * <meta name="usage" content="advanced"/>
  407. * [OP_NUMBERLIT] (Number literal.)
  408. * [3]
  409. * [index to token]
  410. *
  411. * returns:
  412. * XString
  413. */
  414. public static final int OP_NUMBERLIT = 27;
  415. /**
  416. * <meta name="usage" content="advanced"/>
  417. * [OP_LOCATIONPATH]
  418. * [length]
  419. * {FROM_stepType}
  420. * | {function}
  421. * {predicate}
  422. * [ENDOP]
  423. *
  424. * (Note that element and attribute namespaces and
  425. * names can be wildcarded '*'.)
  426. *
  427. * returns:
  428. * XNodeSet
  429. */
  430. public static final int OP_LOCATIONPATH = 28;
  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. * <meta name="usage" content="advanced"/>
  436. * [OP_PREDICATE]
  437. * [length]
  438. * {expression}
  439. * [ENDOP] (For safety)
  440. *
  441. * returns:
  442. * XBoolean or XNumber
  443. */
  444. public static final int OP_PREDICATE = 29;
  445. /**
  446. * <meta name="usage" content="advanced"/>
  447. * [OP_MATCHPATTERN]
  448. * [length]
  449. * {PathExpr}+
  450. *
  451. * returns:
  452. * XNodeSet
  453. */
  454. public static final int OP_MATCHPATTERN = 30;
  455. /**
  456. * <meta name="usage" content="advanced"/>
  457. * [OP_LOCATIONPATHPATTERN]
  458. * [length]
  459. * {FROM_stepType}
  460. * | {function}{predicate}
  461. * [ENDOP]
  462. * returns:
  463. * XNodeSet
  464. */
  465. public static final int OP_LOCATIONPATHPATTERN = 31;
  466. /**
  467. * <meta name="usage" content="advanced"/>
  468. * [NODETYPE_COMMENT]
  469. * No size or arguments.
  470. * Note: must not overlap function OP number!
  471. *
  472. * returns:
  473. * XBoolean
  474. */
  475. public static final int NODETYPE_COMMENT = 1030;
  476. /**
  477. * <meta name="usage" content="advanced"/>
  478. * [NODETYPE_TEXT]
  479. * No size or arguments.
  480. * Note: must not overlap function OP number!
  481. *
  482. * returns:
  483. * XBoolean
  484. */
  485. public static final int NODETYPE_TEXT = 1031;
  486. /**
  487. * <meta name="usage" content="advanced"/>
  488. * [NODETYPE_PI]
  489. * [index to token]
  490. * Note: must not overlap function OP number!
  491. *
  492. * returns:
  493. * XBoolean
  494. */
  495. public static final int NODETYPE_PI = 1032;
  496. /**
  497. * <meta name="usage" content="advanced"/>
  498. * [NODETYPE_NODE]
  499. * No size or arguments.
  500. * Note: must not overlap function OP number!
  501. *
  502. * returns:
  503. * XBoolean
  504. */
  505. public static final int NODETYPE_NODE = 1033;
  506. /**
  507. * <meta name="usage" content="advanced"/>
  508. * [NODENAME]
  509. * [index to ns token or EMPTY]
  510. * [index to name token]
  511. *
  512. * returns:
  513. * XBoolean
  514. */
  515. public static final int NODENAME = 34;
  516. /**
  517. * <meta name="usage" content="advanced"/>
  518. * [NODETYPE_ROOT]
  519. * No size or arguments.
  520. *
  521. * returns:
  522. * XBoolean
  523. */
  524. public static final int NODETYPE_ROOT = 35;
  525. /**
  526. * <meta name="usage" content="advanced"/>
  527. * [NODETYPE_ANY]
  528. * No size or arguments.
  529. *
  530. * returns:
  531. * XBoolean
  532. */
  533. public static final int NODETYPE_ANYELEMENT = 36;
  534. /**
  535. * <meta name="usage" content="advanced"/>
  536. * [NODETYPE_ANY]
  537. * No size or arguments.
  538. *
  539. * returns:
  540. * XBoolean
  541. */
  542. public static final int NODETYPE_FUNCTEST = 1034;
  543. /**
  544. * <meta name="usage" content="advanced"/>
  545. * [FROM_stepType]
  546. * [length, including predicates]
  547. * [length of just the step, without the predicates]
  548. * {node test}
  549. * {predicates}?
  550. *
  551. * returns:
  552. * XBoolean
  553. */
  554. public static final int AXES_START_TYPES = 37;
  555. /** ancestor axes opcode. */
  556. public static final int FROM_ANCESTORS = 37;
  557. /** ancestor-or-self axes opcode. */
  558. public static final int FROM_ANCESTORS_OR_SELF = 38;
  559. /** attribute axes opcode. */
  560. public static final int FROM_ATTRIBUTES = 39;
  561. /** children axes opcode. */
  562. public static final int FROM_CHILDREN = 40;
  563. /** descendants axes opcode. */
  564. public static final int FROM_DESCENDANTS = 41;
  565. /** descendants-of-self axes opcode. */
  566. public static final int FROM_DESCENDANTS_OR_SELF = 42;
  567. /** following axes opcode. */
  568. public static final int FROM_FOLLOWING = 43;
  569. /** following-siblings axes opcode. */
  570. public static final int FROM_FOLLOWING_SIBLINGS = 44;
  571. /** parent axes opcode. */
  572. public static final int FROM_PARENT = 45;
  573. /** preceding axes opcode. */
  574. public static final int FROM_PRECEDING = 46;
  575. /** preceding-sibling axes opcode. */
  576. public static final int FROM_PRECEDING_SIBLINGS = 47;
  577. /** self axes opcode. */
  578. public static final int FROM_SELF = 48;
  579. /** namespace axes opcode. */
  580. public static final int FROM_NAMESPACE = 49;
  581. /** '/' axes opcode. */
  582. public static final int FROM_ROOT = 50;
  583. /**
  584. * <meta name="usage" content="advanced"/>
  585. * For match patterns.
  586. */
  587. public static final int MATCH_ATTRIBUTE = 51;
  588. /**
  589. * <meta name="usage" content="advanced"/>
  590. * For match patterns.
  591. */
  592. public static final int MATCH_ANY_ANCESTOR = 52;
  593. /**
  594. * <meta name="usage" content="advanced"/>
  595. * For match patterns.
  596. */
  597. public static final int MATCH_IMMEDIATE_ANCESTOR = 53;
  598. /** The end of the axes types. */
  599. public static final int AXES_END_TYPES = 53;
  600. /** The next free ID. Please keep this up to date. */
  601. private static final int NEXT_FREE_ID = 99;
  602. }