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