sagexx_ug (1158317), страница 12
Текст из файла (страница 12)
more later "); break;case T_UNKNOWN: printf("unknown "); break;case T_COMPLEX: printf("complex "); break;case LOCAL:case INPUT:case OUTPUT:case IO:printf("do these later\n");break;}}if(t->hasBaseType()){printf("of ");doFullType(t->baseType());}}Dump Info - classifyExpressions// help functions for classifyExpressionvoid doExpr(SgExpression *e){printf("EXPR[%d]:",e->id());e->unparsestdout();}int lhsId(SgExpression *e){if(e->lhs()) return (e->lhs())->id();else return -1;}int rhsId(SgExpression *e){if(e->rhs()) return (e->rhs())->id();else return -1;}int symbId(SgExpression *e){if(e->symbol()) return (e->symbol())->id();else return -1;}char * symbName(SgExpression *e){if(e->symbol()) return (e->symbol())->identifier();else return "";181Chapter 9: Example Programs}int typeId(SgExpression *e){if(e->type()) return (e->type())->id();else return -1;}void classifyExpressions(SgFile *f){SgExpression *e;for(e = f->firstExpression(); e; e = e->nextInExprTable()){SgValueExp *valexp = isSgValueExp(e);printf("EXPR[%3d] ", e->id());switch(e->variant()){case INT_VAL:printf("integer value:%d ", valexp->intValue());break;case FLOAT_VAL:printf("real value:%f ", valexp->floatValue());break;case DOUBLE_VAL:printf("double value:%f ", valexp->doubleValue());break;case BOOL_VAL:printf("bool value:%i ", valexp->intValue());break;case CHAR_VAL:printf("char value:%c ", valexp->charValue());break;case STRING_VAL:printf("string value:%s ", valexp->stringValue());break;case COMPLEX_VAL:printf("complex: real part id=%d im part id=%d ",lhsId(e),rhsId(e));break;case KEYWORD_VAL:/* Strings to be printed with quotes */182Chapter 9: Example Programsbreak;183case CONST_REF:printf("constant ref: symb[%d]:%s type[%d] ",symbId(e), symbName(e), typeId(e));break;case VAR_REF:printf("variable ref: symb[%d]:%s type[%d] ",symbId(e), symbName(e), typeId(e));break;case ARRAY_REF:printf("array ref: symb[%d]:%s type[%d] subscript list id (%d) ",symbId(e), symbName(e), typeId(e), lhsId(e));break;case RECORD_REF:case LABEL_REF:break;case VAR_LIST:case EXPR_LIST:case RANGE_LIST:printf("this item [%d] next list [%d] ", lhsId(e), rhsId(e));break;case CASE_CHOICE:case DEF_CHOICE:case VARIANT_CHOICE:Chapter 9: Example Programsbreak;break;break;casecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecase184DDOT:RANGE_OP:UPPER_OP:LOWER_OP:EQ_OP:LT_OP:GT_OP:NOTEQL_OP:LTEQL_OP:GTEQL_OP:ADD_OP:SUBT_OP:OR_OP:MULT_OP:DIV_OP:MOD_OP:AND_OP:EXP_OP:ARRAY_MULT:CONCAT_OP: /* cancatenation of strings */XOR_OP: /* .XOR.
in fortran */EQV_OP: /* .EQV. in fortran */NEQV_OP: /* .NEQV. in fortran */printf("left oprnd[%d] right oprnd[%d] ", lhsId(e), rhsId(e));break;case MINUS_OP: /* unary operations */case NOT_OP:printf("operand[%d]", lhsId(e));case STAR_RANGE: /* operations with no operands 360.. */casecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasecasePROC_CALL:FUNC_CALL:CONSTRUCTOR_REF:ACCESS_REF:CONS:ACCESS:IOACCESS:CONTROL_LIST:SEQ:SPEC_PAIR:COMM_LIST:STMT_STR:EQUI_LIST:IMPL_TYPE:STMTFN_DECL:BIT_COMPLEMENT_OP:EXPR_IF:EXPR_IF_BODY:FUNCTION_REF:UNARY_ADD_OP:SIZE_OP:INTEGER_DIV_OP:SUB_OP:NAMELIST_LIST:ORDERED_OP:/* Following added for PCF FORTRAN */Chapter 9: Example Programs}Dump Info - classifySymbolsvoid classifySymbols(SgFile *f){SgSymbol *s;SgVariableSymb *vs;SgConstantSymb *cs;SgFunctionSymb *fs;SgLabelVarSymb *lvs;SgExternalSymb *exts;SgConstructSymb *cnsts;SgInterfaceSymb *ifs;SgModuleSymb *mods;for(s = f->firstSymbol(); s; s = s->next()){printf("SYMB[%d]: %s = %s scope=STMT[%d] type:",s->id(),tag[s->variant()], s->identifier(),(s->scope())?(s->scope())->id(): -1);if(s->type()) doFullType(s->type());doSymbAttribs(s);printf("\n");switch(s->variant()){case CONST_NAME:case VARIABLE_NAME:case PROGRAM_NAME:case PROCEDURE_NAME:case LABEL_VAR: /* dest of assigned goto stmt */case FUNCTION_NAME:case LABEL_NAME: /* new added for VPC */case ROUTINE_NAME: /*added for external statement*/case CONSTRUCT_NAME:case INTERFACE_NAME:case MODULE_NAME:printf(" need work\n");break;default:printf("forgot one\n");break;}}}Dump Info - main185Chapter 9: Example Programsint main(int argc, char **argv){SgProject project("x.proj");SgFile file("x.f");int c;initVariantNames();}switch (file.languageType()) {case CSrc:printf("this is a c program.
this example is for fortran \n");return -1;case ForSrc:classifyStatements(&file);printf("**************************************************\n");printf("**** Expression Table ****************************\n");printf("**************************************************\n");classifyExpressions(&file);printf("**************************************************\n");printf("**** Symbol Table *******************************\n");printf("**************************************************\n");classifySymbols(&file);}return 0;186Chapter 10: Indices18710 Indices10.1 Index - Sage ClassesS5180SgArrayType .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123SgAssignedGotoStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62SgAssignStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58SgAttributeExp . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102SgBasicBlockStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19SgBlockDataStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28SgBreakStmt . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58SgCallStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64SgCaseOptionStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . 53SgCastExp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89SgCExpStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57SgClassStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19SgClassSymb . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114SgClassType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124SgCollectionStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23SgComputedGotoStmt . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . 63SgConstantSymb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111SgConstExp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. 100SgConstructSymb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119SgContinueStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55SgControlEndStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55SgCycleStmt . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68SgDeclarationStatement . . . . . . . . . . . . . . . . . . . . . . . . . . 31SgDefaultExp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99SgDeleteExp . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . 90SgDerivedClassType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130SgDerivedCollectionType . . . . . . . . . . . . . . . . . . . . . . . . 130SgDerivedType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128SgDescriptType . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . 126SgDoWhileStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45SgEnumStmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23SgExecutableStatement . . . .