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