463 do_parameters_on(this);
464 }
465 };
466
467
468 // This is the core parsing logic for iterating over signatures.
469 // All of the previous classes use this for doing their work.
470
471 class SignatureStream : public StackObj {
472 private:
473 const Symbol* _signature;
474 int _begin;
475 int _end;
476 int _limit;
477 int _array_prefix; // count of '[' before the array element descr
478 BasicType _type;
479 int _state;
480 Symbol* _previous_name; // cache the previously looked up symbol to avoid lookups
481 GrowableArray<Symbol*>* _names; // symbols created while parsing that need to be dereferenced
482
483 Symbol* find_symbol();
484
485 enum { _s_field = 0, _s_method = 1, _s_method_return = 3 };
486 void set_done() {
487 _state |= -2; // preserve s_method bit
488 assert(is_done(), "Unable to set state to done");
489 }
490 int scan_type(BasicType bt);
491
492 public:
493 bool at_return_type() const { return _state == (int)_s_method_return; }
494 bool is_done() const { return _state < 0; }
495 void next();
496
497 SignatureStream(const Symbol* signature, bool is_method = true);
498 ~SignatureStream();
499
500 bool is_reference() const { return is_reference_type(_type); }
501 bool is_array() const { return _type == T_ARRAY; }
502 BasicType type() const { return _type; }
503
504 const u1* raw_bytes() const { return _signature->bytes() + _begin; }
505 int raw_length() const { return _end - _begin; }
506 int raw_symbol_begin() const { return _begin + (has_envelope() ? 1 : 0); }
507 int raw_symbol_end() const { return _end - (has_envelope() ? 1 : 0); }
508 char raw_char_at(int i) const {
509 assert(i < _limit, "index for raw_char_at is over the limit");
510 return _signature->char_at(i);
511 }
512
513 // True if there is an embedded class name in this type,
514 // followed by ';'.
515 bool has_envelope() const {
516 if (!Signature::has_envelope(_signature->char_at(_begin)))
517 return false;
518 // this should always be true, but let's test it:
519 assert(_signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS, "signature envelope has no semi-colon at end");
520 return true;
521 }
522
523 // return the symbol for chars in symbol_begin()..symbol_end()
524 Symbol* as_symbol() {
525 return find_symbol();
526 }
527
528 // in case you want only the return type:
529 void skip_to_return_type();
530
531 // number of '[' in array prefix
532 int array_prefix_length() {
533 return _type == T_ARRAY ? _array_prefix : 0;
534 }
535
536 // In case you want only the array base type,
537 // reset the stream after skipping some brackets '['.
538 // (The argument is clipped to array_prefix_length(),
539 // and if it ends up as zero this call is a nop.
540 // The default is value skips all brackets '['.)
541 private:
542 int skip_whole_array_prefix();
543 public:
544 int skip_array_prefix(int max_skip_length) {
545 if (_type != T_ARRAY) {
|
463 do_parameters_on(this);
464 }
465 };
466
467
468 // This is the core parsing logic for iterating over signatures.
469 // All of the previous classes use this for doing their work.
470
471 class SignatureStream : public StackObj {
472 private:
473 const Symbol* _signature;
474 int _begin;
475 int _end;
476 int _limit;
477 int _array_prefix; // count of '[' before the array element descr
478 BasicType _type;
479 int _state;
480 Symbol* _previous_name; // cache the previously looked up symbol to avoid lookups
481 GrowableArray<Symbol*>* _names; // symbols created while parsing that need to be dereferenced
482
483 Symbol* find_symbol(bool probe_only);
484
485 enum { _s_field = 0, _s_method = 1, _s_method_return = 3 };
486 void set_done() {
487 _state |= -2; // preserve s_method bit
488 assert(is_done(), "Unable to set state to done");
489 }
490 int scan_type(BasicType bt);
491
492 public:
493 bool at_return_type() const { return _state == (int)_s_method_return; }
494 bool is_done() const { return _state < 0; }
495 void next();
496
497 SignatureStream(const Symbol* signature, bool is_method = true);
498 ~SignatureStream();
499
500 bool is_reference() const { return is_reference_type(_type); }
501 bool is_array() const { return _type == T_ARRAY; }
502 BasicType type() const { return _type; }
503
504 const u1* raw_bytes() const { return _signature->bytes() + _begin; }
505 int raw_length() const { return _end - _begin; }
506 int raw_symbol_begin() const { return _begin + (has_envelope() ? 1 : 0); }
507 int raw_symbol_end() const { return _end - (has_envelope() ? 1 : 0); }
508 char raw_char_at(int i) const {
509 assert(i < _limit, "index for raw_char_at is over the limit");
510 return _signature->char_at(i);
511 }
512
513 // True if there is an embedded class name in this type,
514 // followed by ';'.
515 bool has_envelope() const {
516 if (!Signature::has_envelope(_signature->char_at(_begin)))
517 return false;
518 // this should always be true, but let's test it:
519 assert(_signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS, "signature envelope has no semi-colon at end");
520 return true;
521 }
522
523 // return the symbol for chars in symbol_begin()..symbol_end()
524 Symbol* as_symbol(bool probe_only = false) {
525 return find_symbol(probe_only);
526 }
527
528 // in case you want only the return type:
529 void skip_to_return_type();
530
531 // number of '[' in array prefix
532 int array_prefix_length() {
533 return _type == T_ARRAY ? _array_prefix : 0;
534 }
535
536 // In case you want only the array base type,
537 // reset the stream after skipping some brackets '['.
538 // (The argument is clipped to array_prefix_length(),
539 // and if it ends up as zero this call is a nop.
540 // The default is value skips all brackets '['.)
541 private:
542 int skip_whole_array_prefix();
543 public:
544 int skip_array_prefix(int max_skip_length) {
545 if (_type != T_ARRAY) {
|