hotspot/src/share/vm/adlc/adlparse.cpp
changeset 46630 75aa3e39d02c
parent 35164 80ecc1fdfbd6
equal deleted inserted replaced
46629:8eeacdc76bf2 46630:75aa3e39d02c
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
  3483   }
  3483   }
  3484   next_char();                   // skip open paren
  3484   next_char();                   // skip open paren
  3485   skipws();
  3485   skipws();
  3486   if (_curchar != ')') {
  3486   if (_curchar != ')') {
  3487     // Parse primary, secondary, and tertiary opcodes, if provided.
  3487     // Parse primary, secondary, and tertiary opcodes, if provided.
  3488     if ( ((primary = get_ident_or_literal_constant("primary opcode")) == NULL) ) {
  3488     if ( (primary = get_ident_or_literal_constant("primary opcode")) == NULL ) {
  3489         parse_err(SYNERR, "primary hex opcode expected at %c\n", _curchar);
  3489           parse_err(SYNERR, "primary hex opcode expected at %c\n", _curchar);
  3490         return NULL;
  3490         return NULL;
  3491     }
  3491     }
  3492     skipws();
  3492     skipws();
  3493     if (_curchar == ',') {
  3493     if (_curchar == ',') {
  3494       next_char();
  3494       next_char();
  3495       skipws();
  3495       skipws();
  3496       // Parse secondary opcode
  3496       // Parse secondary opcode
  3497       if ( ((secondary = get_ident_or_literal_constant("secondary opcode")) == NULL) ) {
  3497       if ( (secondary = get_ident_or_literal_constant("secondary opcode")) == NULL ) {
  3498         parse_err(SYNERR, "secondary hex opcode expected at %c\n", _curchar);
  3498         parse_err(SYNERR, "secondary hex opcode expected at %c\n", _curchar);
  3499         return NULL;
  3499         return NULL;
  3500       }
  3500       }
  3501       skipws();
  3501       skipws();
  3502       if (_curchar == ',') {
  3502       if (_curchar == ',') {
  3503         next_char();
  3503         next_char();
  3504         skipws();
  3504         skipws();
  3505         // Parse tertiary opcode
  3505         // Parse tertiary opcode
  3506         if ( ((tertiary = get_ident_or_literal_constant("tertiary opcode")) == NULL) ) {
  3506         if ( (tertiary = get_ident_or_literal_constant("tertiary opcode")) == NULL ) {
  3507           parse_err(SYNERR,"tertiary hex opcode expected at %c\n", _curchar);
  3507           parse_err(SYNERR,"tertiary hex opcode expected at %c\n", _curchar);
  3508           return NULL;
  3508           return NULL;
  3509         }
  3509         }
  3510         skipws();
  3510         skipws();
  3511       }
  3511       }
  4771     return 0;
  4771     return 0;
  4772 
  4772 
  4773   skipws();                       // Skip whitespace before identifier
  4773   skipws();                       // Skip whitespace before identifier
  4774   start = end = _ptr;             // Start points at first character
  4774   start = end = _ptr;             // Start points at first character
  4775   c = *end;                       // Grab character to test
  4775   c = *end;                       // Grab character to test
  4776   while ((c >= '0') && (c <= '9')
  4776   while ((c >= '0' && c <= '9') || (c == '-' && end == start)) {
  4777          || ((c == '-') && (end == start))) {
       
  4778     end++;                        // Increment end pointer
  4777     end++;                        // Increment end pointer
  4779     c = *end;                     // Grab character to test
  4778     c = *end;                     // Grab character to test
  4780   }
  4779   }
  4781   if (start == end) {             // We popped out on the first try
  4780   if (start == end) {             // We popped out on the first try
  4782     parse_err(SYNERR, "integer expected at %c\n", c);
  4781     parse_err(SYNERR, "integer expected at %c\n", c);
  4810   char *start = _ptr;             // Store start of relational operator
  4809   char *start = _ptr;             // Store start of relational operator
  4811   char first  = *_ptr;            // the first character
  4810   char first  = *_ptr;            // the first character
  4812   if( (first == '=') || (first == '!') || (first == '<') || (first == '>') ) {
  4811   if( (first == '=') || (first == '!') || (first == '<') || (first == '>') ) {
  4813     next_char();
  4812     next_char();
  4814     char second = *_ptr;          // the second character
  4813     char second = *_ptr;          // the second character
  4815     if( (second == '=') ) {
  4814     if( second == '=' ) {
  4816       next_char();
  4815       next_char();
  4817       char tmp  = *_ptr;
  4816       char tmp  = *_ptr;
  4818       *_ptr = '\0';               // NULL terminate
  4817       *_ptr = '\0';               // NULL terminate
  4819       result = strdup(start);     // Duplicate the string
  4818       result = strdup(start);     // Duplicate the string
  4820       *_ptr = tmp;                // restore buffer
  4819       *_ptr = tmp;                // restore buffer