1 /* 2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. 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 18 #ifndef SEMSYM_H_ 19 #define SEMSYM_H_ 20 21 #include "gbldefs.h" 22 #include "symtab.h" 23 24 /** 25 \brief Look up symbol having a specific symbol type. 26 27 If a symbol is found in the same overloading class and has the same 28 symbol type, it is returned to the caller. If a symbol is found in 29 the same overloading class, the action of declref depends on the 30 stype of the existing symbol and value of the argument def: 31 1. if symbol is an unfrozen intrinsic and def is 'd' (define), its 32 intrinsic property is removed and a new symbol is declared, 33 2. if def is 'd', a multiple declaration error occurs, or 34 3. if def is not 'd', an 'illegal use' error occurs. 35 36 If an error occurs or a matching symbol is not found, one is 37 created and its symbol type is initialized. 38 */ 39 SPTR declref(SPTR sptr, SYMTYPE stype, int def); 40 41 /** 42 \brief Declare a new symbol. 43 44 An error can occur if the symbol is already in the symbol table: 45 - if the symbol types match treat as an error if 'errflg' is true 46 otherwise its okay and return symbol to caller 47 - else if symbol is an intrinsic attempt to remove symbol's 48 intrinsic property otherwise it is an error 49 */ 50 SPTR declsym(SPTR sptr, SYMTYPE stype, bool errflg); 51 52 /** 53 \brief Look up symbol matching overloading class of given symbol 54 type. 55 56 The sptr is returned for the symbol whose overloading class matches 57 the overloading class of the symbol type given. If no symbol is 58 found in the given overloading class one is created. (If scoping 59 becomes a Fortran feature, this routine will not use it) 60 */ 61 SPTR getocsym(SPTR sptr, int oclass); 62 63 /** 64 \brief Reset fields of intrinsic or generic symbol, sptr, to zero 65 in preparation for changing its symbol type by the Semantic 66 Analyzer. If the symbol type of the symbol has been 'frozen', issue 67 an error message and notify the caller by returning a zero symbol 68 pointer. 69 */ 70 SPTR newsym(SPTR sptr); 71 72 /** 73 \brief Reference a symbol when it's known the context requires an 74 identifier. If an error occurs (e.g., symbol which is frozen as an 75 intrinsic), a new symbol is created so that processing can 76 continue. If the symbol found is ST_UNKNOWN, its stype is changed 77 to ST_IDENT. 78 */ 79 SPTR ref_ident(SPTR sptr); 80 81 /** 82 \brief Look up a symbol having the given overloading class. 83 84 If the symbol with the overloading class is found its sptr is 85 returned. If no symbol with the given overloading class is found, 86 a new sptr is returned. (If scoping becomes a Fortran feature, 87 this routine will implement it) 88 */ 89 SPTR refsym(SPTR sptr, int oclass); 90 91 #endif // SEMSYM_H_ 92