/tests/CompileTests/RoseExample_tests/trial_Cxx_Grammar.C
C | 14108 lines | 8485 code | 2536 blank | 3087 comment | 1750 complexity | 8b54bf5d5c2e8df473121fd27356c4cb MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, Apache-2.0
- // MACHINE GENERATED SOURCE FILE --- DO NOT MODIFY!
- #include "sage3basic.h"
- #include "sage3.h"
- #if 1
- #include "AST_FILE_IO.h"
- using namespace std;
- // Simplify code by using std namespace (never put into header files since it effects users)
- using namespace std;
- static struct
- {
- Cxx_GrammarVariants variant;
- std::string name;
- } Cxx_GrammarTerminalNames[317] = {
- {ModifierTag, "SgModifier"},
- {BitAttributeTag, "SgBitAttribute"},
- {AttributeTag, "SgAttribute"},
- {GraphNodeTag, "SgGraphNode"},
- {GraphEdgeTag, "SgGraphEdge"},
- {GraphTag, "SgGraph"},
- {SupportTag, "SgSupport"},
- {T_PARTIAL_FUNCTION, "SgPartialFunctionType"},
- {T_MEMBERFUNCTION, "SgMemberFunctionType"},
- {T_FUNCTION, "SgFunctionType"},
- {T_POINTER, "SgPointerType"},
- {T_NAME, "SgNamedType"},
- {TypeTag, "SgType"},
- {EXPR_INIT, "SgInitializer"},
- {UNARY_EXPRESSION, "SgUnaryOp"},
- {BINARY_EXPRESSION, "SgBinaryOp"},
- {ValueExpTag, "SgValueExp"},
- {ExpressionTag, "SgExpression"},
- {FORTRAN_DO, "SgFortranDo"},
- {IO_CONTROL_STATEMENT, "SgIOControlStatement"},
- {CLASS_DECL_STMT, "SgClassDeclaration"},
- {CLASS_DEFN_STMT, "SgClassDefinition"},
- {SCOPE_STMT, "SgScopeStatement"},
- {MFUNC_DECL_STMT, "SgMemberFunctionDeclaration"},
- {FUNC_DECL_STMT, "SgFunctionDeclaration"},
- {CPP_DIRECTIVE_STMT, "SgC_PreprocessorDirectiveStatement"},
- {C_LINKAGE_DECLARATION_STMT, "SgClinkageDeclarationStatement"},
- {DECL_STMT, "SgDeclarationStatement"},
- {StatementTag, "SgStatement"},
- {FUNCTION_NAME, "SgFunctionSymbol"},
- {SymbolTag, "SgSymbol"},
- {LocatedNodeTag, "SgLocatedNode"},
- {NodeTag, "SgNode"},
- {SymbolTableTag, "SgSymbolTable"},
- {InitializedNameTag, "SgInitializedName"},
- {NameTag, "SgName"},
- {PragmaTag, "SgPragma"},
- {ModifierNodesTag, "SgModifierNodes"},
- {ConstVolatileModifierTag, "SgConstVolatileModifier"},
- {StorageModifierTag, "SgStorageModifier"},
- {AccessModifierTag, "SgAccessModifier"},
- {FunctionModifierTag, "SgFunctionModifier"},
- {UPC_AccessModifierTag, "SgUPC_AccessModifier"},
- {LinkageModifierTag, "SgLinkageModifier"},
- {SpecialFunctionModifierTag, "SgSpecialFunctionModifier"},
- {TypeModifierTag, "SgTypeModifier"},
- {ElaboratedTypeModifierTag, "SgElaboratedTypeModifier"},
- {BaseClassModifierTag, "SgBaseClassModifier"},
- {DeclarationModifierTag, "SgDeclarationModifier"},
- {_File_InfoTag, "Sg_File_Info"},
- {FileTag, "SgFile"},
- {FileListTag, "SgFileList"},
- {DirectoryTag, "SgDirectory"},
- {DirectoryListTag, "SgDirectoryList"},
- {ProjectTag, "SgProject"},
- {OptionsTag, "SgOptions"},
- {Unparse_InfoTag, "SgUnparse_Info"},
- {FuncDecl_attrTag, "SgFuncDecl_attr"},
- {ClassDecl_attrTag, "SgClassDecl_attr"},
- {T_TYPEDEF_SEQ, "SgTypedefSeq"},
- {T_FUNCTION_PARAMETER_TYPE_LIST, "SgFunctionParameterTypeList"},
- {TemplateParameterTag, "SgTemplateParameter"},
- {TemplateArgumentTag, "SgTemplateArgument"},
- {TemplateParameterListTag, "SgTemplateParameterList"},
- {TemplateArgumentListTag, "SgTemplateArgumentList"},
- {BaseClassTag, "SgBaseClass"},
- {DirectedGraphTag, "SgDirectedGraph"},
- {DirectedGraphNodeTag, "SgDirectedGraphNode"},
- {DirectedGraphEdgeTag, "SgDirectedGraphEdge"},
- {QualifiedNameTag, "SgQualifiedName"},
- {T_UNKNOWN, "SgTypeUnknown"},
- {T_CHAR, "SgTypeChar"},
- {T_SIGNED_CHAR, "SgTypeSignedChar"},
- {T_UNSIGNED_CHAR, "SgTypeUnsignedChar"},
- {T_SHORT, "SgTypeShort"},
- {T_SIGNED_SHORT, "SgTypeSignedShort"},
- {T_UNSIGNED_SHORT, "SgTypeUnsignedShort"},
- {T_INT, "SgTypeInt"},
- {T_SIGNED_INT, "SgTypeSignedInt"},
- {T_UNSIGNED_INT, "SgTypeUnsignedInt"},
- {T_LONG, "SgTypeLong"},
- {T_SIGNED_LONG, "SgTypeSignedLong"},
- {T_UNSIGNED_LONG, "SgTypeUnsignedLong"},
- {T_VOID, "SgTypeVoid"},
- {T_GLOBAL_VOID, "SgTypeGlobalVoid"},
- {T_WCHAR, "SgTypeWchar"},
- {T_FLOAT, "SgTypeFloat"},
- {T_DOUBLE, "SgTypeDouble"},
- {T_LONG_LONG, "SgTypeLongLong"},
- {T_UNSIGNED_LONG_LONG, "SgTypeUnsignedLongLong"},
- {T_LONG_DOUBLE, "SgTypeLongDouble"},
- {T_STRING, "SgTypeString"},
- {T_BOOL, "SgTypeBool"},
- {T_COMPLEX, "SgTypeComplex"},
- {T_IMAGINARY, "SgTypeImaginary"},
- {T_DEFAULT, "SgTypeDefault"},
- {T_MEMBER_POINTER, "SgPointerMemberType"},
- {T_REFERENCE, "SgReferenceType"},
- {T_CLASS, "SgClassType"},
- {T_TEMPLATE, "SgTemplateType"},
- {T_ENUM, "SgEnumType"},
- {T_TYPEDEF, "SgTypedefType"},
- {T_MODIFIER, "SgModifierType"},
- {T_PARTIAL_FUNCTION_MODIFIER, "SgPartialFunctionModifierType"},
- {T_ARRAY, "SgArrayType"},
- {T_ELLIPSE, "SgTypeEllipse"},
- {UnknownMemberFunctionTag, "SgUnknownMemberFunctionType"},
- {T_QUALIFIED_NAME, "SgQualifiedNameType"},
- {EXPR_LIST, "SgExprListExp"},
- {VAR_REF, "SgVarRefExp"},
- {CLASSNAME_REF, "SgClassNameRefExp"},
- {FUNCTION_REF, "SgFunctionRefExp"},
- {MEMBER_FUNCTION_REF, "SgMemberFunctionRefExp"},
- {FUNC_CALL, "SgFunctionCallExp"},
- {SIZEOF_OP, "SgSizeOfOp"},
- {VA_START_OP, "SgVarArgStartOp"},
- {VA_START_ONE_OPERAND_OP, "SgVarArgStartOneOperandOp"},
- {VA_OP, "SgVarArgOp"},
- {VA_END_OP, "SgVarArgEndOp"},
- {VA_COPY_OP, "SgVarArgCopyOp"},
- {TYPEID_OP, "SgTypeIdOp"},
- {EXPR_CONDITIONAL, "SgConditionalExp"},
- {NEW_OP, "SgNewExp"},
- {DELETE_OP, "SgDeleteExp"},
- {THIS_NODE, "SgThisExp"},
- {TYPE_REF, "SgRefExp"},
- {AGGREGATE_INIT, "SgAggregateInitializer"},
- {CONSTRUCTOR_INIT, "SgConstructorInitializer"},
- {ASSIGN_INIT, "SgAssignInitializer"},
- {EXPRESSION_ROOT, "SgExpressionRoot"},
- {UNARY_MINUS_OP, "SgMinusOp"},
- {UNARY_ADD_OP, "SgUnaryAddOp"},
- {NOT_OP, "SgNotOp"},
- {DEREF_OP, "SgPointerDerefExp"},
- {ADDRESS_OP, "SgAddressOfOp"},
- {MINUSMINUS_OP, "SgMinusMinusOp"},
- {PLUSPLUS_OP, "SgPlusPlusOp"},
- {BIT_COMPLEMENT_OP, "SgBitComplementOp"},
- {CAST_OP, "SgCastExp"},
- {THROW_OP, "SgThrowOp"},
- {POINTST_OP, "SgArrowExp"},
- {RECORD_REF, "SgDotExp"},
- {DOTSTAR_OP, "SgDotStarOp"},
- {ARROWSTAR_OP, "SgArrowStarOp"},
- {EQ_OP, "SgEqualityOp"},
- {LT_OP, "SgLessThanOp"},
- {GT_OP, "SgGreaterThanOp"},
- {NE_OP, "SgNotEqualOp"},
- {LE_OP, "SgLessOrEqualOp"},
- {GE_OP, "SgGreaterOrEqualOp"},
- {ADD_OP, "SgAddOp"},
- {SUBT_OP, "SgSubtractOp"},
- {MULT_OP, "SgMultiplyOp"},
- {DIV_OP, "SgDivideOp"},
- {INTEGER_DIV_OP, "SgIntegerDivideOp"},
- {MOD_OP, "SgModOp"},
- {AND_OP, "SgAndOp"},
- {OR_OP, "SgOrOp"},
- {BITXOR_OP, "SgBitXorOp"},
- {BITAND_OP, "SgBitAndOp"},
- {BITOR_OP, "SgBitOrOp"},
- {COMMA_OP, "SgCommaOpExp"},
- {LSHIFT_OP, "SgLshiftOp"},
- {RSHIFT_OP, "SgRshiftOp"},
- {ARRAY_OP, "SgPntrArrRefExp"},
- {SCOPE_OP, "SgScopeOp"},
- {ASSIGN_OP, "SgAssignOp"},
- {PLUS_ASSIGN_OP, "SgPlusAssignOp"},
- {MINUS_ASSIGN_OP, "SgMinusAssignOp"},
- {AND_ASSIGN_OP, "SgAndAssignOp"},
- {IOR_ASSIGN_OP, "SgIorAssignOp"},
- {MULT_ASSIGN_OP, "SgMultAssignOp"},
- {DIV_ASSIGN_OP, "SgDivAssignOp"},
- {MOD_ASSIGN_OP, "SgModAssignOp"},
- {XOR_ASSIGN_OP, "SgXorAssignOp"},
- {LSHIFT_ASSIGN_OP, "SgLshiftAssignOp"},
- {RSHIFT_ASSIGN_OP, "SgRshiftAssignOp"},
- {BOOL_VAL, "SgBoolValExp"},
- {STRING_VAL, "SgStringVal"},
- {SHORT_VAL, "SgShortVal"},
- {CHAR_VAL, "SgCharVal"},
- {UNSIGNED_CHAR_VAL, "SgUnsignedCharVal"},
- {WCHAR_VAL, "SgWcharVal"},
- {UNSIGNED_SHORT_VAL, "SgUnsignedShortVal"},
- {INT_VAL, "SgIntVal"},
- {ENUM_VAL, "SgEnumVal"},
- {UNSIGNED_INT_VAL, "SgUnsignedIntVal"},
- {LONG_INT_VAL, "SgLongIntVal"},
- {LONG_LONG_INT_VAL, "SgLongLongIntVal"},
- {UNSIGNED_LONG_LONG_INT_VAL, "SgUnsignedLongLongIntVal"},
- {UNSIGNED_LONG_INT_VAL, "SgUnsignedLongVal"},
- {FLOAT_VAL, "SgFloatVal"},
- {DOUBLE_VAL, "SgDoubleVal"},
- {LONG_DOUBLE_VAL, "SgLongDoubleVal"},
- {COMPLEX_VAL, "SgComplexVal"},
- {NULL_EXPR, "SgNullExpression"},
- {VARIANT_EXPR, "SgVariantExpression"},
- {STMT_EXPR, "SgStatementExpression"},
- {ASM_OP, "SgAsmOp"},
- {INTRINSICFN, "SgIntrinsicFn"},
- {SUBSCRIPT_EXPR, "SgSubscriptExpression"},
- {SUBSCRIPT_COLON, "SgSubscriptColon"},
- {COLON, "SgColon"},
- {SUBSCRIPT_ASTERISK, "SgSubscriptAsterisk"},
- {USE_ONLY_EXPR, "SgUseOnlyExpression"},
- {USE_RENAME_EXPR, "SgUseRenameExpression"},
- {IO_ITEM_EXPR, "SgIOItemExpression"},
- {IO_IMPLIED_DO, "SgIOImpliedDo"},
- {EXPONENTIATION_OP, "SgExponentiationOp"},
- {FOR_STMT, "SgForStatement"},
- {FOR_INIT_STMT, "SgForInitStatement"},
- {CATCH_STATEMENT_SEQ, "SgCatchStatementSeq"},
- {FUNCTION_PARAMETER_LIST, "SgFunctionParameterList"},
- {CTOR_INITIALIZER_LIST, "SgCtorInitializerList"},
- {BASIC_BLOCK_STMT, "SgBasicBlock"},
- {GLOBAL_STMT, "SgGlobal"},
- {IF_STMT, "SgIfStmt"},
- {FUNC_DEFN_STMT, "SgFunctionDefinition"},
- {WHILE_STMT, "SgWhileStmt"},
- {DO_WHILE_STMT, "SgDoWhileStmt"},
- {SWITCH_STMT, "SgSwitchStatement"},
- {CATCH_STMT, "SgCatchOptionStmt"},
- {VAR_DECL_STMT, "SgVariableDeclaration"},
- {VAR_DEFN_STMT, "SgVariableDefinition"},
- {ENUM_DECL_STMT, "SgEnumDeclaration"},
- {ASM_STMT, "SgAsmStmt"},
- {TYPEDEF_STMT, "SgTypedefDeclaration"},
- {FUNC_TBL_STMT, "SgFunctionTypeTable"},
- {EXPR_STMT, "SgExprStatement"},
- {LABEL_STMT, "SgLabelStatement"},
- {CASE_STMT, "SgCaseOptionStmt"},
- {TRY_STMT, "SgTryStmt"},
- {DEFAULT_STMT, "SgDefaultOptionStmt"},
- {BREAK_STMT, "SgBreakStmt"},
- {CONTINUE_STMT, "SgContinueStmt"},
- {RETURN_STMT, "SgReturnStmt"},
- {GOTO_STMT, "SgGotoStatement"},
- {SPAWN_STMT, "SgSpawnStmt"},
- {NULL_STMT, "SgNullStatement"},
- {VARIANT_STMT, "SgVariantStatement"},
- {PRAGMA_DECL, "SgPragmaDeclaration"},
- {TEMPLATE_DECL_STMT, "SgTemplateDeclaration"},
- {TEMPLATE_INST_DECL_STMT, "SgTemplateInstantiationDecl"},
- {TEMPLATE_INST_DEFN_STMT, "SgTemplateInstantiationDefn"},
- {TEMPLATE_INST_FUNCTION_DECL_STMT, "SgTemplateInstantiationFunctionDecl"},
- {TEMPLATE_INST_MEMBER_FUNCTION_DECL_STMT, "SgTemplateInstantiationMemberFunctionDecl"},
- {PROGRAM_HEADER_STMT, "SgProgramHeaderStatement"},
- {PROCEDURE_HEADER_STMT, "SgProcedureHeaderStatement"},
- {FORTRAN_NONBLOCKED_DO, "SgFortranNonblockedDo"},
- {INTERFACE_STATEMENT, "SgInterfaceStatement"},
- {PARAMETER_STATEMENT, "SgParameterStatement"},
- {COMMON_BLOCK, "SgCommonBlock"},
- {MODULE_STATEMENT, "SgModuleStatement"},
- {USE_STATEMENT, "SgUseStatement"},
- {STOP_OR_PAUSE_STATEMENT, "SgStopOrPauseStatement"},
- {IO_STATEMENT, "SgIOStatement"},
- {INPUT_OUTPUT_STATEMENT, "SgInputOutputStatement"},
- {OPEN_STATEMENT, "SgOpenStatement"},
- {CLOSE_STATEMENT, "SgCloseStatement"},
- {INQUIRE_STATEMENT, "SgInquireStatement"},
- {IO_FILE_CONTROL_STMT, "SgIOFileControlStmt"},
- {TEMP_Block_Data_Statement, "SgBlockDataStatement"},
- {TEMP_Implicit_Statement, "SgImplicitStatement"},
- {TEMP_Statement_Function_Statement, "SgStatementFunctionStatement"},
- {TEMP_Where_Statement, "SgWhereStatement"},
- {TEMP_Nullify_Statement, "SgNullifyStatement"},
- {TEMP_Equivalence_Statement, "SgEquivalenceStatement"},
- {TEMP_Derived_Type_Statement, "SgDerivedTypeStatement"},
- {TEMP_Attribute_Specification_Statement, "SgAttributeSpecificationStatement"},
- {TEMP_Allocate_Statement, "SgAllocateStatement"},
- {TEMP_Deallocate_Statement, "SgDeallocateStatement"},
- {TEMP_Contains_Statement, "SgContainsStatement"},
- {TEMP_Sequence_Statement, "SgSequenceStatement"},
- {TEMP_Else_Where_Statement, "SgElseWhereStatement"},
- {TEMP_Arithmetic_If_Statement, "SgArithmeticIfStatement"},
- {TEMP_Assign_Statement, "SgAssignStatement"},
- {TEMP_Computed_Goto_Statement, "SgComputedGotoStatement"},
- {TEMP_Assigned_Goto_Statement, "SgAssignedGotoStatement"},
- {NAMESPACE_DECLARATION_STMT, "SgNamespaceDeclarationStatement"},
- {NAMESPACE_ALIAS_DECLARATION_STMT, "SgNamespaceAliasDeclarationStatement"},
- {NAMESPACE_DEFINITION_STMT, "SgNamespaceDefinitionStatement"},
- {USING_DECLARATION_STMT, "SgUsingDeclarationStatement"},
- {USING_DIRECTIVE_STMT, "SgUsingDirectiveStatement"},
- {TEMPLATE_INST_DIRECTIVE_STMT, "SgTemplateInstantiationDirectiveStatement"},
- {INCLUDE_DIRECTIVE_STMT, "SgIncludeDirectiveStatement"},
- {DEFINE_DIRECTIVE_STMT, "SgDefineDirectiveStatement"},
- {UNDEF_DIRECTIVE_STMT, "SgUndefDirectiveStatement"},
- {IFDEF_DIRECTIVE_STMT, "SgIfdefDirectiveStatement"},
- {IFNDEF_DIRECTIVE_STMT, "SgIfndefDirectiveStatement"},
- {IF_DIRECTIVE_STMT, "SgIfDirectiveStatement"},
- {DEAD_IF_DIRECTIVE_STMT, "SgDeadIfDirectiveStatement"},
- {ELSE_DIRECTIVE_STMT, "SgElseDirectiveStatement"},
- {ELSEIF_DIRECTIVE_STMT, "SgElseifDirectiveStatement"},
- {ENDIF_DIRECTIVE_STMT, "SgEndifDirectiveStatement"},
- {LINE_DIRECTIVE_STMT, "SgLineDirectiveStatement"},
- {WARNING_DIRECTIVE_STMT, "SgWarningDirectiveStatement"},
- {ERROR_DIRECTIVE_STMT, "SgErrorDirectiveStatement"},
- {EMPTY_DIRECTIVE_STMT, "SgEmptyDirectiveStatement"},
- {C_LINKAGE_START_STMT, "SgClinkageStartStatement"},
- {C_LINKAGE_END_STMT, "SgClinkageEndStatement"},
- {VARIABLE_NAME, "SgVariableSymbol"},
- {FUNCTYPE_NAME, "SgFunctionTypeSymbol"},
- {CLASS_NAME, "SgClassSymbol"},
- {TEMPLATE_NAME, "SgTemplateSymbol"},
- {ENUM_NAME, "SgEnumSymbol"},
- {FIELD_NAME, "SgEnumFieldSymbol"},
- {TYPEDEF_NAME, "SgTypedefSymbol"},
- {MEMBER_FUNC_NAME, "SgMemberFunctionSymbol"},
- {LABEL_NAME, "SgLabelSymbol"},
- {DEFAULT_NAME, "SgDefaultSymbol"},
- {NAMESPACE_NAME, "SgNamespaceSymbol"},
- {INTRINSIC_SYMBOL, "SgIntrinsicSymbol"},
- {MODULE_SYMBOL, "SgModuleSymbol"},
- {INTERFACE_SYMBOL, "SgInterfaceSymbol"},
- {COMMON_SYMBOL, "SgCommonSymbol"},
- {TOKEN, "SgToken"},
- {Cxx_Grammar_LAST_TAG, "last tag" }
- };
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgNode*
- SgNode::get_freepointer () const
- {
- assert (this != NULL);
- return p_freepointer;
- }
- void
- SgNode::set_freepointer ( SgNode* freepointer )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_freepointer != NULL && freepointer != NULL && p_freepointer != freepointer)
- {
- printf ("Warning: freepointer = %p overwriting valid pointer p_freepointer = %p \n",freepointer,p_freepointer);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_freepointer != NULL && freepointer != NULL && p_freepointer != freepointer) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_freepointer = freepointer;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgNode::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgNode::variantT() const {
- return V_SgNode;
- }
- #if 0
- int
- SgNode::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return NodeTag;
- }
- #endif
- const char*
- SgNode::sage_class_name() const
- {
- assert(this != NULL);
- return "SgNode";
- }
- std::string
- SgNode::class_name() const
- {
- assert(this != NULL);
- return "SgNode";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgNode::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 769 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- // ########################################
- // Some global variables used within SAGE 3
- // ########################################
- // declaration of variable to control internal output of debuging information
- int SAGE_DEBUG = 0; // default value is zero
- // JJW (1/19/2007): Added global variable for whether virtual CFG is
- // interprocedural
- bool interproceduralControlFlowGraph = false;
- // ###############################
- // Start of source code for SgNode
- // ###############################
- // Support for global function type symbol table (moved to be static data pointer)
- // DQ (1/31/2006): Modified to build all types in the memory pools
- // SgFunctionTypeTable* SgNode::Sgfunc_type_table = new SgFunctionTypeTable();
- // SgFunctionTypeTable* SgNode::p_globalFunctionTypeTable = new SgFunctionTypeTable();
- SgFunctionTypeTable* SgNode::p_globalFunctionTypeTable = NULL;
- // DQ (3/12/2007): Added mangled name map to improve performance of generating mangled names
- std::map<SgNode*,std::string> SgNode::p_globalMangledNameMap;
- std::map<std::string,int> SgNode::p_shortMangledNameCache;
- // DQ (10/5/2007): Added IR node specific function to permit copies, via AST copy(), to be fixedup
- // Usually this will correct scopes and in a few cases build child IR nodes that are not traversed
- // (and thus shared in the result from the automatically generated copy function).
- void
- SgNode::fixupCopy(SgNode* copy, SgCopyHelp & help) const
- {
- // This is the empty default inplementation, not a problem if it is called!
- }
- // DQ (1/31/2006): We might want this function to be automaticaly generated
- // except that then we could not support the assertion. Also we
- // don't have to set this function, though perhaps the interface function
- // should be implemented to set it just on general principles.
- SgFunctionTypeTable*
- SgNode::get_globalFunctionTypeTable()
- {
- // DQ (1/31/2006): If there is no global function type symbol table then build one
- if (p_globalFunctionTypeTable == NULL)
- {
- // printf ("In SgNode::get_globalFunctionTypeTable(): p_globalFunctionTypeTable == NULL (allocating the global function type symbol table) \n");
- p_globalFunctionTypeTable = new SgFunctionTypeTable();
- ROSE_ASSERT(p_globalFunctionTypeTable != NULL);
- // p_globalFunctionTypeTable->set_parent(???);
- }
- ROSE_ASSERT(p_globalFunctionTypeTable != NULL);
- return p_globalFunctionTypeTable;
- }
- void
- SgNode::set_globalFunctionTypeTable ( SgFunctionTypeTable* globalFunctionTypeTable )
- {
- p_globalFunctionTypeTable = globalFunctionTypeTable;
- }
- // DQ (3/17/2007): return reference to the global mangled name map (the use
- // of this map is a performance optimization).
- std::map<SgNode*,std::string> &
- SgNode::get_globalMangledNameMap()
- {
- return p_globalMangledNameMap;
- }
- #if 0
- std::map<SgNode*,std::string> &
- SgNode:: get_mangledNameCache()
- {
- return p_mangledNameCache;
- }
- #endif
- std::map<std::string, int> &
- SgNode:: get_shortMangledNameCache()
- {
- return p_shortMangledNameCache;
- }
- // DQ (3/17/2007): return reference to the global mangled name map (the use
- // of this map is a performance optimization).
- void
- SgNode::clearGlobalMangledNameMap()
- {
- // Remove all elements from the globalMangledNameMap
- // p_globalMangledNameMap.erase(p_globalMangledNameMap.begin(),p_globalMangledNameMap.end());
- p_globalMangledNameMap.clear();
- // DQ (6/26/2007): The function types require the same mangled names be generated across
- // clears of the p_globalMangledNameMap cache. Clearing the short name map breaks this.
- // It might be that we don't want to clear the short name map to permit the same mangled
- // names to be regenerated. However, for the purposes of AST merge this is not a problem.
- // p_shortMangledNameCache.clear();
- }
- #if 0
- // DQ (3/12/2007): Not clear how to do this!
- SgName
- SgNode::lookupMangledName(const SgNode* node) const
- {
- string returnString;
- // DQ (3/12/2007): Experiment with mangled name map (caching for performance improvement)
- const SgName name = "__global__";
- SgGlobal* global = const_cast<SgGlobal*>(this);
- std::map<SgNode*,std::string>::iterator i = p_globalMangledNameMap.find(global);
- if (i != p_globalMangledNameMap.end())
- {
- return i->second.c_str();
- }
- else
- {
- p_globalMangledNameMap[global] = name;
- return name;
- }
- return SgName(returnString);
- }
- #endif
- // DQ (4/10/2006): These are the default virtual function definitions (each returns an error)
- void
- SgNode::addNewAttribute( std::string s, AstAttribute* a )
- {
- printf ("Error: calling SgNode::addNewAttribute(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- }
- void
- SgNode::setAttribute( std::string s, AstAttribute* a )
- {
- printf ("Error: calling SgNode::setAttribute(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- }
- AstAttribute*
- SgNode::getAttribute(std::string s) const
- {
- printf ("Error: calling SgNode::getAttribute(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- return NULL;
- }
- void
- SgNode::updateAttribute( std::string s, AstAttribute* a )
- {
- // formerly called: replace
- printf ("Error: calling SgNode::updateAttribute(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- }
- void
- SgNode::removeAttribute(std::string s)
- {
- printf ("Error: calling SgNode::removeAttribute(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- }
- bool
- SgNode::attributeExists(std::string s) const
- {
- printf ("Error: calling SgNode::attributeExists(%s) \n",s.c_str());
- ROSE_ASSERT(false);
- }
- int
- SgNode::numberOfAttributes() const
- {
- int returnValue = 0;
- return returnValue;
- }
- AstAttributeMechanism*
- SgNode::get_attributeMechanism() const
- {
- // DQ (4/10/2006): virtual function defined at the SgNode and redefined whereever there is
- // an AstAttributeMechanism defined! Note that there is no set function defined.
- return NULL;
- }
- void
- SgNode::set_attributeMechanism(AstAttributeMechanism* a)
- {
- // Nothing to do here, but we need this virtual function so that the correct access
- // function will be call on IR nodes where the AstAttributeMechanism is defined as
- // a data member.
- printf ("Error: SgNode::set_attributeMechanism(AstAttributeMechanism* a) has been called \n");
- ROSE_ASSERT(false);
- }
- #if 0
- void
- SgNode::print( std::ostream* os, /* 0 uses the default */
- int maxdepth) /* controlling function*/
- {
- Sg_print_info().reset(os, maxdepth);
- this->_print(0);
- }
- bool
- SgNode::_print(int depth) const
- {
- return Sg_print_info().output_class(this,sage_class_name(), depth + 1);
- }
- #endif
- #if 0
- //! implementation in base class - overridden by SgLocatedNode::directives(ostream&)
- void
- SgNode::directives(std::ostream& os)
- {
- // to be overridden by SgLocatedNode::directives(ostream&)
- }
- #endif
- #if 0
- void
- SgNode::unparse(SgUnparse_Info& info, std::ostream& os)
- {
- /* nothing to be done in general: only comments for statements*/
- directives(os);
- logical_unparse(info,os);
- }
- void
- SgNode::unparse_helper(SgUnparse_Info& info, std::ostream& os)
- {
- }
- void
- SgNode::logical_unparse(SgUnparse_Info& info, std::ostream& os)
- {
- }
- #endif
- void
- SgNode::post_construction_initialization()
- {
- // default implementation does nothing!
- }
- // DQ (7/23/2005): Let these be automatically generated by ROSETTA!
- // See note above where these are proptotyped, they have to be defined
- // explicitly to avoid endless recursion!
- void
- SgNode::set_isModified ( bool isModified)
- {
- p_isModified = isModified;
- }
-
- bool
- SgNode::get_isModified () const
- {
- return p_isModified;
- }
-
- bool
- SgNode::get_isVisited () const
- {
- // The p_isVisited flag has been removed, it is an error to call this function.
- assert (this != NULL);
- printf ("Error: The p_isVisited flag has been removed, it is an error to call this function (get_isVisited). \n");
- ROSE_ASSERT(false);
- return true;
- }
- void
- SgNode::set_isVisited ( bool isVisited )
- {
- // The p_isVisited flag has been removed, it is an error to call this function.
- assert (this != NULL);
- printf ("Error: The p_isVisited flag has been removed, it is an error to call this function (set_isVisited). \n");
- ROSE_ASSERT(false);
- set_isModified(true);
- // p_isVisited = isVisited;
- /* */
- }
- // ! Permits specification of parent node (connects the AST tree)
- /* ! This function is called internally to connect the elements of the grammar to form the AST.
- */
- void
- SgNode::set_parent ( SgNode* parent )
- {
- // ROSE_ASSERT (parent != NULL); // QY: should allow setting parent to NULL when detaching SgNodes
- // DQ (9/24/2004): Enforce this simple rule!
- ROSE_ASSERT(this != NULL);
- ROSE_ASSERT(this != parent);
- // printf ("In SgNode::set_parent(): Setting parent of %p = %s to %p = %s \n",this,class_name().c_str(),parent,parent->class_name().c_str());
- p_parent = parent;
- // ROSE_ASSERT( ( this != (SgNode*)(0xb484411c) ) || ( parent != (SgNode*)(0xb46fe008) ) );
- // I think this should be always be true, so let's inforce it (this happends for test2005_64.C)
- if ( ( variantT() == V_SgClassDeclaration ) && ( parent->variantT() == V_SgFunctionParameterList ) )
- {
- printf ("Warning: Found case in set_parent() where this is a SgClassDeclaration and parent is a SgFunctionParameterList \n");
- // get_file_info()->display("Warning: Found case in set_parent() where this is a SgClassDeclaration and parent is a SgFunctionParameterList");
- }
- // ROSE_ASSERT( ( variantT() != V_SgClassDeclaration ) || ( parent->variantT() != V_SgFunctionParameterList ) );
- // We should not be setting the parent on SgType IR nodes
- ROSE_ASSERT( isSgType(this) == NULL );
- }
- /*! \brief Set the parent node.
- This function is called internally to connect the elements of the grammar to form the
- AST. This is the backward reference up the tree.
- \internal We can't have ROSETTA build these access functions since we want specific
- checking of values for NULL pointers (parent point is NULL only for SgProject)
- */
- SgNode*
- SgNode::get_parent () const
- {
- ROSE_ASSERT(this != NULL);
- SgNode* returnNode = p_parent;
- // DQ (5/24/2006): I would like to allow SgSymbols to have a valid parent pointer since it can be used to reference
- // the symbol table as a way to support better debugging within the AST merge mechanims.
- // Sage II semantics: Types and Symbols always have a NULL parent (This is the way it is implemented (from Sage II))
- // if ( (isSgType( const_cast<SgNode*>(this) ) != NULL) || (isSgSymbol( const_cast<SgNode*>(this) ) != NULL) )
- if ( isSgType( const_cast<SgNode*>(this) ) != NULL )
- returnNode = NULL;
- return returnNode;
- }
- // DQ (3/8/2007): Added more efficent implementation to support AST consitency tests and other work.
- //! Query function for if the input IR nodes is a child of the current IR node.
- bool
- SgNode::isChild ( SgNode* node ) const
- {
- return (getChildIndex(node) != -1);
- }
- vector<string>
- SgNode::buildCommandLineToSubstituteTransformationFile( const vector<string>& argv, std::string newFileName )
- {
- int fileNameCounter = 0;
- int fileNameLocation = 0;
- // return a copy of the commandline input to this function
- vector<string> transformation_argv(argv.size());
- // printf ("In buildCommandLineToSubstituteTransformationFile(): argc = %d \n",argc);
- // copy all the entries in the command line.
- for (unsigned int i=0; i < argv.size(); i++)
- {
- // Count up the number of filenames (if it is ZERO then this is likely a link line called
- // using the compiler (required for template processing in C++ with most compilers) if there
- // is ONE then this is the source file. Currently their can only be ONE source file specified.
- // most options appear as -<option>
- // have to process +w2 (warnings option) on some compilers so include +<option>
- if ( argv[i].size() < 1 || (argv[i][0] != '-') || (argv[i][0] != '+') )
- {
- unsigned int length = argv[i].size();
- // printf ("Look for file names: argv[%d] = %s length = %d \n",i,argv[i],length);
- // look only for .c and .C files (source code files)
- // The length has to be greater then 2 or else we will generate a purify error!
- if ( (length > 2) && (argv[i][length-2] == '.') && ( (argv[i][length-1] == 'c') || (argv[i][length-1] == 'C') ) )
- {
- // printf ("Found a filename = %s \n",argv[i]);
- // ROSE::sourceFileNamesWithPath [fileNameCounter] = strdup(argv[i]);
- // ROSE::sourceFileNamesWithoutPath [fileNameCounter] = strdup(argv[i]);
- // argv[i] = "rose_transformation.C";
- // transformation_argv[i] = "rose_transformation.C";
- transformation_argv[i] = strdup(newFileName.c_str());
- // record the location of the filename in the command line and the number of filenames
- fileNameLocation = i;
- fileNameCounter++;
- }
- else
- {
- transformation_argv [i] = argv[i];
- }
- }
- else
- {
- transformation_argv [i] = argv[i];
- }
- // printf ("In loop: i = %d \n",i);
- }
- // For now ets only debug the case of a single file specified on the command line
- ROSE_ASSERT (fileNameCounter == 1);
- ROSE_ASSERT (fileNameLocation > 0);
- // We have found the location of the filename in the command line (now modify it)
- // now delete the original file name
- // delete argv[fileNameLocation];
- // argv[fileNameLocation] = "rose_transformation.C";
- // argv[fileNameLocation] = "/home/dquinlan/ROSE/NEW_ROSE/TransformationSpecification/rose_transformation.C";
- // argv[fileNameLocation] = "/home/dquinlan2/ROSE/SUN_CC_NOPURIFY/TransformationSpecification/rose_transformation.C";
- // argv[fileNameLocation] = "rose_transformation.C";
- #if 0
- // This is not longer required (EDG sets its
- // primary_source_file_name internally from the
- // command line directly).
- // Since it is a problem to call EDG more than once with
- // (EDG comand line processing can only be called once)
- // the easiest thing to do is change the name of the primary
- // source file. See notes in the TODO document.
- EDG_secondarySourceFile = argv[fileNameLocation];
- #endif
- // printf ("Command line modified to include \"rose_transformation.C\"! \n");
- return transformation_argv;
- }
- std::string
- SgNode::unparseToString(SgUnparse_Info* info) const
- {
- // DQ (4/4/2006): Added optional parameter to customize unparsing
- // Generate the string (don't pass a SgUnparse_Info object so that we can use the
- // default settings).
- std::string outputString = globalUnparseToString(this,info);
- return outputString;
- }
- std::string
- SgNode::unparseToCompleteString()
- {
- // Generate the string (pass a SgUnparse_Info object)
- SgUnparse_Info* inputUnparseInfoPointer = new SgUnparse_Info();
- inputUnparseInfoPointer->unset_SkipComments(); // generate comments
- inputUnparseInfoPointer->unset_SkipWhitespaces(); // generate all whitespaces to format the code
- std::string outputString = globalUnparseToString(this,inputUnparseInfoPointer);
- return outputString;
- }
- // DQ (10/8/2007): I would like to get rid of this mechanism in the future.
- SgShallowCopy *SgShallowCopy::p_static_instance = NULL;
- SgTreeCopy *SgTreeCopy ::p_static_instance = NULL;
- void
- SgCopyHelp::insertCopiedNodePair( const SgNode* key, SgNode* value )
- {
- // DQ (10/8/2007): This function support the saving of state used to associated original IR nodes with the copies made of them so that symbols can be updated.
- if (copiedNodeMap.find(key) == copiedNodeMap.end())
- {
- // Add the node to the map...
- copiedNodeMap[key] = value;
- }
- }
- SgNode*
- SgTreeCopy::copyAst( const SgNode *n )
- {
- #if 0
- if (isSgType( const_cast<SgNode*>(n) ) != NULL)
- {
- return const_cast<SgNode *>(n);
- }
- SgNode *nCopy = n->copy(*this);
- nCopy->set_parent(NULL);
- return nCopy;
- #else
- // DQ (10/8/2007): I have modified this function to have a single return.
- // This function is called by the copy mechanism to copy AST child trees.
- SgNode *nCopy = NULL;
- // If this is a SgType, then force it to be shared, since all SgTypes are shared.
- // if (isSgType( const_cast<SgNode*>(n) ) != NULL)
- if (isSgType(n) != NULL)
- {
- // Share the reference to the IR node.
- nCopy = const_cast<SgNode *>(n);
- }
- else
- {
- // If this is a class definition then only do a deep copy if it is from a defining class declaration.
- const SgClassDefinition* classDefinition = isSgClassDefinition(n);
- if (classDefinition != NULL)
- {
- ROSE_ASSERT(classDefinition->get_parent() != NULL);
- SgClassDeclaration* classDeclaration = isSgClassDeclaration(classDefinition->get_parent());
- if (classDeclaration == classDeclaration->get_definingDeclaration())
- {
- // Do a deep copy on this IR node.
- nCopy = n->copy(*this);
- }
- else
- {
- // Share the reference to the IR node.
- nCopy = const_cast<SgNode *>(n);
- }
- }
- else
- {
- // Do a deep copy on this IR node.
- nCopy = n->copy(*this);
- }
- // Set the parent to NULL, the copy mechanism we set it correctly ...
- nCopy->set_parent(NULL);
- }
- return nCopy;
- #endif
- }
- #if 0
- bool SgTreeCopy :: clone_node( const SgNode *n ) const
- {
- if (isSgType( const_cast<SgNode*>(n) ) != 0)
- return false;
- return true;
- }
- #endif
- unsigned int
- SgNode::cfgIndexForEnd() const {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return 0;
- }
- bool
- SgNode::cfgIsIndexInteresting(unsigned int) const {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return false;
- }
- unsigned int
- SgNode::cfgFindChildIndex(SgNode*) {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return 0;
- }
- unsigned int
- SgNode::cfgFindNextChildIndex(SgNode*) {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return 0;
- }
- std::vector<VirtualCFG::CFGEdge>
- SgNode::cfgOutEdges(unsigned int) {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return std::vector<VirtualCFG::CFGEdge>();
- }
- std::vector<VirtualCFG::CFGEdge>
- SgNode::cfgInEdges(unsigned int) {
- ROSE_ASSERT (!"CFG functions only work on SgExpression, SgStatement, and SgInitializedName");
- return std::vector<VirtualCFG::CFGEdge>();
- }
-
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1362 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- bool SgNode::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != NodeTag)
- {
- printf ("Error in SgNode::error(): SgNode object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgNode::error() \n");
- ROSE_ABORT();
- }
- // ROSE_ASSERT (getVariant() == SgNodeTag);
- ROSE_ASSERT (getVariant() == NodeTag);
- return false; // //::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgNode::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgNode::variant() const \n");
- #endif
- assert(this != NULL);
- return NodeTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgNode* isSgNode ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgNode*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgNode* isSgNode ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgNode*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgNode::~SgNode ()
- {
- #if 0
- // debugging information!
- printf ("In SgNode::~SgNode (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- // case: not a listType for parent
- p_parent = NULL; // non list case
- // case: not a listType for isModified
- p_isModified = false; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarConstructorDefinitionMacros.macro"
- // Generated constructor
- SgNode::SgNode ( )
-
- {
- #ifdef DEBUG
- // printf ("In SgNode::SgNode () sage_class_name() = %s \n",sage_class_name());
- #endif
- p_parent = NULL;
- p_isModified = false;
- p_freepointer = AST_FileIO::IS_VALID_POINTER();
- #line 11 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarConstructorDefinitionMacros.macro"
- // Test the variant virtual function
- assert(NodeTag == variant());
- post_construction_initialization();
- // Test the isSgNode() function since it has been problematic
- assert(isSgNode(this) != NULL);
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- #line 3893 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- // No functions defined for the GrammarSource
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgSupport::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgSupport::variantT() const {
- return V_SgSupport;
- }
- #if 0
- int
- SgSupport::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return SupportTag;
- }
- #endif
- const char*
- SgSupport::sage_class_name() const
- {
- assert(this != NULL);
- return "SgSupport";
- }
- std::string
- SgSupport::class_name() const
- {
- assert(this != NULL);
- return "SgSupport";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgSupport::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- SgSupport::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != SupportTag)
- {
- printf ("Error in SgSupport::error(): SgSupport object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgSupport::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == SupportTag);
- return SgNode::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgSupport::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgSupport::variant() const \n");
- #endif
- assert(this != NULL);
- return SupportTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgSupport* isSgSupport ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgSupport*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgSupport* isSgSupport ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgSupport*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgSupport::~SgSupport ()
- {
- #if 0
- // debugging information!
- printf ("In SgSupport::~SgSupport (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarConstructorDefinitionMacros.macro"
- // Generated constructor
- SgSupport::SgSupport ( )
- : SgNode()
- {
- #ifdef DEBUG
- // printf ("In SgSupport::SgSupport () sage_class_name() = %s \n",sage_class_name());
- #endif
- // Test the variant virtual function
- assert(SupportTag == variant());
- post_construction_initialization();
- // Test the isSgSupport() function since it has been problematic
- assert(isSgSupport(this) != NULL);
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 7362 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- // Added to support assignments to string variables.
- SgName::operator std::string () const
- {
- return p_char;
- }
- // DQ (10/5/2007): We no longer need this!
- // Definition of defaultName (use a default parameter)
- // const SgName SgdefaultName("defaultName");
- SgName::SgName()
- : p_char("")
- { }
- unsigned int
- SgName::get_length() const
- {
- ROSE_ASSERT(this != NULL);
- return p_char.size();
- }
- SgName::SgName(const char * str): p_char(str ? str : "") {}
- // DQ (9/9/2004): Added support for conversion of strings to SgName
- // I always wanted this and it was a pain that it didn't exist previously!
- SgName::SgName(const std::string & str): p_char(str) {}
- SgName::SgName(const SgName& n): p_char(n.p_char) {}
- // SgName::SgName(const char *str, int n): p_char(str, n) {} // get first n chars in the string
- int
- SgName::operator!=(const SgName& n1) const
- {
- ROSE_ASSERT(this != NULL);
- return p_char != n1.p_char;
- }
- int
- SgName::operator==(const SgName& n1) const
- {
- ROSE_ASSERT(this != NULL);
- return p_char == n1.p_char;
- }
- int
- SgName::operator<(const SgName& n1) const
- {
- ROSE_ASSERT(this != NULL);
- return p_char < n1.p_char;
- }
- int
- SgName::is_null(void) const
- {
- ROSE_ASSERT(this != NULL);
- return p_char.empty();
- }
- void
- SgName::replace_space(char t)
- {
- ROSE_ASSERT(this != NULL);
- int len = p_char.size();
- for(int i=0; i < len; i++)
- {
- // if last one
- if(p_char[i]==' ')
- {
- if(i==len-1)
- p_char.resize(p_char.size() - 1);
- else
- p_char[i]=t;
- }
- }
- }
- SgName&
- SgName::operator<<(const std::string& str)
- {
- ROSE_ASSERT (this != NULL);
- p_char += str;
- return *this;
- }
- SgName
- SgName::itoname(int val)
- {
- std::ostringstream os;
- os << val;
- return SgName(os.str());
- }
- SgName&
- SgName::operator<<(int val)
- {
- ROSE_ASSERT(this != NULL);
- SgName str = itoname(val);
- p_char += str.p_char;
- return *this;
- }
- SgName&
- SgName::operator=(const SgName& n1)
- {
- ROSE_ASSERT(this != NULL);
- this->p_char = n1.p_char;
- return *this;
- }
- SgName&
- SgName::tail(int n) // keep string after n
- {
- ROSE_ASSERT(this != NULL);
- p_char = (unsigned int)n >= p_char.size() ? "" : p_char.substr(n);
- return *this;
- }
- SgName&
- SgName::head(int n) // keep first n chars
- {
- ROSE_ASSERT(this != NULL);
- p_char = (unsigned int)n >= p_char.size() ? p_char : p_char.substr(0, n);
- return *this;
- }
- const char* SgName::str() const {
- ROSE_ASSERT(this != NULL);
- return p_char.c_str();
- }
- std::string&
- SgName::getString()
- {
- ROSE_ASSERT(this != NULL);
- return p_char;
- }
- const std::string&
- SgName::getString() const
- {
- ROSE_ASSERT(this != NULL);
- return p_char;
- }
- #if 0
- // Removed to prevent confusion about it's used (really should not be a const function)
- SgName::operator char*() const
- {
- return p_char;
- }
- #endif
- // default name to use within initializers for SgName objects
- // const SgName defaultName;
- void SgName::display( const std::string& label ) const
- {
- ROSE_ASSERT(this != NULL);
- std::cout << label << ": " << p_char << "\n";
- }
- // DQ (9/9/2004): friend function
- SgName
- operator+(const SgName & n1, const SgName & n2)
- {
- return SgName(n1.p_char + n2.p_char);
- }
- // DQ (11/15/2004): Added to support general string operations (first used in the unparser)
- SgName &
- SgName::operator+= (const SgName & n1)
- {
- ROSE_ASSERT(this != NULL);
- p_char += n1.p_char;
- return *this;
- }
- SgName
- SgName::assembleQualifiedName(const SgName & scopeQualifiedName, const SgName & localName)
- {
- // DQ (22/2005): Neede to add global scope specifier to handle some pathological cases (see test2005_144.C).
- // DQ (9/9/2004): Supporting function for building qualified names (specialied string concatination)
- // Previous code caused "::" to be inserted too often (e.g. where scope->get_qualified_name() was empty, as in global scope)
- // returnName = scope->get_qualified_name() << "::" << get_name().str();
- // DQ (9/9/2004): We can't assert this since "" evaluates to is_null() being true!
- // ROSE_ASSERT(scopeQualifiedName.is_null() == false);
- SgName returnName;
- // DQ (9/9/2004): So these are redundent tests! (which was pleasant news to me!)
- // if ( (scopeQualifiedName.is_null() == true) || (scopeQualifiedName == "") )
- if ( (scopeQualifiedName.is_null() == true) || (scopeQualifiedName.getString() == "") )
- {
- returnName = localName;
- #if 0
- // DQ (11/29/2004): It seems that any assignment of "" to a SgName forces it to be evaluated so that is_null() == true
- // DQ (11/29/2004): Added checking for is_null() so that returnName would always be a valid name
- if (localName.is_null() == true)
- returnName = "";
- else
- returnName = localName;
- #endif
- }
- else
- {
- // Trap out the case of global scope to avoid building "::::"
- if ( scopeQualifiedName == "::" )
- {
- // Avoid building "::::"
- returnName = scopeQualifiedName.getString() + localName.getString();
- }
- else
- {
- returnName = scopeQualifiedName.getString() + "::" + localName.getString();
- }
- }
- // returnName = scopeQualifiedName << "::" << localName.str();
- // ROSE_ASSERT(returnName.is_null() == false);
-
- return returnName;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgName::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgName::variantT() const {
- return V_SgName;
- }
- #if 0
- int
- SgName::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return NameTag;
- }
- #endif
- const char*
- SgName::sage_class_name() const
- {
- assert(this != NULL);
- return "SgName";
- }
- std::string
- SgName::class_name() const
- {
- assert(this != NULL);
- return "SgName";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgName::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- SgName::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != NameTag)
- {
- printf ("Error in SgName::error(): SgName object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgName::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == NameTag);
- return SgSupport::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgName::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgName::variant() const \n");
- #endif
- assert(this != NULL);
- return NameTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgName* isSgName ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgName*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgName* isSgName ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgName*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgName::~SgName ()
- {
- #if 0
- // debugging information!
- printf ("In SgName::~SgName (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- // case: not a listType for char
- p_char = ""; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgName
- SgSymbolTable::get_name () const
- {
- assert (this != NULL);
- return p_name;
- }
- void
- SgSymbolTable::set_name ( SgName name )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_name = name;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgSymbolTable::get_no_name () const
- {
- assert (this != NULL);
- return p_no_name;
- }
- void
- SgSymbolTable::set_no_name ( bool no_name )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_no_name = no_name;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- rose_hash_multimap*
- SgSymbolTable::get_table () const
- {
- assert (this != NULL);
- return p_table;
- }
- void
- SgSymbolTable::set_table ( rose_hash_multimap* table )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_table != NULL && table != NULL && p_table != table)
- {
- printf ("Warning: table = %p overwriting valid pointer p_table = %p \n",table,p_table);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_table != NULL && table != NULL && p_table != table) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_table = table;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgNodeSet
- SgSymbolTable::get_symbolSet () const
- {
- assert (this != NULL);
- return p_symbolSet;
- }
- void
- SgSymbolTable::set_symbolSet ( SgNodeSet symbolSet )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_symbolSet = symbolSet;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 3898 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- // DQ (2/19/2007): Added mechanism to turn off expensive error checking!
- #define SYMBOL_TABLE_ERROR_CHECKING 1
- // DQ (7/24/2005): Make this a constant in the function if it is not used elsewhere!
- // #define SYMTBL_INIT_SZ 16
- SgSymbolTable::SgSymbolTable()
- : p_no_name(true)
- {
- // This should always be a non-null pointer (and never shared)!
- int symbolTableSize = 17;
- p_table = new BaseHashType(symbolTableSize);
- ROSE_ASSERT (p_table != NULL);
- }
- // DQ (2/19/2007): I have put it back into use as a way of
- // customizing the size of the underlying hash tables to be
- // larger for certain scopes (e.g global scope usually has a
- // lot more symbols.
- // DQ (1/31/2007): This function is not used!
- SgSymbolTable::SgSymbolTable(int symbolTableSize)
- : p_no_name(true)
- {
- // This should always be a non-null pointer (and never shared)!
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- // p_table = new SgSymbolHashMultiMap(sz);
- p_table = new BaseHashType(symbolTableSize);
- ROSE_ASSERT (p_table != NULL);
- }
- std::ostream & operator<< ( std::ostream & os, const rose_hash_multimap::iterator & rhm_it )
- {
- // DQ (1/19/2006): Error reported by Michelle Strout when compiled with g++ 4.0.2 on 64 bit machines
- // os << " pair (" << (*rhm_it).first.str() << "," << (int)((*rhm_it).second) << ")";
- os << " pair (" << (*rhm_it).first.str() << "," << ((*rhm_it).second) << ")";
- return os;
- }
- SgName
- SgSymbolTable::get_name( const SgNode* node) const
- {
- // DQ (2/20/2007): This function is used to get the name for the different types of declarations used to build symbols.
- SgName name;
- switch (node->variantT())
- {
- // We could implement a function on the selective nodes that generated the symbol
- // name (the name used for the input of associated symbols in the symbol table).
- case V_SgLabelStatement:
- {
- const SgLabelStatement* labelStatement = isSgLabelStatement(node);
- name = labelStatement->get_label();
- break;
- }
- case V_SgClassDeclaration:
- case V_SgDerivedTypeStatement:
- {
- const SgClassDeclaration* classDeclaration = isSgClassDeclaration(node);
- name = classDeclaration->get_name();
- break;
- }
- case V_SgTemplateInstantiationDecl:
- {
- const SgTemplateInstantiationDecl* templateInstantiationDeclaration = isSgTemplateInstantiationDecl(node);
- // Note that get_name() returns a name with arguments such as "class_template<int>" while get_templateName() returns the template name withouth arguments.
- // name = templateInstantiationDeclaration->get_templateName();
- // printf ("In SgSymbolTable::find(const SgStatement*): case V_SgTemplateInstantiationDecl, using get_name() = %s instead of get_templateName() = %s \n",
- // templateInstantiationDeclaration->get_name().str(),templateInstantiationDeclaration->get_templateName().str());
- // printf ("Base class get_name() = %s \n",templateInstantiationDeclaration->SgClassDeclaration::get_name().str());
- name = templateInstantiationDeclaration->get_name();
- break;
- }
- case V_SgEnumDeclaration:
- {
- const SgEnumDeclaration* enumDeclaration = isSgEnumDeclaration(node);
- name = enumDeclaration->get_name();
- break;
- }
- case V_SgFunctionDeclaration:
- case V_SgProgramHeaderStatement:
- case V_SgProcedureHeaderStatement:
- case V_SgMemberFunctionDeclaration:
- {
- const SgFunctionDeclaration* functionDeclaration = isSgFunctionDeclaration(node);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- name = functionDeclaration->get_name();
- break;
- }
- // DQ (2/14/2007): Note that for template-based declarations there is a process where within the post-processing of
- // the AST the names are updated from the EDG form (e.g. "template_name___Lnnn"), to the template specialization
- // form (e.g. "template_name<int>"). Since the symbol references only one of the declarations, if there are defining
- // declarations and non-defining declarations, the name can be changed in the declaration but not in the associated symbol.
- // Details of this situation require more clarification.
- case V_SgTemplateInstantiationFunctionDecl:
- {
- const SgTemplateInstantiationFunctionDecl* functionDeclaration = isSgTemplateInstantiationFunctionDecl(node);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- // DQ (2/14/2007): The name used to insert symbols into the symbol table is the one returned by get_name(),
- // get_templateName returns the name of the template which is required for code generation (where for
- // functions the specialization is not required or not allowed).
- // name = functionDeclaration->get_templateName();
- name = functionDeclaration->get_name();
- break;
- }
- case V_SgTemplateInstantiationMemberFunctionDecl:
- {
- const SgTemplateInstantiationMemberFunctionDecl* functionDeclaration = isSgTemplateInstantiationMemberFunctionDecl(node);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- // DQ (2/14/2007): The name used to insert symbols into the symbol table is the one returned by get_name(),
- // get_templateName returns the name of the template which is required for code generation (where for
- // functions the specialization is not required or not allowed).
- // name = functionDeclaration->get_templateName();
- name = functionDeclaration->get_name();
- break;
- }
- case V_SgNamespaceDeclarationStatement:
- {
- const SgNamespaceDeclarationStatement* namespaceDeclarationStatement = isSgNamespaceDeclarationStatement(node);
- name = namespaceDeclarationStatement->get_name();
- break;
- }
- case V_SgTemplateDeclaration:
- {
- const SgTemplateDeclaration* templateDeclaration = isSgTemplateDeclaration(node);
- name = templateDeclaration->get_name();
- break;
- }
- case V_SgTypedefDeclaration:
- {
- const SgTypedefDeclaration* typedefDeclaration = isSgTypedefDeclaration(node);
- name = typedefDeclaration->get_name();
- break;
- }
- case V_SgFunctionType:
- {
- const SgFunctionType* functionType = isSgFunctionType(node);
- name = functionType->get_mangled();
- break;
- }
- case V_SgInitializedName:
- {
- const SgInitializedName* initializedName = isSgInitializedName(node);
- name = initializedName->get_name();
- break;
- }
- default:
- {
- printf ("SgSymbolTable::get_name(SgNode*) undefined for %s \n",node->class_name().c_str());
- ROSE_ASSERT(false);
- }
- }
- return name;
- }
- #if 0
- // DQ (3/10/2007): This approach in the end, didn't work. So I think this can be removed!
- // What about the variations for defining vs. first non-defining declarations
- // we could match up the different types of declarations!
- unsigned int
- SgSymbolTable::generateUniqueNumberForMatchingSymbol( SgDeclarationStatement* symbolBasis ) const
- {
- // DQ (2/20/2007): This function supports the AST merge mechansim, but is general
- // and may be useful for the mangled name generation in the future. For symbols
- // in the symbol table for a specific scope that have matching names (typically
- // originating as un-named structs or enums) this function requires a unique number
- // for each instance.
- #if 1
- printf ("In SgSymbolTable::generateUniqueNumberForMatchingSymbol() symbolBasis = %p \n",symbolBasis);
- #endif
- ROSE_ASSERT(p_table != NULL);
- SgName nm = get_name(symbolBasis);
- unsigned int counter = 0;
- hash_iterator p_iterator = p_table->find(nm);
- ROSE_ASSERT(symbolBasis != NULL);
- SgDeclarationStatement* symbolBasisDefiningDeclaration = symbolBasis->get_definingDeclaration();
- SgDeclarationStatement* symbolBasisNondefiningDeclaration = symbolBasis->get_firstNondefiningDeclaration();
- ROSE_ASSERT(symbolBasisDefiningDeclaration != NULL);
- ROSE_ASSERT(symbolBasisNondefiningDeclaration != NULL);
- // loop over all symbols of the same name
- while (p_iterator != p_table->end() && p_iterator->first == nm)
- {
- // only count matching symbol types (with the same name)
- if ( p_iterator->second->get_symbol_basis()->variantT() == symbolBasis->variantT() )
- {
- // return the count when we have found the symbol basis (or matching of it's defining or nondefining declarations)
- SgDeclarationStatement* tmp_symbolBasis = isSgDeclarationStatement(p_iterator->second->get_symbol_basis());
- ROSE_ASSERT(tmp_symbolBasis != NULL);
- // Exit loop on condition of definingDeclaration
- if (symbolBasisDefiningDeclaration != NULL)
- {
- SgDeclarationStatement* tmp_symbolBasisDefiningDeclaration = tmp_symbolBasis->get_definingDeclaration();
- ROSE_ASSERT(tmp_symbolBasisDefiningDeclaration != NULL);
- if (symbolBasisDefiningDeclaration == tmp_symbolBasisDefiningDeclaration)
- break;
- }
- // Exit loop on condition of firstNondefiningDeclaration
- if (symbolBasisNondefiningDeclaration != NULL)
- {
- SgDeclarationStatement* tmp_symbolBasisNondefiningDeclaration = tmp_symbolBasis->get_firstNondefiningDeclaration();
- ROSE_ASSERT(tmp_symbolBasisNondefiningDeclaration != NULL);
- if (symbolBasisNondefiningDeclaration == tmp_symbolBasisNondefiningDeclaration)
- break;
- }
- }
- counter++;
- p_iterator++;
- }
- #if 1
- printf ("Leaving SgSymbolTable::generateUniqueNumberForMatchingSymbol() = %d \n",counter);
- #endif
- return counter;
- }
- #endif
- /* ************************************************************************
- INSERT FUNCTIONS
- ************************************************************************/
- void
- SgSymbolTable::insert ( const SgName & nm , SgSymbol *sp )
- {
- // DQ (2/14/2007): Added assertion!
- ROSE_ASSERT(this != NULL);
- // DQ (2/19/2007): Added additional assertion!
- ROSE_ASSERT (p_table != NULL);
- // DQ (2/14/2007): Added assertion!
- ROSE_ASSERT (sp != NULL);
- #if 0
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // SgFunctionTypeSymbol does not have a valid get_symbol_basis(), so skip this case!
- if (isSgFunctionTypeSymbol(sp) == NULL)
- {
- if (sp->get_symbol_basis() == NULL)
- {
- printf ("Error (sp->get_symbol_basis() == NULL): name = %s sp = %p = %s \n",nm.str(),sp,sp->class_name().c_str());
- }
- ROSE_ASSERT(sp->get_symbol_basis() != NULL);
- #if 0
- // This outputs a message for every use of the insert function (for non function type symbols) useful for tracing through bugs
- printf ("In SgSymbolTable::insert(%s,%p) into SgSymbolTable = %p = %s of scope = %p = %s sp = %p = %s sp->get_symbol_basis() = %p = %s \n",
- nm.str(),sp,this,this->class_name().c_str(),this->get_parent(),this->get_parent()->class_name().c_str(),
- sp,sp->class_name().c_str(),sp->get_symbol_basis(),sp->get_symbol_basis()->class_name().c_str());
- #endif
- }
- #endif
- // DQ (3/10/2007): This is a simpler assertion equivalent to the one above but without generating any error output
- ROSE_ASSERT(isSgFunctionTypeSymbol(sp) != NULL || sp->get_symbol_basis() != NULL);
- // DQ (3/10/2007): Test for if the symbol exists
- ROSE_ASSERT (p_symbolSet.find(sp) == p_symbolSet.end());
- #if 0
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // DQ (2/19/2007): These is no need to do both of these since exists(sp) is more complete test!
- // DQ (2/25/2007): except that it is helpful to know which one fails.
- ROSE_ASSERT(exists(nm,sp) == false);
- ROSE_ASSERT(exists(sp) == false);
- // DQ (2/14/2007): error checking (make sure that no two symbols are represented by the same basis declaration).
- // But skip such tests on the SgFunctionTypeSymbol (only used for the function type table)
- if (isSgFunctionTypeSymbol(sp) == NULL)
- {
- // set<SgNode*> existingSymbolBasisDeclarations;
- map<SgNode*, hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator > existingSymbolBasisDeclarations;
- SgNode* sp_associatedDeclaration = sp->get_symbol_basis();
- ROSE_ASSERT(sp_associatedDeclaration != NULL);
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator i = get_table()->begin();
- while (i != get_table()->end())
- {
- // test if symbol is in set
- SgNode* associatedDeclaration = i->second->get_symbol_basis();
- ROSE_ASSERT(associatedDeclaration != NULL);
- // Check if this declaration has previously been used with another symbol!
- if (existingSymbolBasisDeclarations.find( sp_associatedDeclaration ) == existingSymbolBasisDeclarations.end())
- {
- // Add this declaration to the list associated with symbols in the table
- // existingSymbolBasisDeclarations.insert( associatedDeclaration );
- existingSymbolBasisDeclarations[associatedDeclaration] = i;
- }
- else
- {
- printf ("Error in symbol table located in parent = %p = %s \n",get_parent(),get_parent()->class_name().c_str());
- ROSE_ASSERT(get_parent() != NULL);
- get_parent()->get_file_info()->display("Error in symbol table");
- string associatedDeclarationName = SageInterface::get_name(sp_associatedDeclaration);
- // DQ (2/15/2007): Output the name of the symbol being inserted, the declaration associated with it,
- // and the name of the symbol previously inserted with the same associated declaration.
- printf ("Symbol sp = %p = %s already associated with declaration = %p = %s (name = %s) in symbol table i = %p = %s \n",
- sp,sp->class_name().c_str(),sp_associatedDeclaration,sp_associatedDeclaration->class_name().c_str(),
- associatedDeclarationName.c_str(),existingSymbolBasisDeclarations[sp_associatedDeclaration]->second,existingSymbolBasisDeclarations[sp_associatedDeclaration]->second->class_name().c_str());
- associatedDeclaration->get_file_info()->display("Dual use of associatedDeclaration in source: debug");
- printf ("existingSymbolBasisDeclarations[sp_associatedDeclaration]->first = %s second = %p \n",
- existingSymbolBasisDeclarations[sp_associatedDeclaration]->first.str(),
- existingSymbolBasisDeclarations[sp_associatedDeclaration]->second);
- ROSE_ASSERT(false);
- }
- i++;
- }
- }
- #endif
- // Now, finally insert it into the symbol table
- // std::pair<const SgName,SgSymbol*> npair(nm,sp);
- // p_table->insert(npair);
- p_table->insert(std::pair<const SgName,SgSymbol*>(nm,sp));
- // DQ (5/11/2006): set the parent to avoid NULL pointers
- sp->set_parent(this);
- // DQ (3/10/2007): Insert this symbol into p_symbolSet which we use for fast tests of existance in the
- // symbol table when we don't use the name. This helps detect where symbols have been entered using one
- // name and either reentered using an second name or the name changed and the symbol had not been properly
- // unloaded and reloaded into the symbol table. Since the names are not stored in the symbol, but computed
- // from associated declaration this is an easy error to make and we detect this by backing up the test for
- // if a symbol exists using a name with a test for if the symbol exists using ANY possible name (a search
- // for the symbol independent of the name). To avoid this being a linear search of the symbol table (too
- // slow) we implement a set of symbols to permit fast tests for existence.
- p_symbolSet.insert(sp);
- #if 0
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // Error checking
- ROSE_ASSERT(exists(nm) == true);
- ROSE_ASSERT(exists(nm,sp) == true);
- ROSE_ASSERT(exists(sp) == true);
- #endif
- #if 0
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // DQ (2/14/2007): Added error checking!
- if (nm != sp->get_name())
- {
- printf ("Warning: symbol name does not match name used to input associated symbol into symbol table! sp = %p = %s nm = \"%s\" sp->get_name() = \"%s\" \n",sp,sp->class_name().c_str(),nm.str(),sp->get_name().str());
- ROSE_ASSERT(sp->get_symbol_basis() != NULL);
- ROSE_ASSERT(sp->get_symbol_basis()->get_file_info() != NULL);
- sp->get_symbol_basis()->get_file_info()->display("Error in source: debug");
- ROSE_ASSERT(false);
- }
- #endif
- #if 0
- // We can't test this because where symbols are inserted (EDG/SageIII translation) the scopes are not set yet (done in AST post-processing).
- // DQ (2/14/2007): Added error checking!
- SgStatement* statement = isSgStatement(sp->get_symbol_basis());
- if (statement != NULL)
- {
- // printf ("In loop: p_iterator->second = %p = %s statement = %p = %s \n",p_iterator->second,p_iterator->second->class_name().c_str(),statement,statement->class_name().c_str());
- // SgNode* symbolBasis = p_iterator->second->get_symbol_basis();
- SgSymbol* symbolFromTable = statement->get_symbol_from_symbol_table();
- ROSE_ASSERT(symbolFromTable != NULL);
- ROSE_ASSERT(symbolFromTable == sp);
- }
- else
- {
- SgInitializedName* initializedName = isSgInitializedName(sp->get_symbol_basis());
- if (initializedName != NULL)
- {
- // printf ("In loop: p_iterator->second = %p = %s statement = %p = %s \n",p_iterator->second,p_iterator->second->class_name().c_str(),statement,statement->class_name().c_str());
- // SgNode* symbolBasis = p_iterator->second->get_symbol_basis();
- SgSymbol* symbolFromTable = initializedName->get_symbol_from_symbol_table();
- ROSE_ASSERT(symbolFromTable != NULL);
- ROSE_ASSERT(symbolFromTable == sp);
- }
- else
- {
- printf ("Unknown symbol_base for input symbol sp = %p = %s sp->get_symbol_basis() = %p = %s \n",sp,sp->class_name().c_str(),sp->get_symbol_basis(),sp->get_symbol_basis()->class_name().c_str());
- ROSE_ASSERT(false);
- }
- }
- #endif
- }
- /* ************************************************************************
- REMOVE FUNCTIONS
- ************************************************************************/
- // DQ (2/6/2007): This is too dangerous for use in ROSE (deletes all
- // possible SgSymbols that match the input name independent of type).
- // It is however currently used in the global function type symbol table
- // so we have named this function to make its purpose more clear.
- // This function is not likely called except where complex function type
- // symbol table editing is required. Since SgFunctionTypeSymbols are
- // shared removing such symbols is a rather dangerous actvity!
- void
- SgSymbolTable::remove_function_type( const SgName & name )
- {
- // This is non-destructive (does not delete the symbol, only removes it from the symbol table).
- ROSE_ASSERT (p_table != NULL);
- list<hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator it = get_table()->find(name);
- while (it != get_table()->end() && (*it).first == name)
- {
- ROSE_ASSERT(it->second->variantT() == V_SgFunctionTypeSymbol);
- deleteList.push_back(it);
- it++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- // DQ (5/9/2007): Moved to after the call to "p_symbolSet.erase((*i)->second);"
- // Remove the existing symbol (associated with the function declaration we will be deleting from the AST.
- // printf ("Erasing symbol %p from symbol table %p in scope = %p \n",(*i)->second,this,this->get_parent());
- // get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase((*i)->second);
- // Remove the existing symbol (associated with the function declaration we will be deleting from the AST.
- // printf ("Erasing symbol %p from symbol table %p in scope = %p \n",(*i)->second,this,this->get_parent());
- get_table()->erase(*i);
- i++;
- }
- }
- SgSymbol*
- SgSymbolTable::find( const SgInitializedName* initializedName)
- {
- ROSE_ASSERT(p_table != NULL);
- ROSE_ASSERT(initializedName != NULL);
- // printf ("Inside of SgSymbolTable::find( const SgInitializedName* ): initializedName = %p = %s \n",initializedName,SageInterface::get_name(initializedName).c_str());
- SgSymbol* returnSymbol = NULL;
- SgName name = initializedName->get_name();
- // printf ("Inside of SgSymbolTable::find( const SgInitializedName* ): name = %s \n",name.str());
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- ROSE_ASSERT(p_iterator->second != NULL);
- SgNode* symbolBasis = p_iterator->second->get_symbol_basis();
- // printf ("In loop: p_iterator->second = %p symbolBasis = %p initializedName = %p \n",p_iterator->second,symbolBasis,initializedName);
- // printf ("In loop: symbolBasis->variantT() = %d statement->variantT() = %d \n",symbolBasis->variantT(),initializedName->variantT());
- ROSE_ASSERT(symbolBasis != NULL);
- if (isSgInitializedName(symbolBasis) != NULL)
- {
- // printf ("found a SgInitializedName \n");
- returnSymbol = p_iterator->second;
- if (returnSymbol->get_symbol_basis() == initializedName)
- {
- // printf ("returnSymbol->get_symbol_basis() == initializedName returnSymbol = %p = %s \n",returnSymbol,returnSymbol->class_name().c_str());
- return returnSymbol;
- }
- else
- {
- // printf ("returnSymbol->get_symbol_basis() != initializedName \n");
- }
- }
- else
- {
- // printf ("Some other symbol was found (no matching variants) \n");
- }
- p_iterator++;
- }
- // DQ (2/13/2007): Fixed bug that returns a valid pointer even when there was no match to the input statement!
- // return returnSymbol;
- return NULL;
- }
- SgSymbol*
- SgSymbolTable::find( const SgFunctionType* functionType)
- {
- ROSE_ASSERT(p_table != NULL);
- ROSE_ASSERT(functionType != NULL);
- // printf ("Inside of SgSymbolTable::find( const SgFunctionType* ): functionType = %p = %s \n",functionType,SageInterface::get_name(functionType).c_str());
- SgSymbol* returnSymbol = NULL;
- SgName name = functionType->get_mangled();
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgSymbol((*p_iterator).second)->variantT() == functionType->variantT())
- {
- returnSymbol = p_iterator->second;
- if (returnSymbol->get_symbol_basis() == functionType)
- return returnSymbol;
- }
- p_iterator++;
- }
- // DQ (2/13/2007): Fixed bug that returns a valid pointer even when there was no match to the input statement!
- // return returnSymbol;
- return NULL;
- }
- SgSymbol*
- SgSymbolTable::find( const SgStatement* statement)
- {
- ROSE_ASSERT(p_table != NULL);
- ROSE_ASSERT(statement != NULL);
- // printf ("Inside of SgSymbolTable::find( const SgStatement* ): statement = %p = %s = %s \n",statement,statement->class_name().c_str(),SageInterface::get_name(statement).c_str());
- SgSymbol* returnSymbol = NULL;
- SgName name = get_name(statement);
- #if 0
- // This code is replaced by the SgSymbolTable::get_name() function.
- switch (statement->variantT())
- {
- // We could implement a function on the selective statements that generated the symbol
- // name (the name used for the input of associated symbols in the symbol table).
- case V_SgLabelStatement:
- {
- const SgLabelStatement* labelStatement = isSgLabelStatement(statement);
- name = labelStatement->get_label();
- break;
- }
- case V_SgClassDeclaration:
- {
- const SgClassDeclaration* classDeclaration = isSgClassDeclaration(statement);
- name = classDeclaration->get_name();
- break;
- }
- case V_SgTemplateInstantiationDecl:
- {
- const SgTemplateInstantiationDecl* templateInstantiationDeclaration = isSgTemplateInstantiationDecl(statement);
- // Note that get_name() returns a name with arguments such as "class_template<int>" while get_templateName() returns the template name withouth arguments.
- // name = templateInstantiationDeclaration->get_templateName();
- // printf ("In SgSymbolTable::find(const SgStatement*): case V_SgTemplateInstantiationDecl, using get_name() = %s instead of get_templateName() = %s \n",
- // templateInstantiationDeclaration->get_name().str(),templateInstantiationDeclaration->get_templateName().str());
- // printf ("Base class get_name() = %s \n",templateInstantiationDeclaration->SgClassDeclaration::get_name().str());
- name = templateInstantiationDeclaration->get_name();
- break;
- }
- case V_SgEnumDeclaration:
- {
- const SgEnumDeclaration* enumDeclaration = isSgEnumDeclaration(statement);
- name = enumDeclaration->get_name();
- break;
- }
- case V_SgFunctionDeclaration:
- case V_SgMemberFunctionDeclaration:
- {
- const SgFunctionDeclaration* functionDeclaration = isSgFunctionDeclaration(statement);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- name = functionDeclaration->get_name();
- break;
- }
- // DQ (2/14/2007): Note that for template-based declarations there is a process where within the post-processing of
- // the AST the names are updated from the EDG form (e.g. "template_name___Lnnn"), to the template specialization
- // form (e.g. "template_name<int>"). Since the symbol references only one of the declarations, if there are defining
- // declarations and non-defining declarations, the name can be changed in the declaration but not in the associated symbol.
- // Details of this situation require more clarification.
- case V_SgTemplateInstantiationFunctionDecl:
- {
- const SgTemplateInstantiationFunctionDecl* functionDeclaration = isSgTemplateInstantiationFunctionDecl(statement);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- // DQ (2/14/2007): The name used to insert symbols into the symbol table is the one returned by get_name(),
- // get_templateName returns the name of the template which is required for code generation (where for
- // functions the specialization is not required or not allowed).
- // name = functionDeclaration->get_templateName();
- name = functionDeclaration->get_name();
- break;
- }
- case V_SgTemplateInstantiationMemberFunctionDecl:
- {
- const SgTemplateInstantiationMemberFunctionDecl* functionDeclaration = isSgTemplateInstantiationMemberFunctionDecl(statement);
- // printf ("functionDeclaration = %p \n",functionDeclaration);
- // printf ("functionDeclaration->get_definingDeclaration() = %p \n",functionDeclaration->get_definingDeclaration());
- // printf ("functionDeclaration->get_firstNondefiningDeclaration() = %p \n",functionDeclaration->get_firstNondefiningDeclaration());
- // DQ (2/14/2007): The name used to insert symbols into the symbol table is the one returned by get_name(),
- // get_templateName returns the name of the template which is required for code generation (where for
- // functions the specialization is not required or not allowed).
- // name = functionDeclaration->get_templateName();
- name = functionDeclaration->get_name();
- break;
- }
- case V_SgNamespaceDeclarationStatement:
- {
- const SgNamespaceDeclarationStatement* namespaceDeclarationStatement = isSgNamespaceDeclarationStatement(statement);
- name = namespaceDeclarationStatement->get_name();
- break;
- }
- case V_SgTemplateDeclaration:
- {
- const SgTemplateDeclaration* templateDeclaration = isSgTemplateDeclaration(statement);
- name = templateDeclaration->get_name();
- break;
- }
- case V_SgTypedefDeclaration:
- {
- const SgTypedefDeclaration* typedefDeclaration = isSgTypedefDeclaration(statement);
- name = typedefDeclaration->get_name();
- break;
- }
- default:
- {
- printf ("SgSymbolTable::find(SgStatement*) undefined for %s \n",statement->class_name().c_str());
- ROSE_ASSERT(false);
- }
- }
- #endif
- // printf ("Inside of SgSymbolTable::find( const SgStatement* ): name = %s \n",name.str());
- // Get a quick pointer into the symbol table using the name (log n complexity)
- p_iterator = p_table->find(name);
- // Once we have p_iterator set via the name we don't typically have more than one iteration
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- ROSE_ASSERT(p_iterator->second != NULL);
- #if 0
- printf ("In loop: p_iterator->second = %p statement = %p \n",p_iterator->second,statement);
- printf ("In loop: p_iterator->second = %p = %s statement = %p = %s \n",p_iterator->second,p_iterator->second->class_name().c_str(),statement,statement->class_name().c_str());
- #endif
- // This is a virtual function call (not defined for function type symbols)
- SgNode* symbolBasis = p_iterator->second->get_symbol_basis();
- #if 0
- printf ("In loop: symbolBasis->variantT() = %d = %s statement->variantT() = %d = %s \n",
- symbolBasis->variantT(),Cxx_GrammarTerminalNames[symbolBasis->variantT()].name,
- statement->variantT(),Cxx_GrammarTerminalNames[statement->variantT()].name);
- #endif
- ROSE_ASSERT(symbolBasis != NULL);
- if (symbolBasis->variantT() == statement->variantT())
- {
- // printf ("matching variants \n");
- returnSymbol = p_iterator->second;
- // This is a very presice test which might be a problem because of defining and non-defining versions
- // of declarations (we might be able to always use the non-defining declaration in these cases. The
- // switch which computes the names could normalize this aspect.
- if (returnSymbol->get_symbol_basis() == statement)
- {
- // printf ("returnSymbol->get_symbol_basis() == statement returnSymbol = %p = %s \n",returnSymbol,returnSymbol->class_name().c_str());
- return returnSymbol;
- }
- else
- {
- // printf ("returnSymbol->get_symbol_basis() != statement \n");
- }
- }
- else
- {
- // printf ("Some other symbol was found (no matching variants) \n");
- }
- p_iterator++;
- }
- // DQ (2/13/2007): Fixed bug that returns a valid pointer even when there was no match to the input statement!
- // return returnSymbol;
- return NULL;
- }
- void
- SgSymbolTable::remove( const SgSymbol* symbol )
- {
- // This is used for the handled of non function type symbol tables, and is more useful when the
- // symbols don't have unique names.
- // This is non-destructive (does not delete the symbol, only removes it from the symbol table).
- ROSE_ASSERT (p_table != NULL);
- #if 1
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // This is an expensive linear time search of the symbol table!
- ROSE_ASSERT(exists(symbol) == true);
- #endif
- // This is a virtual function call
- SgName name = symbol->get_name();
- #if 0
- // printf ("In SgSymbolTable::remove(SgSymbol* symbol = %p = %s = %s) from SgSymbolTable = %p \n",symbol,symbol->class_name().c_str(),SageInterface::get_name(symbol).c_str(),this);
- SgNode* symbolBasis = symbol->get_symbol_basis();
- ROSE_ASSERT(symbolBasis != NULL);
- printf ("In SgSymbolTable::remove(SgSymbol* symbol = %p = %s = %s) symbol_basis = %p = %s = %s from SgSymbolTable = %p \n",
- symbol,symbol->class_name().c_str(),SageInterface::get_name(symbol).c_str(),
- symbolBasis,symbolBasis->class_name().c_str(),SageInterface::get_name(symbolBasis).c_str(),this);
- #endif
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator elementToDelete = get_table()->end();
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator it = get_table()->find(name);
- while ( (it != get_table()->end()) && (elementToDelete == get_table()->end()) && ((*it).first == name) )
- {
- // printf ("Looking for symbol to remove (Make sure that we find the correct element) \n");
- // Make sure that we find the correct element
- if (it->second == symbol)
- {
- // printf ("Found iterator for symbol = %p \n",symbol);
- elementToDelete = it;
- }
- it++;
- }
- #if 0
- // #if SYMBOL_TABLE_ERROR_CHECKING
- // DQ (2/11/2007): This is part of making the symbol table use more precise.
- if (elementToDelete == get_table()->end())
- {
- printf ("Error: could not find symbol name = %s in symbol table (restart search using symbol pointer) \n",name.str());
- // DQ (2/19/2007): Added assertion to exit on error! Enforcing this allows us to
- // make sure that the complexity is not linear in the size of the symbol table!
- ROSE_ASSERT(false);
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator i = get_table()->begin();
- while ( (i != get_table()->end()) && (elementToDelete == get_table()->end()) )
- {
- // printf ("Looking for symbol to remove (Make sure that we find the correct element) \n");
- // Make sure that we find the correct element
- if (i->second == symbol)
- {
- // printf ("Found iterator for symbol = %p \n",symbol);
- elementToDelete = i;
- }
- i++;
- }
- if (elementToDelete != get_table()->end())
- {
- printf ("Warning: found symbol = %p = %s stored under a different name = %s \n",symbol,symbol->class_name().c_str(),elementToDelete->first.str());
- printf ("Location of problem in source code: \n");
- SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(symbol->get_symbol_basis());
- if (declarationStatement != NULL)
- {
- printf ("declarationStatement = %p = %s \n",declarationStatement,declarationStatement->class_name().c_str());
- declarationStatement->get_startOfConstruct()->display("location of problem: debug");
- }
- ROSE_ASSERT(false);
- }
- }
- #endif
- #if 0
- // DQ (2/13/2007): Now we really have an error to report
- // Make sure we found the input element to be removed!
- if (elementToDelete == get_table()->end())
- {
- printf ("Error: could not find symbol = %p name = %s in symbol table (failed to find symbol pointer under any name) \n",symbol,name.str());
- ROSE_ASSERT(false);
- }
- #endif
- ROSE_ASSERT(elementToDelete != get_table()->end());
- // DQ (5/9/2007): Moved to after the call to "p_symbolSet.erase(elementToDelete->second);"
- // get_table()->erase(elementToDelete);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- // p_symbolSet.erase(symbol);
- p_symbolSet.erase(elementToDelete->second);
- get_table()->erase(elementToDelete);
- }
- #if 0
- // *****************************************************************
- // DQ (2/6/2007): These are just too dangerous to use directly.
- // Use the versions which take a declaration or a symbol explicitly.
- // *****************************************************************
- /* ************************************************************************
- DQ (1/30/2007): Added remove functions for each sort of SgSymbol IR node
- ************************************************************************
- void remove_function ( const SgName & );
- void remove_class ( const SgName & );
- void remove_enum ( const SgName & );
- void remove_typedef ( const SgName & );
- void remove_label ( const SgName & );
- void remove_var ( const SgName & );
- void remove_enum_field ( const SgName & );
- void remove_function_type ( const SgName & );
- void remove_namespace ( const SgName & );
- */
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_function( const SgName & name )
- {
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgFunctionSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_class( const SgName & name )
- {
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgClassSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- // DQ (5/9/2007): Moved to after the call to "p_symbolSet.erase(i->second);"
- // get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- get_table()->erase(*i);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_enum( const SgName & name )
- {
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgEnumSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_label( const SgName & name )
- {
- printf ("Error: not implemented yet! \n");
- ROSE_ASSERT(false);
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgEnumSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_var( const SgName & name )
- {
- printf ("Error: not implemented yet! \n");
- ROSE_ASSERT(false);
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgEnumSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_function_type( const SgName & name )
- {
- printf ("Error: not implemented yet! \n");
- ROSE_ASSERT(false);
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgEnumSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- void
- SgSymbolTable::remove_namespace( const SgName & name )
- {
- printf ("Error: not implemented yet! \n");
- ROSE_ASSERT(false);
- ROSE_ASSERT(p_table != NULL);
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator> deleteList;
- p_iterator = p_table->find(name);
- while (p_iterator != p_table->end() && (*p_iterator).first == name)
- {
- if (isSgEnumSymbol((*p_iterator).second))
- {
- deleteList.push_back(p_iterator);
- }
- p_iterator++;
- }
- // Now remove the copy of the symbol from the symbol table and insert the shared symbol
- list<hash_multimap<const SgName, SgSymbol*, hash_Name, eqstr>::iterator>::iterator i = deleteList.begin();
- while (i != deleteList.end())
- {
- get_table()->erase(*i);
- // DQ (3/10/2007): Remove the symbol from the symbol set used to test for if the symbol exists
- p_symbolSet.erase(i->second);
- i++;
- }
- }
- #error "DEAD CODE!"
- #endif
- /* ************************************************************************
- FIND FUNCTIONS
- ************************************************************************/
- // DQ (2/10/2007): This is a depricated function
- int
- SgSymbolTable::find(const SgName & nm, SgSymbol *sp)
- {
- ROSE_ASSERT(p_table != NULL);
- // if(!p_table)
- // return NULL;
- // DQ (5/22/2006): Made this a local variable
- // hash_iterator p_iterator = p_table->find(nm);
- p_iterator = p_table->find(nm);
- // while (p_iterator != p_table->end() && (*p_iterator).first == nm)
- while (p_iterator != p_table->end() && p_iterator->first == nm)
- {
- p_name = nm;
- p_no_name = false;
- // if( ((SgSymbol *)(*p_iterator).second) == sp )
- if( p_iterator->second == sp )
- return true;
- p_iterator++;
- }
- return false;
- }
- // DQ (1/31/2007): New functions that will replace the depricated find() member function
- bool
- SgSymbolTable::exists ( const SgName & nm ) const
- {
- ROSE_ASSERT(p_table != NULL);
- return p_table->find(nm) != p_table->end();
- }
- // DQ (1/31/2007): New functions that will replace the depricated find() member function
- bool
- SgSymbolTable::exists ( const SgSymbol *sp ) const
- {
- #if 0
- // DQ (2/19/2007): Make sure that this sort of expensive symbol table is not called if SYMBOL_TABLE_ERROR_CHECKING is not active
- #if SYMBOL_TABLE_ERROR_CHECKING == 0
- printf ("Error: Expensive symbol table tests being called while SYMBOL_TABLE_ERROR_CHECKING == 0 \n");
- ROSE_ASSERT(false);
- #endif
- // This is the more expensive implementation but more useful for error checking!
- bool returnValue = false;
- ROSE_ASSERT(p_table != NULL);
- hash_iterator i = p_table->begin();
- while ( returnValue == false && i != p_table->end() )
- {
- // if ((SgSymbol *)(i->second) == sp )
- if ( i->second == sp )
- returnValue = true;
- i++;
- }
- return returnValue;
- #else
- // DQ (3/10/2007): We can now use the stored p_symbolSet (STL set of SgNode*) to do this test more efficiently.
- // return p_symbolSet.find(sp) != p_symbolSet.end();
- return p_symbolSet.find(const_cast<SgSymbol*>(sp)) != p_symbolSet.end();
- #endif
- }
- // DQ (1/31/2007): New functions that will replace the depricated find() member function
- bool
- SgSymbolTable::exists ( const SgName & nm, SgSymbol *sp ) const
- {
- #if 0
- bool returnValue = false;
- ROSE_ASSERT(p_table != NULL);
- hash_iterator i = p_table->find(nm);
- while ( returnValue == false && i != p_table->end() && i->first == nm )
- {
- if ( i->second == sp )
- returnValue = true;
- i++;
- }
- return returnValue;
- #else
- // DQ (3/10/2007): We can now use the stored p_symbolSet (STL set of SgNode*) to do this test more efficiently.
- // Since we if we find the symbol it exists, we can test the name separately
- // bool returnValue = false;
- // Test if the symbol is in the set, else the name is not relavant to the existence
- if (p_symbolSet.find(sp) != p_symbolSet.end())
- {
- // Now look to make sure that we have an entry with the correct name (and pointer value)
- hash_iterator p_iterator = p_table->find(nm);
- while (p_iterator != p_table->end() && p_iterator->first == nm)
- {
- if ( p_iterator->second == sp )
- {
- // This allows us to short-circuit the rest of the iterations
- return true;
- }
- p_iterator++;
- }
- }
- return false;
- #endif
- }
- /* ************************************************************************
- DQ (1/30/2007): Added remove functions for each sort of SgSymbol IR node
- ************************************************************************
- SgSymbol* find_any(const SgName &);
- SgVariableSymbol* find_variable(const SgName &);
- SgClassSymbol* find_class(const SgName &);
- SgFunctionSymbol* find_function(const SgName&);
- SgFunctionSymbol* find_function_type(const SgName&, const SgType*);
- SgTypedefSymbol* find_typedef(const SgName &);
- SgEnumSymbol* find_enum(const SgName &);
- SgEnumFieldSymbol* find_enum_field(const SgName &);
- SgLabelSymbol* find_label(const SgName &) const;
- SgNamespaceSymbol* find_namespace(const SgName &);
- */
- SgSymbol*
- SgSymbolTable::findany(const SgName &nm)
- {
- return find_any(nm);
- }
- SgSymbol*
- SgSymbolTable::find_any(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- // DQ (5/22/2006): Made this a local variable
- // hash_iterator p_iterator = p_table->find(nm);
- p_iterator = p_table->find(nm);
- if (p_iterator != p_table->end() && p_iterator->first == nm)
- {
- p_name = nm;
- p_no_name = false;
- return (SgSymbol *) p_iterator->second;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgTypedefSymbol*
- SgSymbolTable::find_typedef(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator=p_table->find(nm);
- while(p_iterator != p_table->end() && p_iterator->first == nm)
- {
- // if(isSgTypedefSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgTypedefSymbol)
- {
- p_name=nm;
- p_no_name = false;
- return (SgTypedefSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgEnumSymbol*
- SgSymbolTable::find_enum(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table != NULL)
- {
- p_iterator=p_table->find(nm);
- while(p_iterator != p_table->end() && (*p_iterator).first == nm)
- {
- // if (isSgEnumSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgEnumSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgEnumSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgEnumFieldSymbol*
- SgSymbolTable::find_enum_field(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator=p_table->find(nm);
- while(p_iterator != p_table->end() && p_iterator->first == nm)
- {
- // if (isSgEnumFieldSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgEnumFieldSymbol)
- {
- p_name=nm;
- p_no_name = false;
- return (SgEnumFieldSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- SgVariableSymbol*
- SgSymbolTable::findvar(const SgName &nm)
- {
- return find_variable(nm);
- }
- SgVariableSymbol*
- SgSymbolTable::find_variable(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator=p_table->find(nm);
- while(p_iterator != p_table->end() && (*p_iterator).first==nm)
- {
- // if(isSgVariableSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgVariableSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgVariableSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- SgClassSymbol*
- SgSymbolTable::findclass(const SgName &nm)
- {
- return find_class(nm);
- }
- SgClassSymbol*
- SgSymbolTable::find_class(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator=p_table->find(nm);
- while (p_iterator != p_table->end() && (*p_iterator).first==nm)
- {
- // if (isSgClassSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgClassSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgClassSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- SgFunctionTypeSymbol*
- SgSymbolTable::findfunctype(const SgName &nm)
- {
- return find_function_type(nm);
- }
- SgFunctionTypeSymbol*
- SgSymbolTable::find_function_type(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- SgFunctionTypeSymbol* returnFunctionType = NULL;
- hash_iterator i = p_table->find(nm);
- // if (i != p_table->end() && isSgFunctionTypeSymbol((*i).second))
- if (i != p_table->end() && i->second->variantT() == V_SgFunctionTypeSymbol)
- {
- // return (SgFunctionTypeSymbol *) i->second;
- returnFunctionType = (SgFunctionTypeSymbol *) i->second;
- }
- // return NULL;
- return returnFunctionType;
- }
- SgLabelSymbol*
- SgSymbolTable::find_label(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->find(nm);
- while (p_iterator != p_table->end() && (*p_iterator).first == nm)
- {
- // if (isSgNamespaceSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgLabelSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgLabelSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgNamespaceSymbol*
- SgSymbolTable::find_namespace ( const SgName & nm )
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->find(nm);
- while (p_iterator != p_table->end() && (*p_iterator).first == nm)
- {
- // if (isSgNamespaceSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgNamespaceSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgNamespaceSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- SgFunctionSymbol*
- SgSymbolTable::findfunc(const SgName &nm, const SgType* t)
- {
- return find_function(nm,t);
- }
- SgFunctionSymbol*
- SgSymbolTable::find_function (const SgName &nm, const SgType* t)
- {
- // AS (083006): cleaned up logic so that the function only have one return statement.
- SgFunctionSymbol *s = NULL;
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- // SgSymbolHashBase::iterator i=p_table->find(nm);
- // JW and AS (08/30/06) changed to use equal range rather than find and
- // iterating through the hash table. This is an optimization.
- std::pair<hash_iterator, hash_iterator> range = p_table->equal_range(nm);
- for (hash_iterator i = range.first; i != range.second; ++i)
- {
- // s = isSgFunctionSymbol((*i).second);
- s = isSgFunctionSymbol(i->second);
- if ( (s != NULL) && (s->get_declaration()->get_type() == t))
- {
- p_name = nm;
- p_no_name = false;
- // return ((SgFunctionSymbol *)(*i).second);
- break;
- }
- }
- }
- return s;
- }
- SgFunctionSymbol*
- SgSymbolTable::findfunc(const SgName &nm)
- {
- return find_function(nm);
- }
- SgFunctionSymbol*
- SgSymbolTable::find_function(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator =p_table->find(nm);
- while(p_iterator != p_table->end())
- {
- // if(isSgFunctionSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgFunctionSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgFunctionSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- SgTemplateSymbol*
- SgSymbolTable::find_template(const SgName &nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator =p_table->find(nm);
- while(p_iterator != p_table->end())
- {
- // if(isSgTemplateSymbol((*p_iterator).second))
- if ( p_iterator->second->variantT() == V_SgTemplateSymbol)
- {
- p_name = nm;
- p_no_name = false;
- return (SgTemplateSymbol *) p_iterator->second;
- }
- p_iterator++;
- }
- }
- return NULL;
- }
- /* ************************************************************************
- DQ (1/30/2007): Added remove functions for each sort of SgSymbol IR node
- ************************************************************************
- SgSymbol* find_any();
- SgVariableSymbol* find_variable();
- SgClassSymbol* find_class();
- SgFunctionSymbol* find_function();
- SgFunctionSymbol* find_function_type();
- SgTypedefSymbol* find_typedef();
- SgEnumSymbol* find_enum();
- SgEnumFieldSymbol* find_enum_field();
- SgLabelSymbol* find_label();
- SgNamespaceSymbol* find_namespace();
- */
- // DQ (9/7/2006): Previously removed functionality, restored by request from Beata at ANL.
- SgSymbol*
- SgSymbolTable::findfirstany()
- {
- return find_any();
- }
- SgSymbol*
- SgSymbolTable::find_any()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- if(p_iterator != p_table->end())
- // return ((SgSymbol *) (*p_iterator).second);
- return (SgSymbol *) p_iterator->second;
- }
- return NULL;
- }
- // DQ (9/7/2006): Previously removed functionality, restored by request from Beata at ANL.
- SgVariableSymbol*
- SgSymbolTable::findfirstvar()
- {
- return find_variable();
- }
- SgVariableSymbol*
- SgSymbolTable::find_variable()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while(p_iterator != p_table->end())
- {
- // if(isSgVariableSymbol((*p_iterator).second))
- // return ((SgVariableSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgVariableSymbol)
- return (SgVariableSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgClassSymbol*
- SgSymbolTable::findfirstclass()
- {
- return find_class();
- }
- SgClassSymbol*
- SgSymbolTable::find_class()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgClassSymbol((*p_iterator).second))
- // return ((SgClassSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgClassSymbol)
- return (SgClassSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgFunctionSymbol*
- SgSymbolTable::findfirstfunction()
- {
- return find_function();
- }
- SgFunctionSymbol*
- SgSymbolTable::find_function()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while(p_iterator != p_table->end())
- {
- // if(isSgFunctionSymbol((*p_iterator).second))
- // return ((SgFunctionSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgFunctionSymbol)
- return (SgFunctionSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- #if 0
- // DQ (1/30/2007): Added to make the interface consistant
- // This function is not requires since SgFunctionTypeSymbols
- // are stored into their own function table. So this is
- // equivalent to STL function "begin()".
- SgFunctionSymbol*
- SgSymbolTable::find_function_type()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while(p_iterator != p_table->end())
- {
- // if(isSgFunctionSymbol((*p_iterator).second))
- // return ((SgFunctionSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgFunctionTypeSymbol)
- return (SgFunctionTypeSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- #endif
- SgTypedefSymbol*
- SgSymbolTable::find_typedef()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgTypedefSymbol((*p_iterator).second))
- // return ((SgTypedefSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgTypedefSymbol)
- return (SgTypedefSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- SgEnumSymbol*
- SgSymbolTable::find_enum()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgEnumSymbol((*p_iterator).second))
- // return ((SgEnumSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgEnumSymbol)
- return (SgEnumSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- SgEnumFieldSymbol*
- SgSymbolTable::find_enum_field()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgEnumFieldSymbol((*p_iterator).second))
- // return ((SgEnumFieldSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgEnumFieldSymbol)
- return (SgEnumFieldSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- SgLabelSymbol*
- SgSymbolTable::find_label()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgLabelSymbol((*p_iterator).second))
- // return ((SgLabelSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgLabelSymbol)
- return (SgLabelSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- SgNamespaceSymbol*
- SgSymbolTable::find_namespace()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgNamespaceSymbol((*p_iterator).second))
- // return ((SgNamespaceSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgNamespaceSymbol)
- return (SgNamespaceSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- SgTemplateSymbol*
- SgSymbolTable::find_template()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table)
- {
- p_iterator = p_table->begin();
- p_no_name = true;
- while (p_iterator != p_table->end())
- {
- // if (isSgTemplateSymbol((*p_iterator).second))
- // return ((SgTemplateSymbol *)(*p_iterator).second);
- if (p_iterator->second->variantT() == V_SgTemplateSymbol)
- return (SgTemplateSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- /* ************************************************************************
- DQ (1/30/2007): Added remove functions for each sort of SgSymbol IR node
- ************************************************************************
- SgSymbol* next_any();
- SgVariableSymbol* next_variable();
- SgClassSymbol* next_class();
- SgFunctionSymbol* next_function();
- SgTypedefSymbol* next_typedef();
- SgEnumSymbol* next_enum();
- SgEnumFieldSymbol* next_enum_field();
- SgLabelSymbol* next_label();
- SgNamespaceSymbol* next_namespace();
- */
- // DQ (9/7/2006): Previously removed functionality, restored by request from Beata at ANL.
- SgSymbol*
- SgSymbolTable::nextany()
- {
- return next_any();
- }
- SgSymbol*
- SgSymbolTable::next_any()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() )
- {
- if( p_no_name || (*p_iterator).first == p_name )
- return (SgSymbol *) p_iterator->second;
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (9/7/2006): Previously removed functionality, restored by request from Beata at ANL.
- SgVariableSymbol*
- SgSymbolTable::nextvar()
- {
- return next_variable();
- }
- SgVariableSymbol*
- SgSymbolTable::next_variable()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if (isSgVariableSymbol((*p_iterator).second))
- return ((SgVariableSymbol *) (*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgClassSymbol*
- SgSymbolTable::nextclass()
- {
- return next_class();
- }
- SgClassSymbol*
- SgSymbolTable::next_class()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator++; // go to next one
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if(isSgClassSymbol((*p_iterator).second))
- return ((SgClassSymbol *)(*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added these back into ROSE.
- SgFunctionSymbol*
- SgSymbolTable::nextfunc()
- {
- return next_function();
- }
- SgFunctionSymbol*
- SgSymbolTable::next_function()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if(isSgFunctionSymbol((*p_iterator).second))
- return ((SgFunctionSymbol *)(*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- SgTypedefSymbol*
- SgSymbolTable::next_typedef()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if (isSgTypedefSymbol((*p_iterator).second))
- return ((SgTypedefSymbol *) (*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added this as a new member function.
- SgEnumSymbol*
- SgSymbolTable::next_enum()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if(isSgEnumSymbol((*p_iterator).second))
- return ((SgEnumSymbol *)(*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- // DQ (1/30/2007): Added this as a new member function.
- SgEnumFieldSymbol*
- SgSymbolTable::next_enum_field()
- {
- ROSE_ASSERT(p_table != NULL);
- if(p_table)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if(isSgEnumFieldSymbol((*p_iterator).second))
- return ((SgEnumFieldSymbol *)(*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- SgLabelSymbol*
- SgSymbolTable::next_label()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if (isSgLabelSymbol((*p_iterator).second))
- return ((SgLabelSymbol *) (*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- SgNamespaceSymbol*
- SgSymbolTable::next_namespace()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if (isSgNamespaceSymbol((*p_iterator).second))
- return ((SgNamespaceSymbol *) (*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- SgTemplateSymbol*
- SgSymbolTable::next_template()
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- p_iterator++;
- // DQ (10/8/2007): Is there a use of find that would be O(log n) and be a faster way to return the next matching entry?
- while( p_iterator != p_table->end() && (p_no_name || (*p_iterator).first==p_name))
- {
- if (isSgTemplateSymbol((*p_iterator).second))
- return ((SgTemplateSymbol *) (*p_iterator).second);
- p_iterator++;
- }
- }
- return NULL;
- }
- #if 1
- // DQ (1/30/2007): Added these back into ROSE.
- SgSymbol*
- SgSymbolTable::operator[](const SgName & nm)
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- // SgSymbolHashBase::iterator i=p_table->find(nm);
- hash_iterator i=p_table->find(nm);
- if (i != p_table->end())
- return (*i).second;
- }
- return NULL;
- }
- #endif
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- int
- SgSymbolTable::size() const
- {
- ROSE_ASSERT(p_table != NULL);
- return p_table->size();
- }
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- int
- SgSymbolTable::count(const SgName &nm) const
- {
- // DQ (1/30/2007): assertion added
- ROSE_ASSERT(p_table != NULL);
- return p_table->count(nm);
- }
- void
- SgSymbolTable::print(std::ostream& os)
- {
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- #if 0
- SgSymbolHashBase::iterator i=p_table->begin();
- int idx = 0;
- while (i != p_table->end())
- {
- os << "[" << idx << "] " << (*i).first << "--";
- SgFunctionTypeSymbol *f=isSgFunctionTypeSymbol((*i).second);
- if (f)
- {
- isSgFunctionType(f->get_type())->sym_print(os);
- }
- SgFunctionSymbol *ft = isSgFunctionSymbol((*i).second);
- if (ft)
- {
- isSgFunctionType(ft->get_declaration()->get_type())->sym_print(os);
- }
- os << count((*i).first) << endl;
- i++; idx++;
- }
- #else
- printf ("ERROR: sym_print function not implemented in SAGE3! \n");
- ROSE_ABORT();
- #endif
- }
- else
- {
- os << "Pointer to symbol table is NULL \n";
- }
- }
- void
- SgSymbolTable::print( std::string label, VariantT nodeType )
- {
- printf ("Printing out the data within the symbol table (p_table = %p,label = %s size = %zu): \n",p_table,label.c_str(),size());
- printf ("Internal static data: p_no_name: %s p_name = %s \n",(p_no_name == true) ? "true" : "false",p_name.str());
- // These are just static data used internally for some of the symbol lookup functions (symbol tables are not given names).
- // printf ("SymbolTable has a name: %s \n",(p_no_name == true) ? "NO: it has no name" : "YES: it does have a name");
- // if (p_no_name == false)
- // printf ("SymbolTable name = %s \n",p_name.str());
- // DQ (2/16/2006): This is a SgScopeStatement except for the SgSymbolTable used in the global function type symbol table
- // SgScopeStatement* parentNode = isSgScopeStatement(get_parent());
- SgNode* parentNode = get_parent();
- ROSE_ASSERT(parentNode != NULL);
- printf ("Symbol table has parent = %p = %s \n",parentNode,parentNode->class_name().c_str());
- // DQ (6/23/2005): It is not a problem for the global function table to not have a name!
- // else
- // ROSE_ASSERT (p_name.str() == NULL);
- ROSE_ASSERT(p_table != NULL);
- if (p_table != NULL)
- {
- // AJ (10/21/2004): Adjusted implementation to use new STL hash map interface
- // SgSymbolHashBase::iterator i = p_table->begin();
- hash_iterator i = p_table->begin();
- int idx = 0;
- while (i != p_table->end())
- {
- // DQ: removed SgName casting operator to char*
- // cout << "[" << idx << "] " << (*i).first;
- // cout << "[" << idx << "] " << (*i).first.str();
- ROSE_ASSERT ( isSgSymbol( (*i).second ) != NULL );
- // printf ("Symbol number: %d (pair.first (SgName) = %s) pair.second (SgSymbol) sage_class_name() = %s \n",
- // idx,(*i).first.str(),(*i).second->sage_class_name());
- SgSymbol* symbol = isSgSymbol((*i).second);
- ROSE_ASSERT ( symbol != NULL );
- SgType* type = symbol->get_type();
- // DQ (5/7/2004): modified to allow for get_type() to return NULL
- // ROSE_ASSERT ( type != NULL );
- SgNamedType* namedType = isSgNamedType(type);
- SgName nameOfType;
- if (namedType != NULL)
- {
- nameOfType = namedType->get_name();
- // char* nameString = namedType->get_name().str();
- // printf ("Type is: (named type) = %s \n",nameString);
- }
- else
- {
- // DQ (5/7/2004): modified to allow for get_type() to return NULL
- if (type != NULL)
- {
- // printf ("Type is: type->sage_class_name() = %s \n",type->sage_class_name());
- nameOfType = type->sage_class_name();
- }
- else
- {
- // printf ("Type is: No type found in symbol (likely a possible error!) \n");
- switch(symbol->variantT())
- {
- case V_SgNamespaceSymbol:
- {
- // This is a normal case where the type will be a null pointer!
- nameOfType = "symbol's type is NULL (normal for SgNamespaceSymbol)";
- break;
- }
- case V_SgTemplateSymbol:
- {
- // This is a normal case where the type will be a null pointer!
- nameOfType = "symbol's type is NULL (normal for SgTemplateSymbol)";
- break;
- }
- default:
- {
- // This is likely an error, I think
- nameOfType = "unkown type name (likely a possible error!)";
- break;
- }
- }
- }
- }
- bool outputSymbolInfo = (nodeType == V_SgSymbol) || (symbol->variantT() == nodeType);
- // Output of symbol information
- SgNode* symbolBasis = i->second->get_symbol_basis();
- if (symbolBasis != NULL)
- {
- ROSE_ASSERT(symbolBasis != NULL);
- if (outputSymbolInfo == true)
- {
- printf ("Symbol %4d: name = %s SgSymbol = %p = %s type = %p = %s = %s get_symbol_basis() = %p = %s = %s \n",
- idx,(*i).first.str(),(*i).second,(*i).second->class_name().c_str(),type,(type != NULL) ? type->class_name().c_str() : "NULL" ,
- nameOfType.str(),symbolBasis,symbolBasis->class_name().c_str(),SageInterface::get_name(symbolBasis).c_str());
- }
- }
- else
- {
- if (outputSymbolInfo == true)
- {
- printf ("Warning Symbol %4d: name = %s SgSymbol = %p = %s type = %p = %s = %s get_symbol_basis() = NULL \n",
- idx,(*i).first.str(),(*i).second,(*i).second->class_name().c_str(),type,(type != NULL) ? type->class_name().c_str() : "NULL" ,
- nameOfType.str());
- }
- }
- SgName mangledName;
- SgSymbol* symbolFromTable = (*i).second;
- ROSE_ASSERT(symbolFromTable != NULL);
- switch(symbolFromTable->variantT())
- {
- case V_SgFunctionSymbol:
- {
- SgFunctionSymbol* symbol = isSgFunctionSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgFunctionDeclaration* functionDeclaration = symbol->get_declaration();
- mangledName = functionDeclaration->get_mangled_name();
- break;
- }
- case V_SgMemberFunctionSymbol:
- {
- SgMemberFunctionSymbol* symbol = isSgMemberFunctionSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgFunctionDeclaration* functionDeclaration = symbol->get_declaration();
- mangledName = functionDeclaration->get_mangled_name();
- break;
- }
- case V_SgClassSymbol:
- {
- SgClassSymbol* symbol = isSgClassSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgClassDeclaration* classDeclaration = symbol->get_declaration();
- mangledName = classDeclaration->get_mangled_name();
- break;
- }
- case V_SgEnumFieldSymbol:
- {
- SgEnumFieldSymbol* symbol = isSgEnumFieldSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgInitializedName* enumFieldName = symbol->get_declaration();
- mangledName = enumFieldName->get_mangled_name();
- break;
- }
- case V_SgEnumSymbol:
- {
- SgEnumSymbol* symbol = isSgEnumSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgEnumDeclaration* enumDeclaration = symbol->get_declaration();
- mangledName = enumDeclaration->get_mangled_name();
- break;
- }
- case V_SgFunctionTypeSymbol:
- {
- SgFunctionTypeSymbol* symbol = isSgFunctionTypeSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- mangledName = symbol->get_name();
- printf ("A SgFunctionTypeSymbol also has a pointer to a SgType = %p \n",symbol->get_type());
- break;
- }
- case V_SgLabelSymbol:
- {
- SgLabelSymbol* symbol = isSgLabelSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgLabelStatement* labelStatement = symbol->get_declaration();
- mangledName = labelStatement->get_label();
- break;
- }
- case V_SgNamespaceSymbol:
- {
- SgNamespaceSymbol* symbol = isSgNamespaceSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgNamespaceDeclarationStatement* namespaceDeclaration = symbol->get_declaration();
- mangledName = namespaceDeclaration->get_mangled_name();
- printf ("A SgNamespaceSymbol also has a name = %s \n",symbol->get_name().str());
- break;
- }
- case V_SgTemplateSymbol:
- {
- SgTemplateSymbol* symbol = isSgTemplateSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgTemplateDeclaration* templateDeclaration = symbol->get_declaration();
- mangledName = templateDeclaration->get_mangled_name();
- break;
- }
- case V_SgTypedefSymbol:
- {
- SgTypedefSymbol* symbol = isSgTypedefSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgTypedefDeclaration* typedefDeclaration = symbol->get_declaration();
- mangledName = typedefDeclaration->get_mangled_name();
- break;
- }
- case V_SgVariableSymbol:
- {
- SgVariableSymbol* symbol = isSgVariableSymbol(symbolFromTable);
- ROSE_ASSERT(symbol != NULL);
- SgInitializedName* initializedName = symbol->get_declaration();
- mangledName = initializedName->get_mangled_name();
- break;
- }
-
- default:
- {
- mangledName = "unknown mangled name";
- printf ("Error: SgSymbol not handled (%s) \n",symbolFromTable->class_name().c_str());
- // DQ (6/8/2007): Make this case fail so we can detect this error.
- ROSE_ASSERT(false);
- }
- }
- if (outputSymbolInfo == true)
- {
- printf (" Symbol's associated mangled name = %s \n",mangledName.str());
- // This is useful for the output of the function types when the global function type symbol table is output.
- // handle case of function symbol (unparse the funtion type)
- SgFunctionTypeSymbol *f = isSgFunctionTypeSymbol((*i).second);
- if (f != NULL)
- {
- #if 1
- // f->get_type()->unparse(); cout << endl;
- std::cout << " function: " << f->get_type()->unparseToString() << endl;
- #else
- // printf ("ERROR: unparse function for symbol type not implemented in SAGE3! \n");
- // ROSE_ABORT();
- #endif
- }
- }
- // Increment the symbol table's symble iterator
- i++;
- // Increment the symbol counter (used for output)
- idx++;
- }
- }
- else
- {
- // DQ (6/27/2005): I think this is an error (we should always have a valid symbol table)
- printf ("Pointer to symbol table is NULL \n");
- ROSE_ASSERT(false);
- }
- }
- set<SgNode*>
- SgSymbolTable::get_symbols() const
- {
- // DQ (2/15/2007): generate a set of SgNode* so that we can use them for set difference against the delete list in AST merge.
- set<SgNode*> returnSet;
- ROSE_ASSERT(p_table != NULL);
- hash_multimap<SgName, SgSymbol*, hash_Name, eqstr>::iterator i = get_table()->begin();
- while (i != p_table->end())
- {
- ROSE_ASSERT(i->second != NULL);
- returnSet.insert(i->second);
- i++;
- }
- return returnSet;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgSymbolTable::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgSymbolTable::variantT() const {
- return V_SgSymbolTable;
- }
- #if 0
- int
- SgSymbolTable::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return SymbolTableTag;
- }
- #endif
- const char*
- SgSymbolTable::sage_class_name() const
- {
- assert(this != NULL);
- return "SgSymbolTable";
- }
- std::string
- SgSymbolTable::class_name() const
- {
- assert(this != NULL);
- return "SgSymbolTable";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgSymbolTable::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- SgSymbolTable::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != SymbolTableTag)
- {
- printf ("Error in SgSymbolTable::error(): SgSymbolTable object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgSymbolTable::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == SymbolTableTag);
- return SgSupport::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgSymbolTable::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgSymbolTable::variant() const \n");
- #endif
- assert(this != NULL);
- return SymbolTableTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgSymbolTable* isSgSymbolTable ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgSymbolTable*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgSymbolTable* isSgSymbolTable ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgSymbolTable*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgSymbolTable::~SgSymbolTable ()
- {
- #if 0
- // debugging information!
- printf ("In SgSymbolTable::~SgSymbolTable (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- delete p_table;
- // case: not a listType for name
- p_name = ""; // non list case
- // case: not a listType for no_name
- p_no_name = false; // non list case
- // case: not a listType for table
- p_table = NULL; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- Sg_File_Info*
- SgInitializedName::get_startOfConstruct () const
- {
- assert (this != NULL);
- return p_startOfConstruct;
- }
- void
- SgInitializedName::set_startOfConstruct ( Sg_File_Info* startOfConstruct )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_startOfConstruct != NULL && startOfConstruct != NULL && p_startOfConstruct != startOfConstruct)
- {
- printf ("Warning: startOfConstruct = %p overwriting valid pointer p_startOfConstruct = %p \n",startOfConstruct,p_startOfConstruct);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_startOfConstruct != NULL && startOfConstruct != NULL && p_startOfConstruct != startOfConstruct) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_startOfConstruct = startOfConstruct;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgName
- SgInitializedName::get_name () const
- {
- assert (this != NULL);
- return p_name;
- }
- void
- SgInitializedName::set_name ( SgName name )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_name = name;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgType*
- SgInitializedName::get_typeptr () const
- {
- assert (this != NULL);
- return p_typeptr;
- }
- void
- SgInitializedName::set_typeptr ( SgType* typeptr )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_typeptr != NULL && typeptr != NULL && p_typeptr != typeptr)
- {
- printf ("Warning: typeptr = %p overwriting valid pointer p_typeptr = %p \n",typeptr,p_typeptr);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_typeptr != NULL && typeptr != NULL && p_typeptr != typeptr) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_typeptr = typeptr;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgInitializer*
- SgInitializedName::get_initptr () const
- {
- assert (this != NULL);
- return p_initptr;
- }
- void
- SgInitializedName::set_initptr ( SgInitializer* initptr )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_initptr != NULL && initptr != NULL && p_initptr != initptr)
- {
- printf ("Warning: initptr = %p overwriting valid pointer p_initptr = %p \n",initptr,p_initptr);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_initptr != NULL && initptr != NULL && p_initptr != initptr) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_initptr = initptr;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgInitializedName*
- SgInitializedName::get_prev_decl_item () const
- {
- assert (this != NULL);
- return p_prev_decl_item;
- }
- void
- SgInitializedName::set_prev_decl_item ( SgInitializedName* prev_decl_item )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_prev_decl_item != NULL && prev_decl_item != NULL && p_prev_decl_item != prev_decl_item)
- {
- printf ("Warning: prev_decl_item = %p overwriting valid pointer p_prev_decl_item = %p \n",prev_decl_item,p_prev_decl_item);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_prev_decl_item != NULL && prev_decl_item != NULL && p_prev_decl_item != prev_decl_item) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_prev_decl_item = prev_decl_item;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgDeclarationStatement*
- SgInitializedName::get_declptr () const
- {
- assert (this != NULL);
- return p_declptr;
- }
- void
- SgInitializedName::set_declptr ( SgDeclarationStatement* declptr )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_declptr != NULL && declptr != NULL && p_declptr != declptr)
- {
- printf ("Warning: declptr = %p overwriting valid pointer p_declptr = %p \n",declptr,p_declptr);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_declptr != NULL && declptr != NULL && p_declptr != declptr) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_declptr = declptr;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgScopeStatement*
- SgInitializedName::get_scope () const
- {
- assert (this != NULL);
- return p_scope;
- }
- void
- SgInitializedName::set_scope ( SgScopeStatement* scope )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_scope != NULL && scope != NULL && p_scope != scope)
- {
- printf ("Warning: scope = %p overwriting valid pointer p_scope = %p \n",scope,p_scope);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_scope != NULL && scope != NULL && p_scope != scope) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_scope = scope;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgInitializedName::preinitialization_enum
- SgInitializedName::get_preinitialization () const
- {
- assert (this != NULL);
- return p_preinitialization;
- }
- void
- SgInitializedName::set_preinitialization ( SgInitializedName::preinitialization_enum preinitialization )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_preinitialization = preinitialization;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- AstAttributeMechanism*
- SgInitializedName::get_attributeMechanism () const
- {
- assert (this != NULL);
- return p_attributeMechanism;
- }
- void
- SgInitializedName::set_attributeMechanism ( AstAttributeMechanism* attributeMechanism )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism)
- {
- printf ("Warning: attributeMechanism = %p overwriting valid pointer p_attributeMechanism = %p \n",attributeMechanism,p_attributeMechanism);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_attributeMechanism = attributeMechanism;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 836 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- #if 0
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- AstAttributeMechanism &
- SgInitializedName::attribute()
- {
- // DQ (1/2/2006): This function preserves as much of
- // the syntax of attribute being a public data member.
- if (p_attribute == NULL)
- {
- printf ("Error: p_attribute == NULL (node = %s) \n",class_name().c_str());
- ROSE_ASSERT(false);
- }
- return *p_attribute;
- }
- #endif
- void
- SgInitializedName::addNewAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->add(s,a);
- }
- void
- SgInitializedName::setAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->set(s,a);
- }
- AstAttribute*
- SgInitializedName::getAttribute(std::string s) const
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- AstAttribute* returnValue = get_attributeMechanism()->operator[](s);
- ROSE_ASSERT(returnValue != NULL);
- return returnValue;
- }
- void
- SgInitializedName::updateAttribute( std::string s, AstAttribute* a )
- {
- // formerly called: replace
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->replace(s,a);
- }
- void
- SgInitializedName::removeAttribute(std::string s)
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->remove(s);
- // DQ (1/2/2006): If we have no more attributes then remove the attribute container
- int remainingCount = numberOfAttributes();
- // printf ("In AstTextAttributesHandling::visit(): remaining number of attributes = %d \n",remainingCount);
- if (remainingCount == 0)
- {
- delete get_attributeMechanism();
- set_attributeMechanism(NULL);
- }
- }
- bool
- SgInitializedName::attributeExists(std::string s) const
- {
- bool returnValue = false;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->exists(s);
- return returnValue;
- }
- int
- SgInitializedName::numberOfAttributes() const
- {
- int returnValue = 0;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->size();
- return returnValue;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgInitializedName::asm_register_name_enum
- SgInitializedName::get_register_name_code () const
- {
- assert (this != NULL);
- return p_register_name_code;
- }
- void
- SgInitializedName::set_register_name_code ( SgInitializedName::asm_register_name_enum register_name_code )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_register_name_code = register_name_code;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgInitializedName::get_register_name_string () const
- {
- assert (this != NULL);
- return p_register_name_string;
- }
- void
- SgInitializedName::set_register_name_string ( std::string register_name_string )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_register_name_string = register_name_string;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgInitializedName::get_requiresGlobalNameQualificationOnType () const
- {
- assert (this != NULL);
- return p_requiresGlobalNameQualificationOnType;
- }
- void
- SgInitializedName::set_requiresGlobalNameQualificationOnType ( bool requiresGlobalNameQualificationOnType )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_requiresGlobalNameQualificationOnType = requiresGlobalNameQualificationOnType;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 6420 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- // DQ (2/6/2007): Get the associated symbol from the symbol table in the stored scope
- SgSymbol*
- SgInitializedName::get_symbol_from_symbol_table() const
- {
- ROSE_ASSERT(get_scope() != NULL);
- ROSE_ASSERT(get_scope()->get_symbol_table() != NULL);
- return get_scope()->get_symbol_table()->find(this);
- }
- #if 0
- SgInitializedName::~SgInitializedName()
- {
- /*delete p_ptr;*/
- }
- SgInitializedName::SgInitializedName()
- : p_typeptr(0), p_initptr(0), p_declptr(0),
- // p_itemptr(0), p_prev_itemptr(0),
- p_is_initializer(1)
- {
- }
- #endif
- Sg_File_Info*
- SgInitializedName::get_file_info() const
- {
- // This redefines get_file_info() as it is implemented for a SgLocatedNode
- // to use the "get_startOfConstruct()" for consistancy with SgLocatedNode IR nodes.
- return get_startOfConstruct();
- }
- void
- SgInitializedName::set_file_info(Sg_File_Info* X)
- {
- // This redefines set_file_info() as it is implemented for a SgLocatedNode
- // to use the "set_startOfConstruct()" for consistancy with SgLocatedNode IR nodes.
- return set_startOfConstruct(X);
- }
- SgStorageModifier &
- SgInitializedName::get_storageModifier()
- {
- ROSE_ASSERT (this != NULL);
- ROSE_ASSERT (p_storageModifier != NULL);
- return *p_storageModifier;
- }
- SgName
- SgInitializedName::get_qualified_name() const
- {
- // DQ (8/22/2005): This function is similar to the one for SgClassDeclaration.
- // This function calls get_scope() which uses the parent pointers, thus
- // it should not be called before the parent pointers are set (within the AST fixup after
- // the Sage III AST is fully constructed).
- // printf ("In SgInitializedName::get_qualified_name() name = %s \n",get_name().str());
- SgName returnName;
- // The semantics of get_scope is that it can never be NULL (SgGlobal returns itself as its scope!)
- SgScopeStatement* scope = get_scope();
- ROSE_ASSERT(scope != NULL);
- returnName = SgName::assembleQualifiedName(scope->get_qualified_name(),get_name());
- // printf ("In SgInitializedName::get_qualified_name() returnName = %s \n",returnName.str());
- return returnName;
- }
- void
- SgInitializedName::post_construction_initialization()
- {
- // printf ("In SgInitializedName::post_construction_initialization() this = %p \n",this);
- p_storageModifier = new SgStorageModifier();
- ROSE_ASSERT (p_storageModifier != NULL);
- p_storageModifier->setDefault();
- // DQ (6/20/2006): Set the parent of the SgStorageModifier
- p_storageModifier->set_parent(this);
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- // DQ (1/17/2006): Added initialization to prevent valgrind warning.
- p_attributeMechanism = NULL;
- // DQ (11/19/2004): Added to support explicit scopes for variables within variable declarations.
- p_scope = NULL;
- // DQ (12/17/2006): Added semantics that constructors (which are structural) should set the parents of their inputs.
- if (p_initptr != NULL)
- {
- // printf ("In SgInitializedName::post_construction_initialization(): resetting parent of valid initializer (p_initptr = %p) \n",p_initptr);
- p_initptr->set_parent(this);
- }
- }
- // This constructor is specific to the creation of SgInitializedName objects used as initializers
- SgInitializedName::SgInitializedName
- ( const SgName& name, SgType *typeptr, SgInitializer* iptr,
- SgDeclarationStatement *declptr,
- // QY:11/2/04 remove itemptr
- // SgInitializedName *itemptr,
- SgInitializedName *prev_itemptr ) ROSE_DEPRECATED_FUNCTION
- // DQ (1/18/2006): name change to make consistant with virtual SgNode::get_file_info()
- // DQ (11/20/2004): Reodered elements of pre-initialization list to avoid compiler warnings
- // : p_file_info(NULL), // Note that file_info is a new data member and is set explicitly after construction
- : p_startOfConstruct(NULL), // Note that file_info is a new data member and is set explicitly after construction
- p_name(name),
- p_typeptr(typeptr),
- // p_itemptr(itemptr), Removed constructor parameter list
- p_initptr(iptr),
- p_prev_decl_item(prev_itemptr),
- p_is_initializer(true),
- // DQ (6/18/2006): declptr was not being used to set the internal p_declptr data member.
- // p_declptr(NULL),
- p_declptr(declptr),
- // DQ (11/20/2004): Added additional initialization of remaining data members
- p_storageModifier(NULL),
- p_scope(NULL),
- // DQ (3/1/2005): Added to avoid valgrind warning about uninitialized use
- p_preinitialization(e_unknown_preinitialization),
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- // DQ (1/17/2006): Moved attribute mechanism to specific IR nodes (Added initialization to prevent valgrind warning)
- p_attributeMechanism(NULL),
- // DQ (7/31/2006): Added support for asm declarations on variables (using GNU register codes)
- p_register_name_code(SgInitializedName::e_invalid_register),
- // DQ (8/9/2006): Added support for asm declarations on variables (using strings)
- p_register_name_string(""),
- // DQ (10/10/2007): Added support for initialization of this data member (reported as uninitialized by valgrind).
- p_requiresGlobalNameQualificationOnType(false)
- {
- post_construction_initialization();
- }
- // DQ (8/4/2006): This constructor adds the newer fileInfo data member to the constructor parameter list.
- // We might soon depricate the older constructor.
- SgInitializedName::SgInitializedName
- ( Sg_File_Info* fileInfo, const SgName& name, SgType *typeptr, SgInitializer* iptr,
- SgDeclarationStatement *declptr, SgScopeStatement* scope, SgInitializedName *prev_itemptr )
- // : p_file_info(fileInfo), // Note that file_info is a new data member and is set explicitly after construction
- : p_startOfConstruct(fileInfo), // Note that file_info is a new data member and is set explicitly after construction
- p_name(name),
- p_typeptr(typeptr),
- p_initptr(iptr),
- p_prev_decl_item(prev_itemptr),
- p_is_initializer(true),
- p_declptr(declptr),
- p_storageModifier(NULL),
- p_scope(NULL),
- p_preinitialization(e_unknown_preinitialization),
- p_attributeMechanism(NULL),
- p_register_name_code(SgInitializedName::e_invalid_register),
- p_register_name_string(""),
- // DQ (10/10/2007): Added support for initialization of this data member (reported as uninitialized by valgrind).
- p_requiresGlobalNameQualificationOnType(false)
- {
- post_construction_initialization();
- }
- SgInitializedName::SgInitializedName (const SgInitializedName& ptr)
- {
- p_name = ptr.p_name;
- p_typeptr = ptr.p_typeptr;
- p_initptr = ptr.p_initptr;
- // DQ (12/17/2006): Added semantics that constructors (which are structural) should set the parents of their inputs.
- if (p_initptr != NULL)
- {
- printf ("In SgInitializedName constructor: resetting parent of valid initializer (p_initptr = %p) (likely sharing violation in copy constructor) \n",p_initptr);
- p_initptr->set_parent(this);
- }
- // p_prev_itemptr = ptr.p_prev_itemptr;
- p_is_initializer = ptr.p_is_initializer;
- p_declptr = ptr.p_declptr;
- // p_itemptr = ptr.p_itemptr;
- // DQ (1/18/2006): Avoid reusing Sg_File_Info objects
- // p_fileInfo = ptr.p_fileInfo;
- // p_file_info = (ptr.p_file_info != NULL) ? new Sg_File_Info(*ptr.p_file_info) : NULL;
- // DQ (12/17/2006): See if we can enforce this!
- // p_startOfConstruct = (ptr.p_startOfConstruct != NULL) ? new Sg_File_Info(*ptr.p_startOfConstruct) : NULL;
- ROSE_ASSERT(ptr.p_startOfConstruct != NULL);
- p_startOfConstruct = new Sg_File_Info(*ptr.p_startOfConstruct);
- ROSE_ASSERT(p_startOfConstruct != NULL);
- // DQ (12/17/2006): Fixup the parent of the new or borrowed Sg_File_Info object.
- p_startOfConstruct->set_parent(this);
- // DQ (11/19/2004): Added to support explicit scopes for variables within variable declarations.
- p_scope = ptr.p_scope;
- // DQ (3/1/2005): Added to avoid valgrind warning about uninitialized use
- p_preinitialization = ptr.p_preinitialization;
- // DQ (4/28/2004): Added storage modifier support (replacing the old interface)
- ROSE_ASSERT (ptr.p_storageModifier != NULL);
- p_storageModifier = new SgStorageModifier ( *(ptr.p_storageModifier) );
- ROSE_ASSERT (p_storageModifier != NULL);
- // DQ (6/20/2006): Set the parent of the SgStorageModifier
- p_storageModifier->set_parent(this);
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- // DQ (1/17/2006): Moved attribute mechanism to specific IR nodes
- p_attributeMechanism = NULL;
- // DQ (7/31/2006): Added support for asm declarations on variables (using GNU register codes)
- p_register_name_code = SgInitializedName::e_invalid_register;
- // DQ (8/9/2006): Added support for asm declarations on variables (using strings)
- // Note: don't copy the register string (I think this is best, but it is debatable)
- p_register_name_string = "";
- // DQ (10/10/2007): Added support for initialization of this data member (reported as uninitialized by valgrind).
- p_requiresGlobalNameQualificationOnType = ptr.p_requiresGlobalNameQualificationOnType;
- }
- SgInitializedName&
- SgInitializedName::operator= (const SgInitializedName& ptr)
- {
- ROSE_ASSERT(this != NULL);
- /* check they are not the same name */
- if (this != &ptr)
- {
- p_name = ptr.p_name;
- p_typeptr = ptr.p_typeptr;
- p_initptr = ptr.p_initptr;
- // DQ (12/17/2006): Added semantics that constructors (which are structural) should set the parents of their inputs.
- if (p_initptr != NULL)
- {
- // printf ("In SgInitializedName constructor: resetting parent of valid initializer (p_initptr = %p) (likely sharing violation in operator=) \n",p_initptr);
- #if 0
- // DQ (12/22/2006): Don't allow the parent of the input SgInitializedName to be modified, but make sure that it is set!
- // p_initptr->set_parent(this);
- if (p_initptr->get_parent() == NULL)
- {
- p_initptr->set_parent(this);
- }
- #else
- // DQ (12/22/2006): Interestingly, the inliner is dependent upon this working this way! We should maybe look into this later.
- p_initptr->set_parent(this);
- #endif
- ROSE_ASSERT(p_initptr->get_parent() != NULL);
- // printf ("Exiting as a test! operator= \n");
- // ROSE_ASSERT(false);
- }
- // p_prev_itemptr = ptr.p_prev_itemptr;
- p_is_initializer = ptr.p_is_initializer;
- p_declptr = ptr.p_declptr;
- // p_itemptr = ptr.p_itemptr;
- // DQ (1/18/2006): Avoid reusing Sg_File_Info objects
- // p_fileInfo = ptr.p_fileInfo;
- // DQ (6/23/2006): Added assertion to detect errors
- // ROSE_ASSERT(ptr.p_file_info != NULL);
- // p_file_info = (ptr.p_file_info != NULL) ? new Sg_File_Info(*ptr.p_file_info) : NULL;
- // ROSE_ASSERT(p_file_info != NULL);
- ROSE_ASSERT(ptr.p_startOfConstruct != NULL);
- // p_startOfConstruct = (ptr.p_startOfConstruct != NULL) ? new Sg_File_Info(*ptr.p_startOfConstruct) : NULL;
- p_startOfConstruct = new Sg_File_Info(*ptr.p_startOfConstruct);
- ROSE_ASSERT(p_startOfConstruct != NULL);
- // DQ (12/17/2006): Fixup the parent of the new or borrowed Sg_File_Info object.
- p_startOfConstruct->set_parent(this);
- // DQ (11/19/2004): Added to support explicit scopes for variables within variable declarations.
- p_scope = ptr.p_scope;
- // DQ (3/1/2005): Added to avoid valgrind warning about uninitialized use
- p_preinitialization = ptr.p_preinitialization;
- ROSE_ASSERT (p_storageModifier != NULL);
- *p_storageModifier = *(ptr.p_storageModifier);
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- // DQ (1/17/2006): Moved attribute mechanism to specific IR nodes
- p_attributeMechanism = NULL;
- // DQ (7/31/2006): Added support for asm declarations on variables
- p_register_name_code = ptr.p_register_name_code;
- // DQ (7/31/2006): Added support for asm declarations on variables
- p_register_name_string = ptr.p_register_name_string;
- // DQ (10/10/2007): Added support for initialization of this data member (reported as uninitialized by valgrind).
- p_requiresGlobalNameQualificationOnType = ptr.p_requiresGlobalNameQualificationOnType;
- }
- else
- {
- // DQ (6/23/2006): Added debugging message to track this issue.
- printf ("SgInitializedName::operator=(): Attempt to copy self to self \n");
- }
- // ROSE_ASSERT(p_file_info != NULL);
- ROSE_ASSERT(p_startOfConstruct != NULL);
- return *this;
- }
- bool
- SgInitializedName::operator== (const SgInitializedName& ) const
- { return false; }
- bool
- SgInitializedName::operator< (const SgInitializedName&) const
- { return false; }
- #if 0
- // DQ (10/9/2007): Use the ROSETTA generated version to test failure
- // DQ (12/9/2004): This is how an automatically generated function!
- SgName
- SgInitializedName::get_name() const
- {
- assert (this != NULL);
- return p_name;
- }
- #endif
- #if 0
- void
- SgInitializedName::set_name ( SgName name )
- {
- assert (this != NULL);
-
- p_name = name;
- }
- #endif
- #if 0
- // DQ (10/9/2007): Use the ROSETTA generated version to test failure
- // DQ (10/5/2007): This was a mistake to comment out, we want this functionality. It is likely that
- // similar function ality should be provided for all other names declarations that generate symbols
- // for the symbol table.
- // DQ (12/9/2004): This is now an automatically generated function!
- // AJ (10/21/2004): Added support for changing the symbol name associated with an SgInitializedName
- // by updating the symbol table
- int
- SgInitializedName::set_name(SgName new_name)
- {
- // This function could likely be simpler now that we have better symbol table support.
- set_isModified(true);
- // find the appropriate symbol table.
- SgNode * node = this;
- // DQ (12/9/2004): This should likely call the get_scope function (which is more robust than traversing
- // parents, there is a reason why we are forced to include the scope explicitly on some IR nodes,
- // see test2004_133.C for details).
- while((node!=NULL) && ( isSgScopeStatement(node)==NULL))
- node = node->get_parent();
- ROSE_ASSERT(node!=NULL);
- SgScopeStatement * scope_stmt = isSgScopeStatement(node);
- ROSE_ASSERT(scope_stmt != NULL);
- ROSE_ASSERT(scope_stmt->get_symbol_table() != NULL);
- ROSE_ASSERT(scope_stmt->get_symbol_table()->get_table() != NULL);
- SgDeclarationStatement * parent_declaration = get_declaration();
- ROSE_ASSERT(parent_declaration != NULL);
- // Find the symbols associated with p_name
- std::pair<SgSymbolTable::hash_iterator,SgSymbolTable::hash_iterator> pair_it =
- scope_stmt->get_symbol_table()->get_table()->equal_range(p_name);
- SgSymbolTable::hash_iterator found_it=scope_stmt->get_symbol_table()->get_table()->end();
- for(SgSymbolTable::hash_iterator it = pair_it.first; it != pair_it.second; ++it)
- {
- switch(parent_declaration->getVariant())
- {
- case V_SgVariableDeclaration:
- {
- if (isSgVariableSymbol((*it).second)!=NULL)
- found_it = it;
- break;
- }
- case V_SgClassDeclaration:
- {
- if (isSgClassSymbol((*it).second)!=NULL)
- found_it = it;
- break;
- }
- case V_SgFunctionDeclaration:
- {
- if (isSgFunctionSymbol((*it).second)!=NULL)
- found_it = it;
- break;
- }
- default:
- {
- }
- };
- }
- // there is no Variable,Class or Function symbol associated with p_name
- if (found_it == scope_stmt->get_symbol_table()->get_table()->end())
- {
- printf ("Warning: There is no Variable,Class or Function symbol associated with p_name \n");
- return 0;
- }
- SgSymbol * associated_symbol = (*found_it).second;
- // erase the name from there
- scope_stmt->get_symbol_table()->get_table()->erase(found_it);
- // insert the new_name in the symbol table
- found_it = scope_stmt->get_symbol_table()->get_table()->insert(pair<SgName,SgSymbol*> ( new_name,associated_symbol));
- // if insertion failed
- if (found_it == scope_stmt->get_symbol_table()->get_table()->end())
- {
- printf ("Warning: insertion of new symbol failed \n");
- return 0;
- }
- // Set the p_name to the new_name
- printf ("Reset p_name = %s to new_name = %s \n",p_name.str(),new_name.str());
- p_name = new_name;
- // Invalidate the p_iterator, p_no_name and p_name data members in the Symbol table
- return 1;
- }
- #endif
- SgType*
- SgInitializedName::get_type() const
- {
- ROSE_ASSERT(this != NULL);
- return p_typeptr;
- }
- void
- SgInitializedName::set_type(SgType *t)
- {
- ROSE_ASSERT(this != NULL);
- p_typeptr = t;
- }
- SgInitializer*
- SgInitializedName::get_initializer() const
- {
- // DQ (12/17/2006): These should be able to be generated by ROSETTA!
- // The semantics of p_is_initializer appears to not be required.
- ROSE_ASSERT(this != NULL);
- if (p_is_initializer)
- return p_initptr;
- else
- return NULL;
- }
- void
- SgInitializedName::set_initializer(SgInitializer* i)
- {
- // DQ (12/17/2006): These should be able to be generated by ROSETTA!
- // The semantics of p_is_initializer appears to not be required.
- ROSE_ASSERT(this != NULL);
- p_initptr = i;
- p_is_initializer = 1;
- }
- #if 0
- // DQ (2/18/2006): Added general name mangling for all declarations (and some other IR nodes).
- SgName
- SgInitializedName::get_mangled_name(void) const
- {
- // printf ("In SgInitializedName::get_mangled_name() name = %s \n",get_name().str());
- SgName returnName;
- // The semantics of get_scope is that it can never be NULL (SgGlobal returns itself as its scope!)
- SgScopeStatement* scope = get_scope();
- ROSE_ASSERT(scope != NULL);
- SgName mangleScopeName;
- switch (scope->variantT())
- {
- // These are all of the SgDefinitionStatement IR nodes for which a mangled name can be generated
- case V_SgFunctionDefinition:
- {
- SgFunctionDefinition* functionDefinition = isSgFunctionDefinition(scope);
- ROSE_ASSERT(functionDefinition != NULL);
- mangleScopeName = functionDefinition->get_mangled_name();
- break;
- }
- case V_SgNamespaceDefinitionStatement:
- {
- SgNamespaceDefinitionStatement* namespaceDefinition = isSgNamespaceDefinitionStatement(scope);
- ROSE_ASSERT(namespaceDefinition != NULL);
- mangleScopeName = namespaceDefinition->get_mangled_name();
- break;
- }
- case V_SgClassDefinition:
- {
- SgClassDefinition* classDefinition = isSgClassDefinition(scope);
- ROSE_ASSERT(classDefinition != NULL);
- mangleScopeName = classDefinition->get_mangled_name();
- break;
- }
- default:
- {
- // Nothing to do here!
- // This permits error checking, is it a good idea?
- // ROSE_ASSERT(scope->hasMangledName() == false);
- }
- }
- // DQ (2/18/2006): Not sure if adding "_variable_" really helps
- returnName = mangleScopeName + SgName("_variable_") + get_name();
- // printf ("In SgInitializedName::get_qualified_name() returnName = %s \n",returnName.str());
- return returnName;
- }
- #endif
- #if 0
- // DQ (3/31/2006): Commented out this older version (replaced with newer version).
- SgName
- SgInitializedName::get_mangled_name (void) const
- {
- SgName mangled_name; // return value
- SgName name = get_name ();
- SgScopeStatement* scope = get_scope ();
- ROSE_ASSERT (scope);
- if (name.get_length ()) // not empty
- {
- SgName qual_name = mangleQualifiers (scope);
- mangled_name = joinMangledQualifiers (qual_name, get_name ());
- }
- else // name is empty -- may be an anonymous (unnamed) function arg
- {
- const SgFunctionDefinition* func_def = isSgFunctionDefinition (scope);
- const SgFunctionParameterList* func_params =
- isSgFunctionParameterList (get_declaration ());
- if (func_def && func_params)
- {
- const SgInitializedNamePtrList& func_args = func_params->get_args ();
- // Find position (parameter number) in parameter list
- SgInitializedNamePtrList::const_iterator i;
- size_t param_num = 0;
- for (i = func_args.begin (); i != func_args.end (); ++i)
- {
- param_num++;
- if ((*i) == this)
- break;
- }
- if (i != func_args.end ()) // found position
- {
- ostringstream s;
- s << func_def->get_mangled_name ().str ()
- << "__ARG" << param_num;
- mangled_name = SgName (s.str ());
- }
- }
- }
- if (!mangled_name.get_length ()) // Could not come up with a name?
- {
- printf ("Error in SgInitializedName::get_mangled_name(void): zero length mangled name generated (see if this is realistic) \n");
- ROSE_ASSERT(false);
- // Default: Use pointer value to at least get a unique name
- ostringstream s;
- s << class_name () << "__" << (void *)(this);
- mangled_name = SgName (s.str ().c_str ());
- }
- return mangled_name;
- }
- #endif
- // DQ (3/31/2006): New version from Rich (fixes bug where empty mangled name was generated)
- SgName
- SgInitializedName::get_mangled_name (void) const
- {
- SgName mangled_name; // return value
- // Case 1: Function parameters.
- // Generate names for parameters such that
- // int foo (int x, int y) { return x + y; }
- // int foo (int, int);
- // int foo (int a, int b);
- // all generate the same unique names for equivalent parameters.
- const SgFunctionParameterList* func_params = isSgFunctionParameterList (get_declaration ());
- if (func_params)
- {
- // Find position (parameter number) in parameter list
- const SgInitializedNamePtrList& func_args = func_params->get_args ();
- SgInitializedNamePtrList::const_iterator i;
- size_t param_num = 0;
- for (i = func_args.begin (); i != func_args.end () && *i != this; ++i)
- param_num++;
- if (i != func_args.end ()) // found position
- {
- // Compute a mangled prefix from the function declaration.
- ostringstream s;
- const SgFunctionDeclaration* func_decl = isSgFunctionDeclaration (func_params->get_parent ());
- if (func_decl)
- s << func_decl->get_mangled_name ().str ();
- s << "__ARG" << param_num+1; // Append argument number (1-based)
- mangled_name = SgName (s.str ());
- }
- // else, an error (see below).
- }
- else // Case 2: Not a function parameter
- {
- SgScopeStatement* scope = get_scope ();
- if (scope == NULL)
- {
- printf ("SgInitializedName = %p = %s \n",this,get_name().str());
- get_file_info()->display("Error scope of SgInitializedName == NULL");
- }
- ROSE_ASSERT (scope != NULL);
- SgName qual_name = mangleQualifiers (scope);
- SgName name = get_name();
- if (name.get_length() > 0) // not empty
- {
- mangled_name = joinMangledQualifiers (qual_name, get_name ());
- }
- else
- {
- // name is empty
- if (isSgCatchOptionStmt (scope)) // e.g., 'try {...} catch (int) {...}
- {
- mangled_name = joinMangledQualifiers (qual_name, SgName ("CATCHARG"));
- }
- else
- {
- // printf ("Must be a padding declaration (e.g. int:16) \n");
- mangled_name = joinMangledQualifiers (qual_name, SgName ("PADDING_VARIABLE"));
- }
- }
- }
- if (!mangled_name.get_length ()) // Error: could not come up with a name.
- {
- printf ("Error in SgInitializedName::get_mangled_name(void): zero length mangled name generated (see if this is realistic)\n");
- SgScopeStatement* scope = get_scope ();
- ROSE_ASSERT (scope);
- printf (" Surrounding scope is '%s'\n", scope->sage_class_name ());
- const SgDeclarationStatement* decl = get_declaration ();
- printf (" Decl is '%s'\n", decl ? decl->sage_class_name () : "(none)");
- const SgDeclarationStatement* def = get_definition ();
- printf (" Def is '%s'\n", def ? def->sage_class_name () : "(none)");
- const SgNode* par = decl ? decl->get_parent () : 0;
- printf (" Parent(decl) is '%s'\n", par ? par->sage_class_name () : "(none)");
- // DQ (2/21/2007): I think this is OK for un-named function parameters, leave as a warning for now!.
- // ROSE_ASSERT(false);
- }
- return mangled_name;
- }
- // QY 11/3/04
- SgDeclarationStatement*
- SgInitializedName::get_declaration() const
- {
- // DQ (6/13/2005): This function assumes that the parents have been set!
- // so it should not be used in the EDG/Sage translation!
- // ROSE_ASSERT(get_parent() != NULL);
- #if 1
- // DQ (6/21/2006): Return to using this version of the code
- // DQ (6/21/2005): This is trying to traverse back through the scopes which might not make sense
- for (SgNode* r = get_parent(); r != NULL; r = r->get_parent())
- {
- SgDeclarationStatement* d = isSgDeclarationStatement(r);
- // DQ (6/21/2005): I think this should always be true!
- // ROSE_ASSERT(d != NULL);
- if (d != NULL) {
- return d;
- }
- }
- return NULL;
- #else
- // DQ (6/18/2006): Since we store the declaration we should use the explictly stored
- // value instead of anything generated from parents (structure can be problematic for C++).
- return get_declptr();
- #endif
- }
- SgDeclarationStatement*
- SgInitializedName::get_definition() const
- {
- // printf ("Why does SgInitializedName::get_definition() return a declaration! \n");
- // DQ (6/21/2005): Because the SgVariableDefinition is derived from a SgDeclarationStatement
- // and we return a SgVariableDefinition
- // DQ (6/21/2005): Is this always true? NO!
- // ROSE_ASSERT(isSgVariableDefinition(get_declptr()) != NULL);
- return get_declptr();
- }
- /*
- void
- SgInitializedName::set_declaration(SgDeclarationStatement * decl)
- {
- //p_declptr = decl;
- set_parent(decl);
- }
- */
- void
- SgInitializedName::set_definition(SgDeclarationStatement * def)
- {
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- // DQ (6/12/2007): New access function tests using DEBUG_SAGE_ACCESS_FUNCTIONS and
- // DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION in sage3.h indicate this is required.
- if (get_declptr() != NULL)
- {
- printf ("Note: overwriting SgInitializedName::get_declptr() = %p with NULL before assignment to def = %p \n",get_declptr(),def);
- set_declptr(NULL);
- }
- #endif
- set_declptr(def);
- }
- #if 0
- SgInitializedName*
- SgInitializedName::get_prev_decl_item() const
- { if(p_is_initializer) return 0; else return p_prev_itemptr; }
- void
- SgInitializedName::set_prev_decl_item(SgInitializedName * item)
- { p_prev_itemptr=item; p_is_initializer=0; }
- SgInitializedName*
- SgInitializedName::get_named_item() const
- { return p_itemptr; }
- void
- SgInitializedName::set_named_item(SgInitializedName* item)
- { p_itemptr=item; }
- #endif
- #if 0
- // DQ (1/18/2006): This is not generated due to the name change of "fileInfo" to "file_info"
- Sg_File_Info*
- SgInitializedName::get_file_info(void) const
- {
- // DQ (8/2/2004): Force an explicit function matching the virtual function defined in SgNode
- // but use the new name internally
- // ROSE_ASSERT ( p_fileInfo != NULL);
- return p_fileInfo;
- }
- #endif
- #if 0
- // DQ (4/3/2004): Added support for storage class attributes
- int
- SgInitializedName::checkBit(unsigned int bit) const
- { if (p_storage_class_attributes & bit) return 1; else return 0; }
- void
- SgInitializedName::setBit(unsigned int bit)
- { p_storage_class_attributes |= bit; }
- void
- SgInitializedName::unsetBit(unsigned int bit)
- { p_storage_class_attributes &= ~bit; }
- int
- SgInitializedName::isExtern() const
- { return checkBit(e_extern); }
- void
- SgInitializedName::setExtern()
- { setBit(e_extern); }
- void
- SgInitializedName::unsetExtern()
- { unsetBit(e_extern); }
- int
- SgInitializedName::isStatic() const
- { return checkBit(e_static); }
- void
- SgInitializedName::setStatic()
- { setBit(e_static); }
- void
- SgInitializedName::unsetStatic()
- { unsetBit(e_static); }
- int
- SgInitializedName::isAuto() const
- { return checkBit(e_auto); }
- void
- SgInitializedName::setAuto()
- { setBit(e_auto); }
- void
- SgInitializedName::unsetAuto()
- { unsetBit(e_auto); }
- int
- SgInitializedName::isRegister() const
- { return checkBit(e_register); }
- void
- SgInitializedName::setRegister()
- { setBit(e_register); }
- void
- SgInitializedName::unsetRegister()
- { unsetBit(e_register); }
- int
- SgInitializedName::isAsm() const
- { return checkBit(e_asm); }
- void
- SgInitializedName::setAsm()
- { setBit(e_asm); }
- void
- SgInitializedName::unsetAsm()
- { unsetBit(e_asm); }
- #endif
- unsigned int
- SgInitializedName::cfgIndexForEnd() const {
- return this->get_initializer() ? 1 : 0;
- }
- bool
- SgInitializedName::cfgIsIndexInteresting(unsigned int idx) const {
- return true;
- }
- unsigned int
- SgInitializedName::cfgFindChildIndex(SgNode* n)
- {
- // This function could be rewritten to be:
- // Check for inappropriate child in initialized name
- // ROSE_ASSERT(n == this->get_initializer());
- // return 0;
- if (n == this->get_initializer())
- {
- return 0;
- }
- else
- ROSE_ASSERT (!"Bad child in initialized name");
- // DQ (8/24/2006): Added return to avoid compiler warning!
- return 0;
- }
- unsigned int
- SgInitializedName::cfgFindNextChildIndex(SgNode* n) {
- return this->cfgFindChildIndex(n) + 1;
- }
- std::vector<VirtualCFG::CFGEdge>
- SgInitializedName::cfgOutEdges(unsigned int idx) {
- std::vector<VirtualCFG::CFGEdge> result;
- switch (idx) {
- case 0:
- if (this->get_initializer()) {
- makeEdge(VirtualCFG::CFGNode(this, idx), this->get_initializer()->cfgForBeginning(),
- result);
- } else {
- makeEdge(VirtualCFG::CFGNode(this, idx), VirtualCFG::getNodeJustAfterInContainer(this), result);
- }
- break;
- case 1:
- ROSE_ASSERT (this->get_initializer());
- makeEdge(VirtualCFG::CFGNode(this, idx), VirtualCFG::getNodeJustAfterInContainer(this), result);
- break;
- default: ROSE_ASSERT (!"Bad index in SgInitializedName");
- }
- return result;
- }
- std::vector<VirtualCFG::CFGEdge>
- SgInitializedName::cfgInEdges(unsigned int idx) {
- std::vector<VirtualCFG::CFGEdge> result;
- switch (idx) {
- case 0:
- makeEdge(VirtualCFG::getNodeJustBeforeInContainer(this), VirtualCFG::CFGNode(this, idx), result);
- break;
- case 1:
- ROSE_ASSERT (this->get_initializer());
- makeEdge(this->get_initializer()->cfgForEnd(),
- VirtualCFG::CFGNode(this, idx), result);
- break;
- default: ROSE_ASSERT (!"Bad index in SgInitializedName");
- }
- return result;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgInitializedName::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgInitializedName::variantT() const {
- return V_SgInitializedName;
- }
- #if 0
- int
- SgInitializedName::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return InitializedNameTag;
- }
- #endif
- const char*
- SgInitializedName::sage_class_name() const
- {
- assert(this != NULL);
- return "SgInitializedName";
- }
- std::string
- SgInitializedName::class_name() const
- {
- assert(this != NULL);
- return "SgInitializedName";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgInitializedName::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- SgInitializedName::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != InitializedNameTag)
- {
- printf ("Error in SgInitializedName::error(): SgInitializedName object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgInitializedName::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == InitializedNameTag);
- return SgSupport::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgInitializedName::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgInitializedName::variant() const \n");
- #endif
- assert(this != NULL);
- return InitializedNameTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgInitializedName* isSgInitializedName ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgInitializedName*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgInitializedName* isSgInitializedName ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgInitializedName*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgInitializedName::~SgInitializedName ()
- {
- #if 0
- // debugging information!
- printf ("In SgInitializedName::~SgInitializedName (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- delete p_startOfConstruct;
- delete p_storageModifier;
- // case: not a listType for startOfConstruct
- p_startOfConstruct = NULL; // non list case
- // case: not a listType for name
- p_name = NULL; // non list case
- // case: not a listType for typeptr
- p_typeptr = NULL; // non list case
- // case: not a listType for initptr
- p_initptr = NULL; // non list case
- // case: not a listType for prev_decl_item
- p_prev_decl_item = NULL; // non list case
- // case: not a listType for is_initializer
- p_is_initializer = false; // non list case
- // case: not a listType for declptr
- p_declptr = NULL; // non list case
- // case: not a listType for storageModifier
- p_storageModifier = NULL; // non list case
- // case: not a listType for scope
- p_scope = NULL; // non list case
- // case: not a listType for preinitialization
- p_preinitialization = e_unknown_preinitialization; // non list case
- // case: not a listType for attributeMechanism
- p_attributeMechanism = NULL; // non list case
- // case: not a listType for register_name_code
- p_register_name_code = SgInitializedName::e_invalid_register; // non list case
- // case: not a listType for register_name_string
- p_register_name_string = ""; // non list case
- // case: not a listType for requiresGlobalNameQualificationOnType
- p_requiresGlobalNameQualificationOnType = false; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarConstructorDefinitionMacros.macro"
- // Generated constructor
- SgInitializedName::SgInitializedName ( )
- : SgSupport()
- {
- #ifdef DEBUG
- // printf ("In SgInitializedName::SgInitializedName () sage_class_name() = %s \n",sage_class_name());
- #endif
- p_startOfConstruct = NULL;
- p_name = NULL;
- p_typeptr = NULL;
- p_initptr = NULL;
- p_prev_decl_item = NULL;
- p_is_initializer = false;
- p_declptr = NULL;
- p_storageModifier = NULL;
- p_scope = NULL;
- p_preinitialization = e_unknown_preinitialization;
- p_attributeMechanism = NULL;
- p_register_name_code = SgInitializedName::e_invalid_register;
- p_register_name_string = "";
- p_requiresGlobalNameQualificationOnType = false;
- #line 11 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarConstructorDefinitionMacros.macro"
- // Test the variant virtual function
- assert(InitializedNameTag == variant());
- post_construction_initialization();
- // Test the isSgInitializedName() function since it has been problematic
- assert(isSgInitializedName(this) != NULL);
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- Sg_File_Info::get_file_id () const
- {
- assert (this != NULL);
- return p_file_id;
- }
- void
- Sg_File_Info::set_file_id ( int file_id )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_file_id = file_id;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgFileIdList
- Sg_File_Info::get_fileIDsToUnparse () const
- {
- assert (this != NULL);
- return p_fileIDsToUnparse;
- }
- void
- Sg_File_Info::set_fileIDsToUnparse ( SgFileIdList fileIDsToUnparse )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fileIDsToUnparse = fileIDsToUnparse;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::map<int, std::string>
- Sg_File_Info::get_fileidtoname_map () const
- {
- assert (this != NULL);
- return p_fileidtoname_map;
- }
- void
- Sg_File_Info::set_fileidtoname_map ( std::map<int, std::string> fileidtoname_map )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fileidtoname_map = fileidtoname_map;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::map<std::string, int>
- Sg_File_Info::get_nametofileid_map () const
- {
- assert (this != NULL);
- return p_nametofileid_map;
- }
- void
- Sg_File_Info::set_nametofileid_map ( std::map<std::string, int> nametofileid_map )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_nametofileid_map = nametofileid_map;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- Sg_File_Info::get_max_file_id () const
- {
- assert (this != NULL);
- return p_max_file_id;
- }
- void
- Sg_File_Info::set_max_file_id ( int max_file_id )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_max_file_id = max_file_id;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 7784 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- int Sg_File_Info::p_cur_line ROSE_DEPRECATED_VARIABLE = 0;
- std::string Sg_File_Info::p_cur_file ROSE_DEPRECATED_VARIABLE = "";
- // MK (7/22/05) : Added support for file ids. Here we initialize the static file maps, etc
- int Sg_File_Info::p_max_file_id = 0;
- std::map<std::string, int> Sg_File_Info::p_nametofileid_map;
- std::map<int, std::string> Sg_File_Info::p_fileidtoname_map;
- // DQ (7/4/2005): Added to test internal consistancy
- bool
- Sg_File_Info::ok() const
- {
- ROSE_ASSERT(this != NULL);
- bool lineNumberOK = p_line > 0;
- bool columnNumberOK = p_col > 0;
- // MK (7/22/05) We compare using p_fileid instead of p_filename now
- // bool filenameOK = p_filename != NULL;
- bool filenameOK = p_file_id != NULL_FILE_ID;
- // A compiler generated node has no defined association with a file, line number, or column number.
- bool compilerGenerated = isCompilerGenerated();
- // DQ (11/22/2006): Some nodes have no source position information and we have the live with this at points in the processing.
- // A node which was explicitly marked as a sourcePositionUnavailableInFrontendcompiler has no defined association with a file, line number, or column number.
- bool sourcePositionUnavailableInFrontend = isSourcePositionUnavailableInFrontend();
- // DQ (12/23/2006): If this is part of a transformation then it is OK by definition.
- // A node introduced as part of a transformation has no defined association with a file, line number, or column number.
- bool transformation = isTransformation();
- // return compilerGenerated || (lineNumberOK && filenameOK);
- // return sourcePositionUnavailableInFrontend || compilerGenerated || (lineNumberOK && filenameOK);
- // return transformation || sourcePositionUnavailableInFrontend || compilerGenerated || (lineNumberOK && columnNumberOK && filenameOK);
- return (lineNumberOK && columnNumberOK && filenameOK) || compilerGenerated || sourcePositionUnavailableInFrontend || transformation;
- }
- void
- Sg_File_Info::updateSourcePosition ( Sg_File_Info* update )
- {
- // DQ (12/22/2006): This copies the line number and column number information and verifies that
- // the file name is the same (it does not reset any fo the classification flags). This is more
- // useful than the assignment operator for updating information and is used in the file:
- // fixupSourcePositionInformation.C.
- ROSE_ASSERT(update != NULL);
- // Must have matching file name (only have to compare file_id's)
- ROSE_ASSERT(p_file_id == update->p_file_id);
- // Update only the line number and column number after verifying that the filenames are the same.
- p_line = update->p_line;
- p_col = update->p_col;
- }
- // DQ (8/1/2005): use static function to return new Sg_File_Info object set to default values
- // Static function to return new Sg_File_Info object set to default values
- Sg_File_Info* Sg_File_Info::generateDefaultFileInfo()
- {
- Sg_File_Info* returnValue = new Sg_File_Info("NULL_FILE",0,0);
- ROSE_ASSERT(returnValue != NULL);
- // DQ (6/7/2007): This causes "NULL_FILE" filenames to be introduced into the AST.
- // Gergo pointed out this problems and removing such entries will simplify the tests
- // that are done in the traverseInputFile traversal.
- // printf ("Sg_File_Info::generateDefaultFileInfo(): This function is depricated and is an error to call! \n");
- // ROSE_ASSERT(false);
- // printf ("Calling Sg_File_Info::generateDefaultFileInfo(): returnValue = %p \n",returnValue);
- return returnValue;
- }
- // Static function to return new Sg_File_Info object set to default values appropriate for transformations
- // static Sg_File_Info* generateTransformationDefaultFileInfo()
- Sg_File_Info* Sg_File_Info::generateDefaultFileInfoForTransformationNode()
- {
- // IR nodes using this function's return value will be marked as transformations
- Sg_File_Info* returnValue = generateDefaultFileInfo();
- returnValue->setTransformation();
- // DQ (1/11/2006): Added call to setOutputInCodeGeneration() because the default
- // behavior is to output all transformations. Other functions allow transformations
- // to be specified that would not be output (useful for when including new header files).
- returnValue->setOutputInCodeGeneration();
- returnValue->set_file_id( TRANSFORMATION_FILE_ID );
- return returnValue;
- }
- // DQ (1/11/2006): Added version of function where filename (file_id) can
- // be explicitly set to be the non-default value.
- Sg_File_Info* Sg_File_Info::generateFileInfoForTransformationNode( int file_id )
- {
- // IR nodes using this function's return value will be marked as transformations
- Sg_File_Info* returnValue = generateDefaultFileInfoForTransformationNode();
- returnValue->set_file_id( file_id );
- return returnValue;
- }
- // DQ (1/11/2006): Added version of function where filename (file_id) can
- // be explicitly set to be the non-default value.
- Sg_File_Info* Sg_File_Info::generateFileInfoForTransformationNode( string filename )
- {
- // IR nodes using this function's return value will be marked as transformations
- Sg_File_Info* returnValue = generateDefaultFileInfoForTransformationNode();
- returnValue->set_filenameString( filename );
- return returnValue;
- }
- // Static function to return new Sg_File_Info object set to default values appropriate for compiler generated code
- // static Sg_File_Info* generateCompilerGeneratedDefaultFileInfo()
- Sg_File_Info* Sg_File_Info::generateDefaultFileInfoForCompilerGeneratedNode()
- {
- // IR nodes using this function's return value will be marked as compiler generated (but not output, unless also marked as such)
- Sg_File_Info* returnValue = generateDefaultFileInfo();
- returnValue->setCompilerGenerated();
- returnValue->set_file_id( COMPILER_GENERATED_FILE_ID );
- return returnValue;
- }
- // DQ (11/2/2006): Added operator= member function to simple assignment (used in fixupSourcePositionInformation.C
- // to modify Sg_File_Info objects so that they better reflect the original source code).
- Sg_File_Info &
- Sg_File_Info::operator= ( const Sg_File_Info & X )
- {
- p_file_id = X.p_file_id;
- p_line = X.p_line;
- p_col = X.p_col;
- p_classificationBitField = X.p_classificationBitField;
- p_fileIDsToUnparse = X.p_fileIDsToUnparse;
- // Record that this source position information was updated.
- set_isModified(true);
- return *this;
- }
- // DQ (9/26/2004): Added operator== friend function to permit testing of reused definitions of defining declarations!
- bool
- operator== ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- bool returnValue = false;
- // Make this most efficent by putting the least likely match first
- // (col, line, file) and the most expensive test (file) last.
- if (X.get_col() == Y.get_col())
- {
- if (X.get_line() == Y.get_line())
- {
- // MK (7/22/05) : Replaced string comparisons with file_id comparisons
- /*
- if ( string(X.get_filename()) == string(Y.get_filename()))
- {
- returnValue = true;
- }
- */
- if (X.p_file_id == Y.p_file_id)
- {
- returnValue = true;
- }
- }
- }
- return returnValue;
- }
- // DQ (10/6/2004): Added operator!= friend function to permit testing of reused definitions of defining declarations!
- bool
- operator!= ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- return operator==(X,Y) ? false : true;
- }
- // DQ (10/25/2004): Added relational operators to permit testing of strting vs. ending file info object (assert starting < ending)
- bool
- operator> ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- bool result = false;
- // printf ("In operator > (Sg_File_Info,Sg_File_Info): X.isSameFile(Y) = %s \n",X.isSameFile(Y) ? "true" : "false");
- if (X.isSameFile(Y) == true)
- {
- // printf ("X.p_line = %d Y.p_line = %d \n",X.p_line,Y.p_line);
- // printf ("X.p_col = %d Y.p_col = %d \n",X.p_col,Y.p_col);
- if (X.p_line > Y.p_line)
- {
- // printf ("TRUE: X.p_line = %d > X.p_line = %d \n",X.p_line,X.p_line);
- result = true;
- }
- else
- {
- if (X.p_line == Y.p_line)
- {
- if (X.p_col > Y.p_col)
- {
- // printf ("TRUE: X.p_col = %d > Y.p_col = %d \n",X.p_col,Y.p_col);
- result = true;
- }
- }
- }
- }
- // printf ("Sorry operator> (const Sg_File_Info & X, const Sg_File_Info & Y) not implemented! \n");
- // ROSE_ASSERT(false);
- // return true;
- return result;
- }
- bool
- operator< ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- bool result = false;
- // printf ("In operator < (Sg_File_Info,Sg_File_Info): X.isSameFile(Y) = %s \n",X.isSameFile(Y) ? "true" : "false");
- if (X.isSameFile(Y) == true)
- {
- // printf ("X.p_line = %d Y.p_line = %d \n",X.p_line,Y.p_line);
- // printf ("X.p_col = %d Y.p_col = %d \n",X.p_col,Y.p_col);
- if (X.p_line < Y.p_line)
- {
- // printf ("TRUE: X.p_line = %d < Y.p_line = %d \n",X.p_line,Y.p_line);
- result = true;
- }
- else
- {
- if (X.p_line == Y.p_line)
- {
- if (X.p_col < Y.p_col)
- {
- // printf ("TRUE: X.p_col = %d < Y.p_col = %d \n",X.p_col,Y.p_col);
- result = true;
- }
- }
- }
- }
- // printf ("Sorry operator< (const Sg_File_Info & X, const Sg_File_Info & Y) not implemented! \n");
- // ROSE_ASSERT(false);
- // return true;
- return result;
- }
- bool
- operator>= ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- bool result = false;
- if (X.isSameFile(Y) == true)
- {
- if (X.p_line > Y.p_line)
- {
- result = true;
- }
- else
- {
- if (X.p_line == Y.p_line)
- {
- if (X.p_col >= Y.p_col)
- result = true;
- }
- }
- }
- // printf ("Sorry operator>= (const Sg_File_Info & X, const Sg_File_Info & Y) not implemented! \n");
- // ROSE_ASSERT(false);
- // return true;
- return result;
- }
- bool
- operator<= ( const Sg_File_Info & X, const Sg_File_Info & Y )
- {
- bool result = false;
- if (X.isSameFile(Y) == true)
- {
- if (X.p_line < Y.p_line)
- {
- result = true;
- }
- else
- {
- if (X.p_line == Y.p_line)
- {
- if (X.p_col <= Y.p_col)
- result = true;
- }
- }
- }
- // printf ("Sorry operator<= (const Sg_File_Info & X, const Sg_File_Info & Y) not implemented! \n");
- // ROSE_ASSERT(false);
- // return true;
- return result;
- }
- void
- Sg_File_Info::display( const std::string label ) const
- {
- ROSE_ASSERT(this != NULL);
- printf ("Inside of Sg_File_Info::display(%s) \n",label.c_str());
- printf (" isTransformation = %s \n",isTransformation() == true ? "true (part of a transformation)" : "false");
- printf (" isCompilerGenerated = %s \n",isCompilerGenerated() == true ? "true (no position information)" : "false");
- printf (" isOutputInCodeGeneration = %s \n",isOutputInCodeGeneration() == true ? "true (output in code generator)" : "false");
- printf (" isShared = %s \n",isShared() == true ? "true (shared within merged AST)" : "false");
- printf (" isFrontendSpecific = %s \n",isFrontendSpecific() == true ? "true (part of ROSE support for gnu compatability)" : "false");
- printf (" isSourcePositionUnavailableInFrontend = %s \n",isSourcePositionUnavailableInFrontend() == true ? "true (source position unavailable in frontend)" : "false");
- printf (" isCommentOrDirective = %s \n",isCommentOrDirective() == true ? "true (this is a comment or CPP directive)" : "false");
- printf (" isToken = %s \n",isToken() == true ? "true (this is from the token stream woven into the AST)" : "false");
- // if (isCompilerGenerated() == false)
- if (!isTransformation() && !isCompilerGenerated())
- {
- printf (" filename = %s \n",get_filename());
- printf (" line = %d column = %d \n",get_line(),get_col());
- }
- // DQ (6/17/2005): Way to get extra debugging information, if the
- // substring "debug" is found then extra information is output
- // if (label == "debug")
- if (label.find("debug") != std::string::npos)
- {
- printf (" file_id = %d \n",get_file_id());
- printf (" filename = %s \n",get_raw_filename().c_str());
- printf (" line = %d column = %d \n",p_line,p_col);
- }
- // DQ (5/16/2005): output these values, but I think they might be removed
- // later since I don't see the point of storing this information!
- // printf (" isDeclaration = %s \n",isDeclaration() == true ? "true" : "false");
- // printf (" isInitialization = %s \n",isInitialization() == true ? "true" : "false");
- }
- string
- Sg_File_Info::displayString(const std::string & label ) const
- {
- ROSE_ASSERT(this != NULL);
- std::string s;
- s += std::string("Inside of Sg_File_Info::displayString(") + label + std::string (") \n");
- s += std::string("isTransformation = ") + std::string(isTransformation() ? "true" : "false") + std::string(" ");
- s += std::string("isCompilerGenerated = ") + std::string(isCompilerGenerated() ? "true" : "false") + std::string(" ");
- if (!isTransformation() && !isCompilerGenerated())
- {
- s += std::string("line number = ") + StringUtility::numberToString(get_line()) + std::string(" ");
- s += std::string("column number = ") + StringUtility::numberToString(get_col()) + std::string(" ");
- s += std::string("filename = ") + std::string(get_filename()) + std::string(" ");
- }
- return s;
- }
- void
- Sg_File_Info::display_static_data( const std::string label )
- {
- // DQ (6/11/2007): output static data for debugging
- printf ("Inside of Sg_File_Info::display_static_data(%s) \n",label.c_str());
- printf ("p_cur_line = %d \n",p_cur_line);
- printf ("p_cur_file = %s \n",p_cur_file.c_str());
- printf ("p_max_file_id = %d \n",p_max_file_id);
- printf ("p_nametofileid_map: \n");
- for (std::map<std::string,int>::iterator i = p_nametofileid_map.begin(); i != p_nametofileid_map.end(); i++)
- {
- printf ("name = %s id = %d \n",i->first.c_str(),i->second);
- }
- printf ("p_fileidtoname_map: \n");
- for (std::map<int,std::string>::iterator i = p_fileidtoname_map.begin(); i != p_fileidtoname_map.end(); i++)
- {
- printf ("id = %d name = %s \n",i->first,i->second.c_str());
- }
- }
- // Since we make the arguments in the other constructor
- // have default values this constructor is redundant/ambiguous
- // Sg_File_Info::Sg_File_Info() {}
- Sg_File_Info::Sg_File_Info ()
- {
- ROSE_ASSERT(this != NULL);
- // Default constructor used for making copies of subtrees
- p_line = 0;
- p_col = 0;
- p_classificationBitField = 0;
- // MK (7/22/05) : Initialize p_file_id to inidicate a copy
- p_file_id = COPY_FILE_ID;
- #if 0
- printf ("Sg_File_Info default constructor = %p \n",this);
- // display("In constructor");
- #endif
- // Provide a common function called for initialization support.
- post_construction_initialization();
- }
- // DQ (4/19/2006): Added constructor to take std::string as part of move
- // away from C style strings to C++ style strings.
- Sg_File_Info::Sg_File_Info ( const std::string & filename, int line, int col )
- : p_line(line), p_col(col)
- {
- ROSE_ASSERT(this != NULL);
- // DQ (5/11/2006): Allow "NULL_FILE" as a name (used within ROSE) to map to the NULL_FILE_ID
- // if (filename.empty() == true)
- if (filename.empty() == true || filename == "NULL_FILE")
- {
- p_file_id = NULL_FILE_ID;
- }
- else
- {
- // DQ (7/25/2005): Refactored to use set_filename()
- set_filenameString(filename);
- }
- p_classificationBitField = 0;
- ROSE_ASSERT (p_col >= 0);
- #if 0
- printf ("Sg_File_Info constructor(const std::string,int,int) = %p \n",this);
- // display("In constructor");
- #endif
- // Provide a common function called for initialization support.
- post_construction_initialization();
- }
- // DQ (2/15/2003): added copy constructor
- Sg_File_Info::Sg_File_Info(const Sg_File_Info & X)
- : p_file_id(X.p_file_id),
- p_line(X.p_line), p_col(X.p_col),
- // DQ (7/29/2005): Preserve IR node classification within copy constructor
- // p_classificationBitField(0)
- p_classificationBitField(X.p_classificationBitField),
- p_fileIDsToUnparse(X.p_fileIDsToUnparse)
- {
- ROSE_ASSERT(this != NULL);
- ROSE_ASSERT (p_col >= 0);
- #if 0
- printf ("Sg_File_Info copy constructor(const Sg_File_Info) = %p \n",this);
- // display("In copy constructor");
- #endif
- // Provide a common function called for initialization support.
- post_construction_initialization();
- }
- #if 0
- // This is now removed but saved becuase it might be that it should be depricated for a while
- Sg_File_Info::Sg_File_Info ( const char* filename, int line, int col )
- : p_line(line), p_col(col) // , p_isPartOfTransformation(false)
- {
- ROSE_ASSERT(this != NULL);
- if (!filename) {
- p_file_id = NULL_FILE_ID;
- }
- else
- {
- // DQ (7/25/2005): Refactored to use set_filename()
- set_filename(filename);
- }
- p_classificationBitField = 0;
- if (p_col < 0)
- {
- printf ("Error p_col = %d \n",p_col);
- }
- ROSE_ASSERT (p_col >= 0);
- // Provide a common function called for initialization support.
- post_construction_initialization();
- }
- #endif
- void
- Sg_File_Info::post_construction_initialization()
- {
- ROSE_ASSERT (this != NULL);
- // ROSE_ASSERT(this != (Sg_File_Info*) 0x5231b0);
- }
- void
- Sg_File_Info::set_line(int line)
- {
- ROSE_ASSERT (this != NULL);
- p_line = line;
- }
- void
- // DQ (9/5/2006): renamed functions to swap the implementations
- // Sg_File_Info::set_filename(const char* filename)
- Sg_File_Info::set_filenameString ( const std::string & filename )
- {
- ROSE_ASSERT (this != NULL);
- if (p_nametofileid_map.count(filename) == 0)
- {
- p_file_id = p_max_file_id++;
- p_nametofileid_map[filename] = p_file_id;
- p_fileidtoname_map[p_file_id] = filename;
- }
- else
- {
- p_file_id = p_nametofileid_map[filename];
- }
- // DQ (8/31/2006): We can't enforce that this is an absolute path (test2001_04.C and test2004_60.C demonstrate why).
- // DQ (8/31/2006): Verify that this is a absolute path
- // string targetSubstring = "/";
- // string filenameString = filename;
- // if (filenameString.substr(0,targetSubstring.size()) != targetSubstring)
- // printf ("@@@@@@@@@@@@@@@@@@@@ In Sg_File_Info::Sg_File_Info(string,int,int): filename = %s @@@@@@@@@@@@@@@@@@@@\n",filenameString.c_str());
- // ROSE_ASSERT(filenameString.substr(0,targetSubstring.size()) == targetSubstring);
- // Detect use of AST Rewrite intermediate files (need to make sure they get absolute paths)
- // string targetSubstring2 = "rose_";
- // ROSE_ASSERT(filenameString.substr(0,targetSubstring2.size()) != targetSubstring2);
- }
- void
- // DQ (9/5/2006): renamed functions to swap the implementations
- // Sg_File_Info::set_filenameString ( const std::string & filename )
- Sg_File_Info::set_filename(const char* filename)
- {
- // DQ (9/5/2006): Modified implementation
- // set_filename(filename.c_str());
- ROSE_ASSERT(filename != NULL);
- set_filenameString(filename);
- }
- const std::string&
- Sg_File_Info::get_filenameString() const
- {
- ROSE_ASSERT (this != NULL);
- // return p_filename;
- const std::string* returnString = NULL;
- if (isTransformation() == true)
- {
- #if PRINT_DEVELOPER_WARNINGS
- // DQ (2/25/2006): Unclear how often we want to have this output, it is sometimes useful and sometime annoying.
- printf ("Sg_File_Info::get_filename called for transformation IR node \n");
- #endif
- static const std::string transformation_string = "transformation";
- returnString = &transformation_string;
- }
- else if(isCompilerGenerated() == true)
- {
- // DQ (8/17/2005): only "compilergenerated" when compiler generate (not when marked for output)
- // if ( isCompilerGenerated() == true || isCompilerGeneratedNodeToBeUnparsed() == true )
- // printf ("Sg_File_Info::get_filename called for compiler generated IR node \n");
- static const std::string compilerGenerated_string = "compilerGenerated";
- returnString = &compilerGenerated_string;
- }else {
- #if 0
- const char * tmp = getFilenameFromID(p_file_id).c_str();
- int length = strlen(tmp) + 1;
- returnString = new char[length];
- strncpy(returnString, tmp, length);
- #endif
- returnString = &getFilenameFromID(p_file_id);
- }
- ROSE_ASSERT (returnString != NULL);
- return *returnString;
- }
- const char*
- Sg_File_Info::get_filename() const
- {
- // DQ (10/15/2005): This function is the C++ string version of the get_filename()
- // function which has been depricated. At some point the get_filename() function
- // will be eliminated and later reinfroduced as get_filename() (finally returning
- // a C++ string instead of a char* (C style string)).
- return get_filenameString().c_str();
- }
- string
- Sg_File_Info::get_raw_filename() const
- {
- ROSE_ASSERT (this != NULL);
- // return whatever name is in the map
- return getFilenameFromID(p_file_id);
- }
- int
- Sg_File_Info::get_line() const
- {
- ROSE_ASSERT (this != NULL);
- // return p_line;
- // const int undefinedValue = INT_MAX-1;
- const int undefinedValue = 0;
- int returnValue = 0;
- if (isTransformation() == true)
- {
- // printf ("Sg_File_Info::get_line called for transformation IR node (p_line = %d) \n",p_line);
- returnValue = undefinedValue;
- }
- else
- {
- // DQ (8/17/2005): only undefinedValue when compiler generate (not when marked for output)
- // if ( isCompilerGenerated() == true || isCompilerGeneratedNodeToBeUnparsed() == true )
- if ( isCompilerGenerated() == true )
- {
- // printf ("Sg_File_Info::get_line called for compiler generated IR node (p_line = %d) \n",p_line);
- // DQ (6/14/2005): Temp code to permit identification of line number of template declaration!
- // returnValue = undefinedValue;
- // returnValue = p_line;
- returnValue = undefinedValue;
- }
- else
- {
- returnValue = p_line;
- }
- }
- ROSE_ASSERT (returnValue >= 0);
- return returnValue;
- }
- int
- Sg_File_Info::get_raw_line() const
- {
- ROSE_ASSERT (this != NULL);
- return p_line;
- }
- int
- Sg_File_Info::get_col() const
- {
- ROSE_ASSERT (this != NULL);
- ROSE_ASSERT (p_col >= 0);
- // return p_col;
- // const int undefinedValue = INT_MAX-1;
- const int undefinedValue = 0;
- int returnValue = 0;
- if (isTransformation() == true)
- {
- // printf ("Sg_File_Info::get_col called for transformation IR node \n");
- returnValue = undefinedValue;
- }
- else
- {
- // DQ (8/17/2005): only undefinedValue when compiler generate (not when marked for output)
- // if ( isCompilerGenerated() == true || isCompilerGeneratedNodeToBeUnparsed() == true )
- if ( isCompilerGenerated() == true )
- {
- // printf ("Sg_File_Info::get_col called for compiler generated IR node \n");
- returnValue = undefinedValue;
- }
- else
- {
- returnValue = p_col;
- }
- }
- ROSE_ASSERT (returnValue >= 0);
- return returnValue;
- }
- int
- Sg_File_Info::get_raw_col() const
- {
- ROSE_ASSERT (this != NULL);
- ROSE_ASSERT (p_col >= 0);
- return p_col;
- }
- // DQ (5/24/2005): This function is impemented using the newer classification mechanism
- void
- Sg_File_Info::set_isPartOfTransformation( bool isPartOfTransformation )
- {
- ROSE_ASSERT (this != NULL);
- // p_isPartOfTransformation = isPartOfTransformation;
- if (isPartOfTransformation == true)
- setTransformation();
- else
- unsetTransformation();
- }
- // DQ (5/24/2005): This function is impemented using the newer classification mechanism
- bool
- Sg_File_Info::get_isPartOfTransformation()
- {
- ROSE_ASSERT (this != NULL);
- // return p_isPartOfTransformation;
- return isTransformation();
- }
- void
- Sg_File_Info::register_node(SgLocatedNode* node)
- {} /* register interest */
- void
- Sg_File_Info::deregister_node(SgLocatedNode* node)
- {}
- // functions added by Dan Quinlan (suggested by Gary Lee)
- void
- Sg_File_Info::set_col( int n )
- {
- ROSE_ASSERT (this != NULL);
- p_col = n;
- ROSE_ASSERT (p_col >= 0);
- }
- int
- Sg_File_Info::getCurrentLine () const
- {
- ROSE_ASSERT (this != NULL);
- printf ("This is a depricated function: char* Sg_File_Info::getCurrentLine() const \n");
- return p_cur_line;
- }
- std::string
- Sg_File_Info::getCurrentFilename () const
- {
- ROSE_ASSERT (this != NULL);
- printf ("This is a depricated function: char* Sg_File_Info::getCurrentFilename() const \n");
- return p_cur_file;
- }
- bool
- Sg_File_Info::hasPositionInSource() const
- {
- ROSE_ASSERT(this != NULL);
- // DQ (1/11/2006): Modified to not use the output function which mixed
- // concepts of compiler generated with output (deprecated function).
- // bool result = ( ! ( isTransformation() || isCompilerGenerated() || isCompilerGeneratedNodeToBeUnparsed() ) );
- bool result = ( ! ( isTransformation() || isCompilerGenerated() || isOutputInCodeGeneration() ) );
- return result;
- }
- bool
- Sg_File_Info::isSameFile(SgFile* file) const
- {
- // DQ (6/21/2005): check if this file info object is from the same file
- // This function abstracts the mechanism of comparing if a file info object is associated with a specific SgFile.
- // this function will be made more efficient later when we can abstract out the string comparision from the test.
- // Later we will implement a map from filename to unique "file number identifiers", this will permit significant
- // spaces saving in the IR by avoiding redundant storage of filename strings and also improve the efficiency of
- // testing if two file info objects represent the same file (an integer equality test instead of string comparision).
- // File names are particularly long (since they include full path), so this will allow us to save a lot of space.
- ROSE_ASSERT(this != NULL);
- ROSE_ASSERT(file != NULL);
- // MK (7/22/05) : removing use of p_filename in favor of p_file_id
- // Generate names of the files
- /*
- string inputFilename = file->getFileName();
- string currentFilename = get_filename();
- bool result = (currentFilename == inputFilename);
- */
- SgScopeStatement * globalScope = (SgScopeStatement *)(file->get_root());
- ROSE_ASSERT(globalScope != NULL);
- Sg_File_Info* fileInfo = globalScope->get_file_info();
- ROSE_ASSERT(fileInfo != NULL);
- bool result = (p_file_id == fileInfo->get_file_id());
- return result;
- }
- // DQ (1/18/2006): Added new function with more useful interface.
- bool
- Sg_File_Info::isSameFile(Sg_File_Info* fileInfo) const
- {
- ROSE_ASSERT(fileInfo != NULL);
- bool result = (p_file_id == fileInfo->get_file_id());
- return result;
- }
- // DQ (1/18/2006): Added new function with more useful interface.
- bool
- Sg_File_Info::isSameFile(const Sg_File_Info & fileInfo) const
- {
- bool result = (p_file_id == fileInfo.get_file_id());
- return result;
- }
- //! Access functions for classification of File_Info objects
- bool
- Sg_File_Info::isTransformation() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_transformation);
- }
- void
- Sg_File_Info::setTransformation()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_transformation;
- }
- void
- Sg_File_Info::unsetTransformation()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_transformation;
- }
- bool
- Sg_File_Info::isCompilerGenerated() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_compiler_generated);
- }
- void
- Sg_File_Info::setCompilerGenerated()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_compiler_generated;
- }
- void
- Sg_File_Info::unsetCompilerGenerated()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_compiler_generated;
- }
- // bool isCompilerGeneratedNodeToBeUnparsed() const;
- bool
- Sg_File_Info::isCompilerGeneratedNodeToBeUnparsed() const
- {
- // Make sure that both bits are set!
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_output_in_code_generation);
- #if 0
- // DQ (6/17/2005): Allow these to be set separately so that setting a whole function to
- // be unparsed will not make any expecific casts as compiler generated and not required!
- // If casts are the only issue then perhaps they should be marked explicitly as implicit
- // or explicit (rather than compiler generated).
- bool result = (p_classificationBitField & e_output_in_code_generation);
- // error checking: if e_compiler_generated_node_to_be_unparsed then also e_compiler_generated
- if (result == true)
- ROSE_ASSERT(isCompilerGenerated() == true);
- return result;
- #endif
- }
- void
- Sg_File_Info::setCompilerGeneratedNodeToBeUnparsed()
- {
- // Make sure that both bits are set!
- // setCompilerGenerated();
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_output_in_code_generation;
- }
- void
- Sg_File_Info::unsetCompilerGeneratedNodeToBeUnparsed()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_output_in_code_generation;
- }
- bool
- Sg_File_Info::isOutputInCodeGeneration() const
- {
- // Make sure that both bits are set!
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_output_in_code_generation);
- }
- void
- Sg_File_Info::setOutputInCodeGeneration()
- {
- // Make sure that both bits are set!
- // setCompilerGenerated();
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_output_in_code_generation;
- }
- void
- Sg_File_Info::unsetOutputInCodeGeneration()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_output_in_code_generation;
- }
- bool
- Sg_File_Info::isShared() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_shared);
- }
- void
- Sg_File_Info::setShared()
- {
- // MK (8/3/05) : We always want to unparse the current file (this is a performance issue)
- ROSE_ASSERT(this != NULL);
- if (isShared() == false)
- p_fileIDsToUnparse.insert(p_file_id);
- p_classificationBitField |= e_shared;
- }
- void
- Sg_File_Info::unsetShared()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_shared;
- // MK (8/2/05) : Initialize the fileid set
- p_fileIDsToUnparse.clear();
- }
- bool
- Sg_File_Info::isFrontendSpecific() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_frontend_specific);
- }
- void
- Sg_File_Info::setFrontendSpecific()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_frontend_specific;
- }
- void
- Sg_File_Info::unsetFrontendSpecific()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_frontend_specific;
- }
- bool
- Sg_File_Info::isSourcePositionUnavailableInFrontend() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_source_position_unavailable_in_frontend);
- }
- void
- Sg_File_Info::setSourcePositionUnavailableInFrontend()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_source_position_unavailable_in_frontend;
- }
- void
- Sg_File_Info::unsetSourcePositionUnavailableInFrontend()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_source_position_unavailable_in_frontend;
- }
- bool
- Sg_File_Info::isCommentOrDirective() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_comment_or_directive);
- }
- void
- Sg_File_Info::setCommentOrDirective()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_comment_or_directive;
- }
- void
- Sg_File_Info::unsetCommentOrDirective()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_comment_or_directive;
- }
- bool
- Sg_File_Info::isToken() const
- {
- ROSE_ASSERT(this != NULL);
- return (p_classificationBitField & e_token);
- }
- void
- Sg_File_Info::setToken()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField |= e_token;
- }
- void
- Sg_File_Info::unsetToken()
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField &= ~e_token;
- }
- // MK (8/2/05) : Implementation for function to handle unparsing of particular files
- void
- Sg_File_Info::addFileToUnparse(int file_id)
- {
- ROSE_ASSERT(this != NULL);
- p_fileIDsToUnparse.insert(file_id);
- }
- bool
- Sg_File_Info::shouldUnparse(int file_id)
- {
- ROSE_ASSERT(this != NULL);
- return p_fileIDsToUnparse.count(file_id) != 0;
- }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // bool
- // Sg_File_Info::isDeclaration() const
- // { return (p_classificationBitField & e_declaration); }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // void
- // Sg_File_Info::setDeclaration()
- // {
- // unsetInitialization();
- // p_classificationBitField |= e_declaration;
- // }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // void
- // Sg_File_Info::unsetDeclaration()
- // { p_classificationBitField &= ~e_declaration; }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // bool
- // Sg_File_Info::isInitialization() const
- // { return (p_classificationBitField & e_initialization); }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // void
- // Sg_File_Info::setInitialization()
- // {
- // unsetDeclaration();
- // p_classificationBitField |= e_initialization;
- // }
- // DQ (6/17/2005): Removed function (not used and not important to support)
- // void
- // Sg_File_Info::unsetInitialization()
- // { p_classificationBitField &= ~e_initialization; }
- unsigned int
- Sg_File_Info::get_classificationBitField(void) const
- {
- ROSE_ASSERT(this != NULL);
- return p_classificationBitField;
- }
- void
- Sg_File_Info::set_classificationBitField( unsigned int bitflags )
- {
- ROSE_ASSERT(this != NULL);
- p_classificationBitField = bitflags;
- }
- // MK (8/2/05): Added implementations for static functions to support interface to fileid maps
- const string&
- Sg_File_Info::getFilenameFromID(int id)
- {
- // This is a static function
- const std::string* name = NULL;
- switch(id)
- {
- // special cases
- case NULL_FILE_ID:
- {
- static const std::string null_file_string = "NULL_FILE";
- name = &null_file_string;
- break;
- }
- case COPY_FILE_ID:
- {
- static const std::string copy_file_string = "COPY";
- name = ©_file_string;
- break;
- }
- case TRANSFORMATION_FILE_ID:
- {
- static const std::string transformation_string = "transformation";
- name = &transformation_string;
- break;
- }
- case COMPILER_GENERATED_FILE_ID:
- {
- static const std::string compilerGenerated_string = "compilerGenerated";
- name = &compilerGenerated_string;
- break;
- }
- case COMPILER_GENERATED_MARKED_FOR_OUTPUT_FILE_ID:
- {
- // name = "compilerGenerated";
- printf ("The concept of COMPILER_GENERATED and OUTPUT are now decoupled, so make this an error \n");
- ROSE_ASSERT(false);
- break;
- }
- case BAD_FILE_ID:
- {
- static const std::string badfile_string = "badfile";
- name = &badfile_string;
- break;
- }
- // normal case
- default:
- {
- // assert that the id is present in the map (else error)
- // ROSE_ASSERT(p_fileidtoname_map.count(id) != 0);
- bool failure = (p_fileidtoname_map.count(id) == 0);
- if (failure == true)
- {
- printf ("Error: bad id number for file id (id = %d) \n",id);
- display_static_data("error in getFilenameFromID");
- // Note: this causes an empty entry to be generated in p_fileidtoname_map for the id == p_max_file_id (value of max map size)
- // std::cout << p_fileidtoname_map[id] << std::endl;
- // printf ("Error: bad id number for file id (id = %d) \n",id);
- }
- ROSE_ASSERT(failure == false);
- // get the filename from the map using the valid id
- name = &p_fileidtoname_map[id];
- }
- }
- return *name;
- }
- int
- Sg_File_Info::getIDFromFilename( std::string filename )
- {
- // This is a static function
- if (p_nametofileid_map.count(filename) == 0)
- {
- return BAD_FILE_ID;
- }
- return p_nametofileid_map[filename];
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- Sg_File_Info::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- Sg_File_Info::variantT() const {
- return V_Sg_File_Info;
- }
- #if 0
- int
- Sg_File_Info::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return _File_InfoTag;
- }
- #endif
- const char*
- Sg_File_Info::sage_class_name() const
- {
- assert(this != NULL);
- return "Sg_File_Info";
- }
- std::string
- Sg_File_Info::class_name() const
- {
- assert(this != NULL);
- return "Sg_File_Info";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- Sg_File_Info::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- Sg_File_Info::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != _File_InfoTag)
- {
- printf ("Error in Sg_File_Info::error(): Sg_File_Info object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in Sg_File_Info::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == _File_InfoTag);
- return SgSupport::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- Sg_File_Info::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In Sg_File_Info::variant() const \n");
- #endif
- assert(this != NULL);
- return _File_InfoTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- Sg_File_Info* isSg_File_Info ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<Sg_File_Info*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const Sg_File_Info* isSg_File_Info ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const Sg_File_Info*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- Sg_File_Info::~Sg_File_Info ()
- {
- #if 0
- // debugging information!
- printf ("In Sg_File_Info::~Sg_File_Info (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- // case: not a listType for file_id
- p_file_id = NULL_FILE_ID; // non list case
- // case: not a listType for line
- p_line = 0; // non list case
- // case: not a listType for col
- p_col = 0; // non list case
- // case: not a listType for classificationBitField
- p_classificationBitField = 0; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- Sg_File_Info*
- SgFile::get_startOfConstruct () const
- {
- assert (this != NULL);
- return p_startOfConstruct;
- }
- void
- SgFile::set_startOfConstruct ( Sg_File_Info* startOfConstruct )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_startOfConstruct != NULL && startOfConstruct != NULL && p_startOfConstruct != startOfConstruct)
- {
- printf ("Warning: startOfConstruct = %p overwriting valid pointer p_startOfConstruct = %p \n",startOfConstruct,p_startOfConstruct);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_startOfConstruct != NULL && startOfConstruct != NULL && p_startOfConstruct != startOfConstruct) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_startOfConstruct = startOfConstruct;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgGlobal*
- SgFile::get_root () const
- {
- assert (this != NULL);
- return p_root;
- }
- void
- SgFile::set_root ( SgGlobal* root )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_root != NULL && root != NULL && p_root != root)
- {
- printf ("Warning: root = %p overwriting valid pointer p_root = %p \n",root,p_root);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_root != NULL && root != NULL && p_root != root) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_root = root;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgFile::get_originalCommandLineArgumentList () const
- {
- assert (this != NULL);
- return p_originalCommandLineArgumentList;
- }
- void
- SgFile::set_originalCommandLineArgumentList ( SgStringList originalCommandLineArgumentList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_originalCommandLineArgumentList = originalCommandLineArgumentList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgFile::get_verbose () const
- {
- assert (this != NULL);
- return p_verbose;
- }
- void
- SgFile::set_verbose ( int verbose )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_verbose = verbose;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_C_only () const
- {
- assert (this != NULL);
- return p_C_only;
- }
- void
- SgFile::set_C_only ( bool C_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_C_only = C_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_C99_only () const
- {
- assert (this != NULL);
- return p_C99_only;
- }
- void
- SgFile::set_C99_only ( bool C99_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_C99_only = C99_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_Fortran_only () const
- {
- assert (this != NULL);
- return p_Fortran_only;
- }
- void
- SgFile::set_Fortran_only ( bool Fortran_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_Fortran_only = Fortran_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_F77_only () const
- {
- assert (this != NULL);
- return p_F77_only;
- }
- void
- SgFile::set_F77_only ( bool F77_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_F77_only = F77_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_F90_only () const
- {
- assert (this != NULL);
- return p_F90_only;
- }
- void
- SgFile::set_F90_only ( bool F90_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_F90_only = F90_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_F95_only () const
- {
- assert (this != NULL);
- return p_F95_only;
- }
- void
- SgFile::set_F95_only ( bool F95_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_F95_only = F95_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_F2003_only () const
- {
- assert (this != NULL);
- return p_F2003_only;
- }
- void
- SgFile::set_F2003_only ( bool F2003_only )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_F2003_only = F2003_only;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_fixedFormat () const
- {
- assert (this != NULL);
- return p_fixedFormat;
- }
- void
- SgFile::set_fixedFormat ( bool fixedFormat )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fixedFormat = fixedFormat;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_freeFormat () const
- {
- assert (this != NULL);
- return p_freeFormat;
- }
- void
- SgFile::set_freeFormat ( bool freeFormat )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_freeFormat = freeFormat;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgFile::outputFormatOption_enum
- SgFile::get_outputFormat () const
- {
- assert (this != NULL);
- return p_outputFormat;
- }
- void
- SgFile::set_outputFormat ( SgFile::outputFormatOption_enum outputFormat )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputFormat = outputFormat;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_fortran_implicit_none () const
- {
- assert (this != NULL);
- return p_fortran_implicit_none;
- }
- void
- SgFile::set_fortran_implicit_none ( bool fortran_implicit_none )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fortran_implicit_none = fortran_implicit_none;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_fortran_openmp () const
- {
- assert (this != NULL);
- return p_fortran_openmp;
- }
- void
- SgFile::set_fortran_openmp ( bool fortran_openmp )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fortran_openmp = fortran_openmp;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_skip_transformation () const
- {
- assert (this != NULL);
- return p_skip_transformation;
- }
- void
- SgFile::set_skip_transformation ( bool skip_transformation )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_skip_transformation = skip_transformation;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_skip_unparse () const
- {
- assert (this != NULL);
- return p_skip_unparse;
- }
- void
- SgFile::set_skip_unparse ( bool skip_unparse )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_skip_unparse = skip_unparse;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_unparse_includes () const
- {
- assert (this != NULL);
- return p_unparse_includes;
- }
- void
- SgFile::set_unparse_includes ( bool unparse_includes )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_unparse_includes = unparse_includes;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_skipfinalCompileStep () const
- {
- assert (this != NULL);
- return p_skipfinalCompileStep;
- }
- void
- SgFile::set_skipfinalCompileStep ( bool skipfinalCompileStep )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_skipfinalCompileStep = skipfinalCompileStep;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgFile::outputLanguageOption_enum
- SgFile::get_outputLanguage () const
- {
- assert (this != NULL);
- return p_outputLanguage;
- }
- void
- SgFile::set_outputLanguage ( SgFile::outputLanguageOption_enum outputLanguage )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputLanguage = outputLanguage;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgFile::get_sourceFileNameWithPath () const
- {
- assert (this != NULL);
- return p_sourceFileNameWithPath;
- }
- void
- SgFile::set_sourceFileNameWithPath ( std::string sourceFileNameWithPath )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileNameWithPath = sourceFileNameWithPath;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgFile::get_sourceFileNameWithoutPath () const
- {
- assert (this != NULL);
- return p_sourceFileNameWithoutPath;
- }
- void
- SgFile::set_sourceFileNameWithoutPath ( std::string sourceFileNameWithoutPath )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileNameWithoutPath = sourceFileNameWithoutPath;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgFile::get_unparse_output_filename () const
- {
- assert (this != NULL);
- return p_unparse_output_filename;
- }
- void
- SgFile::set_unparse_output_filename ( std::string unparse_output_filename )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_unparse_output_filename = unparse_output_filename;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_useBackendOnly () const
- {
- assert (this != NULL);
- return p_useBackendOnly;
- }
- void
- SgFile::set_useBackendOnly ( bool useBackendOnly )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_useBackendOnly = useBackendOnly;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_compileOnly () const
- {
- assert (this != NULL);
- return p_compileOnly;
- }
- void
- SgFile::set_compileOnly ( bool compileOnly )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_compileOnly = compileOnly;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgFile::get_savedFrontendCommandLine () const
- {
- assert (this != NULL);
- return p_savedFrontendCommandLine;
- }
- void
- SgFile::set_savedFrontendCommandLine ( std::string savedFrontendCommandLine )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_savedFrontendCommandLine = savedFrontendCommandLine;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_no_implicit_templates () const
- {
- assert (this != NULL);
- return p_no_implicit_templates;
- }
- void
- SgFile::set_no_implicit_templates ( bool no_implicit_templates )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_no_implicit_templates = no_implicit_templates;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_no_implicit_inline_templates () const
- {
- assert (this != NULL);
- return p_no_implicit_inline_templates;
- }
- void
- SgFile::set_no_implicit_inline_templates ( bool no_implicit_inline_templates )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_no_implicit_inline_templates = no_implicit_inline_templates;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_skip_commentsAndDirectives () const
- {
- assert (this != NULL);
- return p_skip_commentsAndDirectives;
- }
- void
- SgFile::set_skip_commentsAndDirectives ( bool skip_commentsAndDirectives )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_skip_commentsAndDirectives = skip_commentsAndDirectives;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_collectAllCommentsAndDirectives () const
- {
- assert (this != NULL);
- return p_collectAllCommentsAndDirectives;
- }
- void
- SgFile::set_collectAllCommentsAndDirectives ( bool collectAllCommentsAndDirectives )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_collectAllCommentsAndDirectives = collectAllCommentsAndDirectives;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- ROSEAttributesListContainerPtr
- SgFile::get_preprocessorDirectivesAndCommentsList () const
- {
- assert (this != NULL);
- return p_preprocessorDirectivesAndCommentsList;
- }
- void
- SgFile::set_preprocessorDirectivesAndCommentsList ( ROSEAttributesListContainerPtr preprocessorDirectivesAndCommentsList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_preprocessorDirectivesAndCommentsList = preprocessorDirectivesAndCommentsList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- AstAttributeMechanism*
- SgFile::get_attributeMechanism () const
- {
- assert (this != NULL);
- return p_attributeMechanism;
- }
- void
- SgFile::set_attributeMechanism ( AstAttributeMechanism* attributeMechanism )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism)
- {
- printf ("Warning: attributeMechanism = %p overwriting valid pointer p_attributeMechanism = %p \n",attributeMechanism,p_attributeMechanism);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_attributeMechanism = attributeMechanism;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 836 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- #if 0
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- AstAttributeMechanism &
- SgFile::attribute()
- {
- // DQ (1/2/2006): This function preserves as much of
- // the syntax of attribute being a public data member.
- if (p_attribute == NULL)
- {
- printf ("Error: p_attribute == NULL (node = %s) \n",class_name().c_str());
- ROSE_ASSERT(false);
- }
- return *p_attribute;
- }
- #endif
- void
- SgFile::addNewAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->add(s,a);
- }
- void
- SgFile::setAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->set(s,a);
- }
- AstAttribute*
- SgFile::getAttribute(std::string s) const
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- AstAttribute* returnValue = get_attributeMechanism()->operator[](s);
- ROSE_ASSERT(returnValue != NULL);
- return returnValue;
- }
- void
- SgFile::updateAttribute( std::string s, AstAttribute* a )
- {
- // formerly called: replace
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->replace(s,a);
- }
- void
- SgFile::removeAttribute(std::string s)
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->remove(s);
- // DQ (1/2/2006): If we have no more attributes then remove the attribute container
- int remainingCount = numberOfAttributes();
- // printf ("In AstTextAttributesHandling::visit(): remaining number of attributes = %d \n",remainingCount);
- if (remainingCount == 0)
- {
- delete get_attributeMechanism();
- set_attributeMechanism(NULL);
- }
- }
- bool
- SgFile::attributeExists(std::string s) const
- {
- bool returnValue = false;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->exists(s);
- return returnValue;
- }
- int
- SgFile::numberOfAttributes() const
- {
- int returnValue = 0;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->size();
- return returnValue;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_KCC_frontend () const
- {
- assert (this != NULL);
- return p_KCC_frontend;
- }
- void
- SgFile::set_KCC_frontend ( bool KCC_frontend )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_KCC_frontend = KCC_frontend;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_new_frontend () const
- {
- assert (this != NULL);
- return p_new_frontend;
- }
- void
- SgFile::set_new_frontend ( bool new_frontend )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_new_frontend = new_frontend;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_travTraceToDOT () const
- {
- assert (this != NULL);
- return p_travTraceToDOT;
- }
- void
- SgFile::set_travTraceToDOT ( bool travTraceToDOT )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_travTraceToDOT = travTraceToDOT;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_disable_edg_backend () const
- {
- assert (this != NULL);
- return p_disable_edg_backend;
- }
- void
- SgFile::set_disable_edg_backend ( bool disable_edg_backend )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_disable_edg_backend = disable_edg_backend;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_disable_sage_backend () const
- {
- assert (this != NULL);
- return p_disable_sage_backend;
- }
- void
- SgFile::set_disable_sage_backend ( bool disable_sage_backend )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_disable_sage_backend = disable_sage_backend;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgFile::get_testingLevel () const
- {
- assert (this != NULL);
- return p_testingLevel;
- }
- void
- SgFile::set_testingLevel ( int testingLevel )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_testingLevel = testingLevel;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_preinit_il () const
- {
- assert (this != NULL);
- return p_preinit_il;
- }
- void
- SgFile::set_preinit_il ( bool preinit_il )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_preinit_il = preinit_il;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_enable_cp_backend () const
- {
- assert (this != NULL);
- return p_enable_cp_backend;
- }
- void
- SgFile::set_enable_cp_backend ( bool enable_cp_backend )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_enable_cp_backend = enable_cp_backend;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_outputGrammarTreeFiles () const
- {
- assert (this != NULL);
- return p_outputGrammarTreeFiles;
- }
- void
- SgFile::set_outputGrammarTreeFiles ( bool outputGrammarTreeFiles )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputGrammarTreeFiles = outputGrammarTreeFiles;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_outputGrammarTreeFilesForHeaderFiles () const
- {
- assert (this != NULL);
- return p_outputGrammarTreeFilesForHeaderFiles;
- }
- void
- SgFile::set_outputGrammarTreeFilesForHeaderFiles ( bool outputGrammarTreeFilesForHeaderFiles )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputGrammarTreeFilesForHeaderFiles = outputGrammarTreeFilesForHeaderFiles;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_outputGrammarTreeFilesForEDG () const
- {
- assert (this != NULL);
- return p_outputGrammarTreeFilesForEDG;
- }
- void
- SgFile::set_outputGrammarTreeFilesForEDG ( bool outputGrammarTreeFilesForEDG )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputGrammarTreeFilesForEDG = outputGrammarTreeFilesForEDG;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_markGeneratedFiles () const
- {
- assert (this != NULL);
- return p_markGeneratedFiles;
- }
- void
- SgFile::set_markGeneratedFiles ( bool markGeneratedFiles )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_markGeneratedFiles = markGeneratedFiles;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_negative_test () const
- {
- assert (this != NULL);
- return p_negative_test;
- }
- void
- SgFile::set_negative_test ( bool negative_test )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_negative_test = negative_test;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_strict_language_handling () const
- {
- assert (this != NULL);
- return p_strict_language_handling;
- }
- void
- SgFile::set_strict_language_handling ( bool strict_language_handling )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_strict_language_handling = strict_language_handling;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgFile::get_embedColorCodesInGeneratedCode () const
- {
- assert (this != NULL);
- return p_embedColorCodesInGeneratedCode;
- }
- void
- SgFile::set_embedColorCodesInGeneratedCode ( int embedColorCodesInGeneratedCode )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_embedColorCodesInGeneratedCode = embedColorCodesInGeneratedCode;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgFile::get_generateSourcePositionCodes () const
- {
- assert (this != NULL);
- return p_generateSourcePositionCodes;
- }
- void
- SgFile::set_generateSourcePositionCodes ( int generateSourcePositionCodes )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_generateSourcePositionCodes = generateSourcePositionCodes;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesCppFileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesCppFileExtension;
- }
- void
- SgFile::set_sourceFileUsesCppFileExtension ( bool sourceFileUsesCppFileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesCppFileExtension = sourceFileUsesCppFileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesFortranFileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesFortranFileExtension;
- }
- void
- SgFile::set_sourceFileUsesFortranFileExtension ( bool sourceFileUsesFortranFileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesFortranFileExtension = sourceFileUsesFortranFileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesFortran77FileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesFortran77FileExtension;
- }
- void
- SgFile::set_sourceFileUsesFortran77FileExtension ( bool sourceFileUsesFortran77FileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesFortran77FileExtension = sourceFileUsesFortran77FileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesFortran90FileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesFortran90FileExtension;
- }
- void
- SgFile::set_sourceFileUsesFortran90FileExtension ( bool sourceFileUsesFortran90FileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesFortran90FileExtension = sourceFileUsesFortran90FileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesFortran95FileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesFortran95FileExtension;
- }
- void
- SgFile::set_sourceFileUsesFortran95FileExtension ( bool sourceFileUsesFortran95FileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesFortran95FileExtension = sourceFileUsesFortran95FileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgFile::get_sourceFileUsesFortran2003FileExtension () const
- {
- assert (this != NULL);
- return p_sourceFileUsesFortran2003FileExtension;
- }
- void
- SgFile::set_sourceFileUsesFortran2003FileExtension ( bool sourceFileUsesFortran2003FileExtension )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileUsesFortran2003FileExtension = sourceFileUsesFortran2003FileExtension;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgFile*
- SgFile::get_binaryFile () const
- {
- assert (this != NULL);
- return p_binaryFile;
- }
- void
- SgFile::set_binaryFile ( SgFile* binaryFile )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_binaryFile != NULL && binaryFile != NULL && p_binaryFile != binaryFile)
- {
- printf ("Warning: binaryFile = %p overwriting valid pointer p_binaryFile = %p \n",binaryFile,p_binaryFile);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_binaryFile != NULL && binaryFile != NULL && p_binaryFile != binaryFile) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_binaryFile = binaryFile;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 8972 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- // void unparsestdout();
- // void unparse(std::ostream&);
- //! Declaration of space for static variables
- //static int SgFile::p_defaultNumberOfCommandLineArguments = 0;
- //static char** SgFile::p_defaultCommandLineArgumentList = NULL;
- //! Function prototype of EDG function to set call back function
- void set_sage_transform_function(void (*f)(SgFile *));
- void set_sage_edg_AST_display_function(void (*f)(SgFile *));
- int edg_main(int, char *[], SgFile & sageFile );
- #if 0
- int openFortranParser_main(int, char *[], SgFile & sageFile );
- // DQ (8/12/2007): Declare this locally for now and later put it into the Fortran support directly
- int
- openFortranParser_main(int numberOfArgs, char* commandline[], SgFile & sourceFile )
- {
- printf ("Inside of openFortranParser_main(): numberOfArgs = %d \n",numberOfArgs);
- SgGlobal* globalScope = sourceFile.get_globalScope();
- ROSE_ASSERT(globalScope != NULL);
- // printf ("Global scope = %p number of declarations = %zu \n",globalScope,globalScope->get_declarations().size());
- // sourceFile.display("In openFortranParser");
- printf ("\nCall to Java-based LANL's OpenFortranParser project not implemented \n\n");
- return 0;
- }
- #else
- // This is the "C" function implemented in:
- // ROSE/src/frontend/OpenFortranParser_SAGE_Connection/openFortranParser_main.c
- // This function calls the Java JVM to load the Java implemented parser (written
- // using ANTLR, a parser generator).
- extern "C" int openFortranParser_main(int argc, char **argv );
- // This is how we pass the pointer to the SgFile created in ROSE before the Open
- // Fortran Parser is called to the Open Fortran Parser. In the case of C/C++ using
- // EDG the SgFile is passed through the edg_main() function, but not so with the
- // Open Fortran Parser's openFortranParser_main() function API. So we use this
- // global variable to pass the SgFile (so that the parser c_action functions can
- // build the Fotran AST using the existing SgFile.
- extern SgFile* OpenFortranParser_globalFilePointer;
- #endif
- #if 0
- // DQ (1/18/2006): This is not generated due to the name change of "fileInfo" to "file_info"
- Sg_File_Info*
- SgFile::get_file_info(void) const
- {
- // DQ (1/18/2006): Added function to be match virtual function on SgNode
- // (so that the SgFile's Sg_File_Info object could be accessed).
- return p_fileInfo;
- }
- #endif
- Sg_File_Info*
- SgFile::get_file_info() const
- {
- // This redefines get_file_info() as it is implemented for a SgLocatedNode
- // to use the "get_startOfConstruct()" for consistancy with SgLocatedNode IR nodes.
- return get_startOfConstruct();
- }
- void
- SgFile::set_file_info( Sg_File_Info* fileinfo )
- {
- // This redefines set_file_info() as it is implemented for a SgLocatedNode
- // to use the "set_startOfConstruct()" for consistancy with SgLocatedNode IR nodes.
- set_startOfConstruct(fileinfo);
- }
- std::string
- SgFile::getFileName ()
- {
- // Get the filename from the Sage III file object
- // ROSE_ASSERT(get_fileInfo() != NULL);
- SgScopeStatement *globalScope = (SgScopeStatement *)(&(root()));
- ROSE_ASSERT (globalScope != NULL);
- Sg_File_Info* fileInfo = globalScope->get_file_info();
- ROSE_ASSERT (fileInfo != NULL);
- std::string fileName = fileInfo->get_filenameString();
- return fileName;
- }
- // function prototype
- ROSEAttributesListPtr getPreprocessorDirectives( char *fileName);
- // DQ (2/3/2004): Debugging segfault in use of il_header within ROSE
- // #include "sageCommonSourceHeader.h"
- // extern an_il_header il_header;
- void
- SgFile::setupSourceFilename ( const vector<string>& argv )
- {
- // DQ (4/21/2006): New version of source file name handling (set the source file name early)
- Rose_STL_Container<string> fileList = CommandlineProcessing::generateSourceFilenames(argv);
- if (!fileList.empty())
- {
- ROSE_ASSERT(fileList.size() == 1);
- // DQ (8/31/2006): Convert the source file to have a path if it does not already
- // p_sourceFileNameWithPath = *(fileList.begin());
- string sourceFilename = *(fileList.begin());
- // sourceFilename = StringUtility::getAbsolutePathFromRelativePath(sourceFilename);
- sourceFilename = StringUtility::getAbsolutePathFromRelativePath(sourceFilename, true);
- p_sourceFileNameWithPath = sourceFilename;
- // printf ("In SgFile::setupSourceFilename(int,char**): p_sourceFileNameWithPath = %s \n",p_sourceFileNameWithPath.c_str());
- // This should be an absolute path
- string targetSubstring = "/";
- // if (sourceFilename.substr(0,targetSubstring.size()) != targetSubstring)
- // printf ("@@@@@@@@@@@@@@@@@@@@ In SgFile::setupSourceFilename(int,char**): sourceFilename = %s @@@@@@@@@@@@@@@@@@@@\n",sourceFilename.c_str());
- // ROSE_ASSERT(sourceFilename.substr(0,targetSubstring.size()) == targetSubstring);
- // Rama: 12/06/06: Fixup for problem with file names.
- // Made changes to this file and string utilities function getAbsolutePathFromRelativePath by cloning it with name getAbsolutePathFromRelativePathWithErrors
- // Also refer to script that tests -- reasonably exhaustively -- to various combinarions of input files.
- if (sourceFilename.substr(0,targetSubstring.size()) != targetSubstring)
- printf ("sourceFilename encountered an error in filename\n");
- // DQ (11/29/2006): Even if this is C mode, we have to define the __cplusplus macro
- // is we detect we are processing a source file using the a C++ filename extension.
- string filenameExtension = StringUtility::fileNameSuffix(sourceFilename);
- // if (StringUtility::isCppFileNameSuffix(filenameExtension) == true)
- if (CommandlineProcessing::isCppFileNameSuffix(filenameExtension) == true)
- {
- // This is a C++ file (so define __cplusplus, just like GNU gcc would)
- // set_requires_cplusplus_macro(true);
- set_sourceFileUsesCppFileExtension(true);
- }
- else
- {
- // This a not a C++ file (assume it is a C file and don't define the __cplusplus macro, just like GNU gcc would)
- set_sourceFileUsesCppFileExtension(false);
- }
- p_sourceFileNameWithoutPath = ROSE::stripPathFromFileName(p_sourceFileNameWithPath.c_str());
- }
- else
- {
- // ROSE_ASSERT (p_numberOfSourceFileNames == 0);
- ROSE_ASSERT (p_sourceFileNameWithPath.empty() == true);
- // If no source code file name was found then likely this is a link command
- // using the C++ compiler. In this case skip the EDG processing.
- set_disable_edg_backend(true);
- // printf ("No source file found on command line, assuming to be linker command line \n");
- }
- // Keep the filename stored in the Sg_File_Info consistant. Later we will want to remove this redundency
- // The reason we have the Sg_File_Info object is so that we can easily support filename matching based on
- // the integer values instead of string comparisions.
- get_file_info()->set_filenameString(p_sourceFileNameWithPath);
- }
- void SgFile::doSetupForConstructor(const vector<string>& argv, int& errorCode, int fileNameIndex, SgProject* project) {
- // DQ (4/21/2006): I think we can now assert this! This is an unused function parameter!
- ROSE_ASSERT(fileNameIndex == 0);
- // DQ (5/9/2007): Moved this call down to after where the file name is available so that we could include the filename in the label.
- // DQ (7/6/2005): Introduce tracking of performance of ROSE.
- // TimingPerformance timer ("AST SgFile Constructor:");
- // Set the project early in the construction phase so that we can access data in
- // the parent if needed (useful for template handling but also makes sure the parent is
- // set (and avoids fixup (currently done, but too late in the construction process for
- // the template support).
- if (project != NULL)
- set_parent(project);
- // DQ (5/9/2007): The initialization() should do this, so this should not be required.
- p_root = NULL;
- p_binaryFile = NULL;
- // initalize all local variables to default values
- initialization();
- // DQ (4/21/2006): Setup the source filename as early as possible
- setupSourceFilename(argv);
- // DQ (5/9/2007): Moved this call from above to where the file name is available so that we could include
- // the filename in the label. This helps to identify the performance data with individual files where
- // multiple source files are specificed on the command line.
- // printf ("p_sourceFileNameWithPath = %s \n",p_sourceFileNameWithPath);
- string timerLabel = "AST SgFile Constructor for " + p_sourceFileNameWithPath + ":";
- TimingPerformance timer (timerLabel);
- // Build a DEEP COPY of the input parameters!
- vector<string> local_commandLineArgumentList = argv;
- // Save the commandline as a list of strings (we made a deep copy becasue the "callFrontEnd()" function might change it!
- set_originalCommandLineArgumentList( local_commandLineArgumentList );
- // DQ (5/22/2005): Store the file name index in the SgFile object so that it can figure out
- // which file name applies to it. This helps support functions such as "get_filename()"
- // used elsewhere in Sage III. Not clear if we really need this!
- // p_fileNameIndex = fileNameIndex;
- #if 0
- printf ("In SgFile::SgFile() after initialization: get_skipfinalCompileStep() = %s \n",
- get_skipfinalCompileStep() ? "true" : "false");
- #endif
- // printf ("In SgFile constructor: fileNameIndex = %d \n",fileNameIndex);
- // Store the command line for later use with compiling the unparsed code
- // set_NumberOfCommandLineArguments ( argc );
- // set_CommandLineArgumentList ( argv );
- ROSE_ASSERT (p_root != NULL);
- // error checking
- ROSE_ASSERT (argv.size() > 1);
- // printf ("DONE with copy of command line in SgFile constructor! \n");
- #if 0
- printf ("In SgFile::SgFile() before callFrontEnd(): get_skipfinalCompileStep() = %s \n",
- get_skipfinalCompileStep() ? "true" : "false");
- #endif
- #if 1
- // DQ (10/16/2005): Modified to make clear that argc and argv are not modified
- // Call the EDG fron-end to generate the abstract syntax tree
- // int EDG_FrontEndErrorCode = callFrontEnd ( argc, argv, *this, fileNameIndex );
- // int EDG_FrontEndErrorCode = callFrontEnd ( local_commandLineArgumentList, *this, fileNameIndex );
- // int EDG_FrontEndErrorCode = callFrontEnd ( local_commandLineArgumentList );
- int EDG_FrontEndErrorCode = callFrontEnd();
- // Warning from EDG processing are OK but not errors
- ROSE_ASSERT (EDG_FrontEndErrorCode <= 3);
- errorCode = EDG_FrontEndErrorCode;
- // cout << "EDG/SAGE/ROSE Processing DONE! " << endl;
- #endif
- #if 0
- printf ("In SgFile::SgFile() after callFrontEnd(): get_skipfinalCompileStep() = %s \n",
- get_skipfinalCompileStep() ? "true" : "false");
- #endif
- // DQ (5/24/2005): Fixup the file info information at the SgFile and the global scope (SgGlobal)
- // Opps, SgFile object does not have a Sg_File_Info pointer data member.
- // Sg_File_Info* localfileInfo = new Sg_File_Info(p_sourceFileNamesWithPath[fileNameIndex],0,0);
- // ROSE_ASSERT (localfileInfo != NULL);
- // set_file_info(localfileInfo);
- // DQ (10/15/2005): This has not been converted to a C++ string!
- // DQ (5/24/2005): Now fixup the file info's file name in the global scope!
- // printf ("In SgFile::SgFile p_sourceFileNamesWithPath[%d] = %s \n",fileNameIndex,p_sourceFileNamesWithPath[fileNameIndex]);
- // p_root->get_file_info()->set_filename(p_sourceFileNamesWithPath[fileNameIndex]);
- p_root->get_file_info()->set_filenameString(p_sourceFileNameWithPath);
- // DQ (1/18/2006): Set the filename in the SgFile::p_file_info
- ROSE_ASSERT(get_file_info() != NULL);
- get_file_info()->set_filenameString(p_sourceFileNameWithPath);
- #if 0
- printf ("In SgFile::SgFile(): get_skipfinalCompileStep() = %s \n",
- get_skipfinalCompileStep() ? "true" : "false");
- #endif
- // DQ (5/3/2007): Added assertion.
- ROSE_ASSERT (get_startOfConstruct() != NULL);
- }
- SgFile::SgFile ( int & argc, char** & argv , int & errorCode, int fileNameIndex, SgProject* project )
- // : p_numberOfCommandLineArguments(argc) , p_commandLineArgumentList(NULL)
- {
- // This constructor actually makes the call to EDG to build the AST (via callFrontEnd()).
- ROSE_ASSERT (argv && argc >= 0);
- doSetupForConstructor(vector<string>(argv, argv + argc), errorCode, fileNameIndex, project);
- }
- SgFile::SgFile ( vector<string> & argv , int & errorCode, int fileNameIndex, SgProject* project )
- // : p_numberOfCommandLineArguments(argc) , p_commandLineArgumentList(NULL)
- {
- // This constructor actually makes the call to EDG to build the AST (via callFrontEnd()).
- doSetupForConstructor(argv, errorCode, fileNameIndex, project);
- }
- SgFile::SgFile ()
- {
- // Default constructor
- // This builds a valid SgFile which has no global scope
- // we might make it have a global scope just to support
- // the p_root pointer always being a valid pointer (and
- // the list of declarations being empty).
- // DQ (1/18/2006): uncommented to test loop processing
- // DQ (9/26/2005): We can try to get this constructor working now
- // printf ("This is the default constructor, use SgFile (argc,argv) instead \n");
- // ROSE_ABORT();
- p_root = NULL;
- p_binaryFile = NULL;
- // DQ (10/16/2005): Removed as part of cleanup to SgFile
- // p_numberOfCommandLineArguments = 0;
- // p_commandLineArgumentList = NULL;
- initialization ();
- // DQ (5/15/2006): Note that initialization() builds a SgGlobal but for this
- // default constructor (used in the copy function) we don't want to build one of these.
- // So delete the SgGlobal just built.
- ROSE_ASSERT(p_root != NULL);
- delete p_root;
- p_root = NULL;
- // DQ (10/16/2005): Removed as part of cleanup to SgFile
- // DQ (7/13/2004): Reset the values based on constructor arguments
- // p_numberOfCommandLineArguments = p_defaultNumberOfCommandLineArguments;
- // p_commandLineArgumentList = p_defaultCommandLineArgumentList;
- }
- // DQ (1/17/2006): Added this (copy constructor) to be explicit
- // and avoid difficult bugs where it is compiler generated.
- SgFile::SgFile ( const SgFile & X )
- {
- printf ("Error: calling private copy constructor! \n");
- ROSE_ASSERT(false);
- }
- void
- SgFile::initialization ()
- {
- /* START: List of variables that need to be initialized!
- X SgGlobal* p_root;
- X int p_numberOfCommandLineArguments;
- X char** p_commandLineArgumentList;
- X int p_defaultNumberOfCommandLineArguments;
- X char** p_defaultCommandLineArgumentList;
- X bool p_verbose;
- X bool p_C_only;
- X bool p_outputGrammarTreeFiles;
- X bool p_outputGrammarTreeFilesForEDG;
- X bool p_skip_transformation;
- X bool p_skip_unparse;
- X bool p_outputGrammarTreeFilesForHeaderFiles;
- X bool p_unparse_includes;
- X bool p_KCC_frontend;
- X bool p_new_frontend;
- X bool p_skipfinalCompileStep;
- X bool p_disable_edg_backend;
- X bool p_disable_sage_backend;
- X int p_testingLevel;
- X bool p_preinit_il;
- X bool p_enable_cp_backend;
- X int p_numberOfSourceFileNames;
- X char** p_sourceFileNamesWithPath;
- X char** p_sourceFileNamesWithoutPath;
- X bool p_skip_buildHigherLevelGrammars;
- X char* p_unparse_output_filename;
- X bool p_travTraceToDOT;
- X bool p_useBackendOnly;
- X bool p_compileOnly;
- string p_savedFrontendCommandLine;
- X ROSEAttributesListContainerPtr p_preprocessorDirectivesAndCommentsList;
- END: List of variables that need to be initialized!
- */
- ROSE_ASSERT(this != NULL);
- // This should use a Sg_File_Info with the correct name (maybe this
- // should be initialized by "callFrontEnd()")
- // Sg_File_Info* fileInfo = new Sg_File_Info("SgFile file unknown",0,0);
- // DQ (1/17/2006): Initialize the local file info pointer (this was not previously set!)
- // the name will be reset to the file name later in the construction of the SgFile.
- // set_file_info(new Sg_File_Info (*fileInfo));
- // DQ (12/23/3006): Let the fileInfo be initialized with line 1, column 1 (instead of
- // line 0, column 0). This avoids it failing the test for a valid Sg_File_Info object
- // later (e.g. in fixupSourcePositionInformation.C).
- // DQ (8/31/2006): Generate a NULL_FILE (instead of SgFile::SgFile) so that we can
- // enforce that the filename is always an absolute path (starting with "/").
- // Sg_File_Info* fileInfo = new Sg_File_Info("SgFile::SgFile",0,0);
- // Sg_File_Info* fileInfo = new Sg_File_Info("",0,0);
- Sg_File_Info* fileInfo = new Sg_File_Info("",1,1);
- ROSE_ASSERT(fileInfo != NULL);
- // set_file_info(fileInfo);
- set_startOfConstruct(fileInfo);
- fileInfo->set_parent(this);
- ROSE_ASSERT(get_startOfConstruct() != NULL);
- ROSE_ASSERT(get_file_info() != NULL);
- ROSE_ASSERT (p_root == NULL);
- ROSE_ASSERT (p_binaryFile == NULL);
- // DQ (8/31/2006): Generate a NULL_FILE (instead of SgFile::SgFile) so that we can
- // enforce that the filename is always an absolute path (starting with "/").
- // Sg_File_Info* globalScopeFileInfo = new Sg_File_Info("SgGlobal::SgGlobal",0,0);
- Sg_File_Info* globalScopeFileInfo = new Sg_File_Info("",0,0);
- ROSE_ASSERT (globalScopeFileInfo != NULL);
- p_root = new SgGlobal( globalScopeFileInfo );
- ROSE_ASSERT (p_root != NULL);
- #if 0
- // DQ (1/17/2006): Trying to debug NULL SgFile::get_fileInfo() result
- printf ("Printing out Sg_File_Info object %p in SgFile(%p)::initialization() \n",fileInfo,this);
- fileInfo->display("In SgFile::initialization()");
- get_fileInfo()->display("In SgFile::initialization() calling get_fileInfo()");
- #endif
- // DQ (2/15/2006): Set the parent of the SgGlobal IR node
- p_root->set_parent(this);
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- // DQ (1/13/2006): Initialize new AstAttributeMechanism pointer (moved from SgNode)
- p_attributeMechanism = NULL;
- // DQ (10/16/2005): Removed as part of cleanup to SgFile
- // DQ (12/6/2003): initialize these here.
- // p_defaultNumberOfCommandLineArguments = 0;
- // p_defaultCommandLineArgumentList = NULL;
- // DQ (7/13/2004): Not previously initialized (except through constructor preinitialization list)
- // I have removed them from the constructor preinitialization list so that ALL local member data
- // could be set in this inialization function!
- // p_numberOfCommandLineArguments = 0;
- // p_commandLineArgumentList = NULL;
- // DQ (4/7/2001) Added support for multiple files (save the preprocessor
- // directives and comments into the SgFile)
- // the ROSEAttributesListContainer represents all preprocessor
- // declarations and comments from each source file (and its
- // corresponding include files) (thus a list of lists of lists
- // of cpp directives and comments!!!)
- // At construction this is a NULL pointer, it is updated later after construction of the AST.
- p_preprocessorDirectivesAndCommentsList = NULL; // new ROSEAttributesListContainer();
- // ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList != NULL);
- ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList == NULL);
- // DQ (10/15/2005): Don't have a default for this (use an empty string)!
- // p_unparse_output_filename = "rose_unparse.C";
- p_verbose = 0;
- // version = false;
- // help = false;
- // DQ (7/13/2004): Not previously initialized!
- p_C_only = false;
- p_C99_only = false;
- // DQ (8/11/2007): Added support for Fortran
- p_Fortran_only = false;
- p_F77_only = false;
- p_F90_only = false;
- p_F95_only = false;
- p_F2003_only = false;
- p_fixedFormat = false;
- p_outputFormat = SgFile::e_unknown_output_format;
- p_fortran_implicit_none = false;
- p_fortran_openmp = false;
- p_compileOnly = false;
- // After higher level ASTs are build optionally apply transformations
- p_skip_transformation = false;
- p_skip_unparse = false;
- p_outputGrammarTreeFiles = false; // default should be false (set to true while debugging)
- p_outputGrammarTreeFilesForHeaderFiles = false; // default is to skip headers
- // DQ (8/27/2007): Support for alternative langauge code generation (unparsing), useful for testing specific language unparsers.
- p_outputLanguage = SgFile::e_default_output_language;
- // p_new_unparser = true; // by default use the new unparser
- p_unparse_includes = false; // by default do NOT unparse include files into the source code
- p_KCC_frontend = false;
- // Alternatively we can call the new edg frontend to test the edg process
- p_new_frontend = false;
- #if 1
- // The default should be to act like a C++ compiler
- p_skipfinalCompileStep = false;
- #else
- p_skipfinalCompileStep = true;
- #endif
- // controls call to the edg_main (disables all processing
- // and acts like a shell which calls the compiler)
- p_disable_edg_backend = false;
- // Disable parsing of the EDG program tree into the SAGE program tree
- p_disable_sage_backend = false;
- // Shorthand form for different levels of testing (default is -1)
- p_testingLevel = -1;
- // enable processing specific to templates
- p_preinit_il = false;
- p_enable_cp_backend = false;
- // Used to store filenames of input source files
- // p_numberOfSourceFileNames = 0;
- // DQ (10/15/2005): This is now a C++ string (so we can't set these to NULL)
- // p_sourceFileNamesWithPath = NULL;
- // p_sourceFileNamesWithoutPath = NULL;
- // currentDirectory = NULL;
- // Used to trigger building of higher level ASTs
- // p_skip_buildHigherLevelGrammars = false;
- // Support for faster processing of pdf output (where we likely don't need the pdf output of the the EDG AST)
- p_outputGrammarTreeFilesForEDG = false;
- // initialize p_useBackendOnly data member
- p_useBackendOnly = false;
- // DQ (12/6/2003): initialize this here
- p_travTraceToDOT = false;
- // DQ (6/21/2005): initialize g++ specific template instantiation control flags
- p_no_implicit_templates = false;
- p_no_implicit_inline_templates = false;
- // DQ (4/19/2006): Added to control comment and directive handling (takes more time to process header files).
- p_collectAllCommentsAndDirectives = false;
- // Added to permit all comments and CPP directives to be skipped (e.g. when unparsing all hearders)
- p_skip_commentsAndDirectives = false;
- // DQ (9/5/2006): Added mechanism to optionally watermark files generated by ROSE
- p_markGeneratedFiles = false;
- // DQ (9/19/2006): Allow testing of ROSE using input that is expected to fail (return passed if test failed)
- p_negative_test = false;
- // DQ (9/24/2006): Permit optional enforcement of ANSI standards
- p_strict_language_handling = false;
- // DQ (10/31/2006): Output information that can be used to colorize properties of generated code (useful for debugging).
- p_embedColorCodesInGeneratedCode = 0;
- // DQ (10/31/2006): Output separate file containing source position information for highlighting (useful for debugging).
- p_generateSourcePositionCodes = 0;
- // DQ (12/2/2006): This we be used (as in GNU) to set the languge mode (C++ files will turn on C++ language mode
- // and only ".c" (C files) will turn on C language mode).
- p_sourceFileUsesCppFileExtension = false;
- // DQ (10/19/2007): Added initialization new data member added to support handing of binary AST and source code AST.
- p_binaryFile = NULL;
- }
- #if 0
- SgFile::~SgFile()
- {
- // This is the highest level of control for the cleanup of memory
- // allocated as part of the creation of the program tree
- #if 1
- delete p_root;
- p_root = NULL;
- #endif
- // Not ready to delete this yet
- // delete p_preprocessorDirectivesAndCommentsList;
- }
- #endif
- SgGlobal &
- SgFile::root() ROSE_DEPRECATED_FUNCTION
- {
- assert(p_root != NULL);
- return *p_root;
- }
- // DQ (7/19/2005): Added to support better naming of global scope (root is not very clear)
- // get_root() set_root() and root() will be depricated.
- SgGlobal*
- SgFile::get_globalScope() const
- {
- // This variable name will be changed in the future (to globalScope)
- ROSE_ASSERT(p_root != NULL);
- return p_root;
- }
- #if 1
- // function prototype (not required?)
- // int compileOutput ( int & argc, char** & argv );
- int
- SgFile::compileOutput ( int fileNameIndex, const std::string& compilerName )
- {
- // Compile the output file from the unparing
- vector<string> argv = get_originalCommandLineArgumentList();
- ROSE_ASSERT(!argv.empty());
-
- // DQ (4/21/2006): I think we can now assert this! This is an unused function parameter!
- ROSE_ASSERT(fileNameIndex == 0);
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // error checking
- ROSE_ASSERT (argv.size() > 1);
- // BP : 10/31/2001, strip out any rose options before passing the command line.
- stripRoseCommandLineOptions( argv );
- // DQ (2/12/2004): strip out edg specific options that
- // would cause an error in the backend compiler.
- stripEdgCommandLineOptions( argv );
- // Call the compile
- int errorCode = compileOutput ( argv, fileNameIndex, compilerName );
- // return the error code from the compilation
- return errorCode;
- }
- #endif
- // function prototype
- // void pdfPrintAbstractSyntaxTreeSage ( SgFile & sageFile, bool writeOutHeaderFiles );
- #if 0
- void
- SgFile::outputPDF ()
- {
- // Output the program tree
- printf ("In SgFile::outputPDF(): Dumping the program tree (AST) to a file \n");
- // Use Markus's new pdf generator
- AstPDFGeneration pdftest;
- pdftest.generateWithinFile(this);
- }
- #endif
- #if 0
- int
- SgFile::get_NumberOfCommandLineArguments()
- {
- ROSE_ASSERT (p_numberOfCommandLineArguments > 0);
- return p_numberOfCommandLineArguments;
- }
- char**
- SgFile::get_CommandLineArgumentList()
- {
- ROSE_ASSERT (p_commandLineArgumentList != NULL);
- return p_commandLineArgumentList;
- }
- #endif
- #if 0
- // These variables are both references and so must be initialized by the constructors
- void
- SgFile::set_NumberOfCommandLineArguments ( int & n )
- {
- ROSE_ASSERT (n > 0);
- p_numberOfCommandLineArguments = n;
- }
- void
- SgFile::set_CommandLineArgumentList ( char** & argv )
- {
- ROSE_ASSERT (argv != NULL);
- p_commandLineArgumentList = argv;
- }
- #endif
- #if 0
- // These can be automatically generated (I think)
- ROSEAttributesListContainer &
- SgFile::get_preprocessorDirectivesAndCommentsList ()
- {
- // assert(i==0);
- // return *p_file;
- ROSE_ASSERT (p_fileList != NULL);
- ROSEAttributesListContainer* targetList = (*p_preprocessorDirectivesAndCommentsList);
- ROSE_ASSERT (targetList != NULL);
- return *targetList;
- }
- void
- SgFile::set_preprocessorDirectivesAndCommentsList ( ROSEAttributesListContainer & directivesList )
- {
- ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList != NULL);
- p_preprocessorDirectivesAndCommentsList->push_back(&directivesList);
- }
- #endif
- #if 0
- void
- roseDisplayMechanism( SgFile *file )
- {
- // This is the function called by EDG if set using the set_sage_transform_function()
- // function. We use it to permit the EDG AST to be dumped out to a file. This
- // step must be done before EDG's AST is deleted and so can't be done when other
- // Sage/ROSE transformations are done (which is now after the EDG AST is released
- // under the new (simplified) interface).
- // This function is called at the point where the EDG program tree has already
- // been parsed into the C++ (modified Sage) grammar but the EDG AST still exists.
- #if ROSE_INTERNAL_DEBUG
- if ( file->get_verbose() > 1 )
- {
- // Find out what file we are doing transformations upon
- printf ("In roseDisplayMechanism: globalSourceFileName = %s \n",file->getFileName());
- }
- #endif
- if (file->get_outputGrammarTreeFiles() == true)
- {
- // Output the program tree
- printf ("## Dumping the program tree (AST) to a file ## \n");
- // Permit the AST for the header files to be output
- // as well (this makes the output files very large)
- bool writeOutHeaderFiles = file->get_outputGrammarTreeFilesForHeaderFiles();
- // Added to speed up processing of large files when we just want the SAGE 3 AST
- bool writeOutEDG_AST = file->get_outputGrammarTreeFilesForEDG();
- // Output the source code file (as represented by the EDG AST) as a PDF file (with bookmarks)
- // Allow this to be off by default since the files generated are so large and most often we just want the SAGE 3 AST
- if (writeOutEDG_AST == true)
- pdfPrintAbstractSyntaxTreeEDG ( file, writeOutHeaderFiles );
- else
- printf ("Skipping output of EDG AST in PDF format (EDG output must be turned on explicitly using commandline option) \n");
- // Output the source code file (as represented by the SAGE AST) as a PDF file (with bookmarks)
- // pdfPrintAbstractSyntaxTreeSage ( file, writeOutHeaderFiles );
- // printf ("Exiting after testing pdf file output of source code! \n");
- // ROSE_ABORT();
- }
- else
- {
- // printf ("## Skip dumping the EDG program tree to a file ## \n");
- }
- }
- #endif
- int
- // SgFile::callFrontEnd ( int & argc, char** & argv, SgFile & sageFile, int fileNameIndex )
- // SgFile::callFrontEnd ( int & argc, char** & argv )
- SgFile::callFrontEnd ()
- {
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- int fileNameIndex = 0;
- // DQ (4/21/2006): I think we can now assert this!
- ROSE_ASSERT(fileNameIndex == 0);
- // DQ (7/6/2005): Introduce tracking of performance of ROSE.
- TimingPerformance timer ("AST Front End Processing (SgFile):");
- // This function processes the command line and calls the EDG frontend.
- int frontendErrorLevel = 0;
- // Build an argc,argv based C style commandline (we might not really need this)
- vector<string> argv = get_originalCommandLineArgumentList();
- #if ROSE_INTERNAL_DEBUG
- if (ROSE_DEBUG > 9)
- {
- // Print out the input arguments, so we can set them up internally instead of
- // on the command line (which is driving me nuts)
- for (unsigned int i=0; i < argv.size(); i++)
- printf ("argv[%d] = %s \n",i,argv[i]);
- }
- #endif
- // printf ("Inside of SgFile::callFrontEnd(): fileNameIndex = %d \n",fileNameIndex);
- // Save this so that it can be used in the template instantiation phase later.
- // This file is later written into the *.ti file so that the compilation can
- // be repeated as required to instantiate all function templates.
- std::string translatorCommandLineString = CommandlineProcessing::generateStringFromArgList(argv,false,true);
- // printf ("translatorCommandLineString = %s \n",translatorCommandLineString.c_str());
- set_savedFrontendCommandLine(translatorCommandLineString);
- // display("At TOP of SgFile::callFrontEnd()");
- // local copies of argc and argv variables
- // The purpose of building local copies is to avoid
- // the modification of the command line by SLA
- vector<string> localCopy_argv = argv;
- // printf ("DONE with copy of command line! \n");
- // Process command line options specific to ROSE
- // This leaves all filenames and non-rose specific option in the argv list
- processRoseCommandLineOptions (localCopy_argv);
- // DQ (6/21/2005): Process template specific options so that we can generated
- // code for the backend compiler (this processing is backend specific).
- processBackendSpecificCommandLineOptions (localCopy_argv);
- // display("AFTER processRoseCommandLineOptions in SgFile::callFrontEnd()");
- // Use ROSE buildCommandLine() function
- // int numberOfCommandLineArguments = 24;
- // char** inputCommandLine = new char* [numberOfCommandLineArguments];
- // ROSE_ASSERT (inputCommandLine != NULL);
- vector<string> inputCommandLine;
- // Build the commandline for EDG
- build_EDG_CommandLine (inputCommandLine,localCopy_argv,fileNameIndex );
- // DQ (10/15/2005): This is now a single C++ string (and not a list)
- // Make sure the list of file names is allocated, even if there are no file names in the list.
- // DQ (1/23/2004): I wish that C++ string objects had been used uniformally through out this code!!!
- // ROSE_ASSERT (get_sourceFileNamesWithoutPath() != NULL);
- // ROSE_ASSERT (get_sourceFileNameWithoutPath().empty() == false);
- // display("AFTER build_EDG_CommandLine in SgFile::callFrontEnd()");
- // Exit if we are to ONLY call the vendor's backend compiler
- if (p_useBackendOnly == true)
- return 0;
- ROSE_ASSERT (p_useBackendOnly == false);
- // DQ (4/21/2006): If we have called the frontend for this SgFile then mark this file to be unparsed.
- // This will cause code to be generated and the compileOutput() function will then set the name of
- // the file that the backend (vendor) compiler will compile to be the the intermediate file. Else it
- // will be set to be the origianl source file. In the new design, the frontendShell() can be called
- // to generate just the SgProject and SgFile nodes and we can loop over the SgFile objects and call
- // the frontend separately for each SgFile. so we have to set the output file name to be compiled
- // late in the processing (at backend compile time since we don't know when or if the frontend will
- // be called for each SgFile).
- set_skip_unparse(false);
- #if 0
- // DQ (2/13/2004): This is no longer used!!!
- // This sets up a "call back" function.
- // This function sets a function pointer internal to SAGE (EDG sage_gen_be.C) which
- // is called by the sage processing after the EDG AST is translated into the SAGE AST.
- // The alternative would be to have the generation of the EDG PDF file be generated as
- // an option to EDG, but this would requirre the addition of the PDF headers to EDG which
- // I would like to avoid (I want to avoid modifying EDG if possible).
- // set_sage_transform_function(roseDisplayMechanism);
- // set_sage_edg_AST_display_function(roseDisplayMechanism);
- // DQ (4/23/2006): Declaration of friend function required here by g++ 4.1.0!
- void alternativeSageEdgInterfaceConstruction( SgFile *file );
- set_sage_transform_function(alternativeSageEdgInterfaceConstruction);
- #endif
- // DQ (1/22/2004): As I recall this has a name that really
- // should be "disable_edg" instead of "disable_edg_backend".
- if ( get_disable_edg_backend() == false )
- {
- // ROSE::new_frontend = true;
- // We can either use the newest EDG frontend separately (useful for debugging)
- // or the EDG frontend that is included in SAGE III (currently EDG 3.3).
- // New EDG frontend:
- // This permits testing with the most up-to-date version of the EDG frontend and
- // can be useful in identifing errors or bugs in the SAGE processing (or ROSE itself).
- // EDG frontend used by SAGE III:
- // The use of this frontend permits the continued processing via ROSE and the
- // unparsing of the AST to rebuilt the C++ source code (with transformations if any
- // were done).
- // DQ (10/15/2005): This is now a C++ string (and not char* C style string)
- // Make sure that we have generated a proper file name (or move filename
- // processing to processRoseCommandLineOptions()).
- // printf ("Print out the file name to make sure it is processed \n");
- // printf (" filename = %s \n",get_unparse_output_filename());
- // ROSE_ASSERT (get_unparse_output_filename() != NULL);
- // ROSE_ASSERT (get_unparse_output_filename().empty() == false);
- std::string edgFrontEndCommandLineString;
- if ( get_new_frontend() == true )
- {
- // Use the current version of the EDG frontend from EDG (or any other version)
- printf ("ROSE::new_frontend == true (call edgFrontEnd using unix system() function!) \n");
- if ( get_KCC_frontend() == true )
- {
- edgFrontEndCommandLineString = "KCC "; // -cpfe_only is no longer supported (I think)
- }
- else
- {
- edgFrontEndCommandLineString = "edgFrontEnd ";
- }
- edgFrontEndCommandLineString += CommandlineProcessing::generateStringFromArgList(inputCommandLine,true,false);
- if ( get_verbose() > 1 )
- printf ("edgFrontEndCommandLineString = %s \n",edgFrontEndCommandLineString.c_str());
- system(edgFrontEndCommandLineString.c_str());
- // exit(0);
- }
- else
- {
- // Call the "INTERNAL" EDG Front End used by ROSE (with modified command
- // line input so that ROSE's command line is simplified)!
- if ( get_verbose() > 1 )
- printf ("Calling edg_main \n");
- #if 0
- edgFrontEndCommandLineString = std::string(argv[0]) + std::string(" ") + CommandlineProcessing::generateStringFromArgList(inputCommandLine,false,false);
- if ( get_verbose() > 1 )
- printf ("edgFrontEndCommandLineString = %s \n",edgFrontEndCommandLineString.c_str());
- #endif
- // We need to detect errors in this stage so that we can prevent further processing
- // int edg_errorLevel = edg_main (numberOfCommandLineArguments, inputCommandLine,sageFile);
- // int edg_errorLevel = edg_main (numberOfCommandLineArguments, inputCommandLine,*this);
- // int frontendErrorLevel = 0;
- #if 0
- printf ("get_C_only() = %s \n",(get_C_only() == true) ? "true" : "false");
- printf ("get_C99_only() = %s \n",(get_C99_only() == true) ? "true" : "false");
- printf ("get_Fortran_only() = %s \n",(get_Fortran_only() == true) ? "true" : "false");
- printf ("get_F77_only() = %s \n",(get_F77_only() == true) ? "true" : "false");
- printf ("get_F90_only() = %s \n",(get_F90_only() == true) ? "true" : "false");
- printf ("get_F95_only() = %s \n",(get_F95_only() == true) ? "true" : "false");
- printf ("get_F2003_only() = %s \n",(get_F2003_only() == true) ? "true" : "false");
- #endif
- if (get_Fortran_only() == true)
- {
- // frontendErrorLevel = openFortranParser_main (numberOfCommandLineArguments, inputCommandLine,*this);
- // printf ("Calling the openFortranParser_main() function (which loads the JVM) \n");
- // DQ (9/30/2007): Introduce syntax checking on input code (initially we can just call the backend compiler
- // and let it report on the syntax errors). Later we can make this a command line switch to disable (default
- // should be true).
- bool syntaxCheckInputCode = true;
- if (syntaxCheckInputCode == true)
- {
- // DQ (9/30/2007): Introduce tracking of performance of ROSE.
- TimingPerformance timer ("Fortran syntax checking of input:");
- // DQ (9/30/2007): For Fortran, we want to run gfortran up front so that we can verify that
- // the input file is syntax error free. First lets see what data is avilable to use to check
- // that we have a fortran file.
- // display("Before calling OpenFortranParser, what are the values in the SgFile");
- // DQ (9/30/2007): Call the backend Fortran compiler (typically gfortran) to check the syntax
- // of the input program. When using GNU gfortran, use the "-S" option which means:
- // "Compile only; do not assemble or link".
- string syntaxCheckingCommandline = "gfortran -S " + get_sourceFileNameWithPath();
- printf ("Checking syntax of input program using gfortran: syntaxCheckingCommandline = %s \n",syntaxCheckingCommandline.c_str());
- // Call the OS with the commandline defined by: syntaxCheckingCommandline
- int returnValueForSyntaxCheckUsingBackendCompiler = system (syntaxCheckingCommandline.c_str());
- // Check that there are no errors, I think that warnings are ignored!
- if (returnValueForSyntaxCheckUsingBackendCompiler != 0)
- {
- printf ("Syntax errors detected in input problem ... \n");
- exit(1);
- }
- ROSE_ASSERT(returnValueForSyntaxCheckUsingBackendCompiler == 0);
- }
- // edgFrontEndCommandLineString = std::string(argv[0]) + std::string(" --class parser.java.FortranParserActionJNI ") + CommandlineProcessing::generateStringFromArgcArgv(numberOfCommandLineArguments,(const char**)inputCommandLine,false,false);
- // edgFrontEndCommandLineString = "xxx --class parser.java.FortranParserActionJNI /home/dquinlan/ROSE/NEW_ROSE/developersScratchSpace/Dan/Fortran_tests/test2007_01.f90";
- // edgFrontEndCommandLineString = "--dump /home/dquinlan/ROSE/NEW_ROSE/developersScratchSpace/Dan/Fortran_tests/test2007_01.f90";
- // edgFrontEndCommandLineString = std::string(argv[0]) + " --class parser.java.FortranParserActionJNI /home/dquinlan/ROSE/NEW_ROSE/developersScratchSpace/Dan/Fortran_tests/test2007_01.f90";
- edgFrontEndCommandLineString = std::string(argv[0]) + " --class parser.java.FortranParserActionJNI " + get_sourceFileNameWithPath();
- if ( get_verbose() > -1 )
- printf ("numberOfCommandLineArguments = %zu edgFrontEndCommandLineString = %s \n",inputCommandLine.size(),edgFrontEndCommandLineString.c_str());
- int openFortranParser_argc = 0;
- char** openFortranParser_argv = NULL;
- CommandlineProcessing::generateArgcArgvFromList(CommandlineProcessing::generateArgListFromString(edgFrontEndCommandLineString),openFortranParser_argc,openFortranParser_argv);
- // printf ("openFortranParser_argc = %d openFortranParser_argv = %s \n",openFortranParser_argc,CommandlineProcessing::generateStringFromArgList(openFortranParser_argv,false,false).c_str());
- // DQ (8/19/2007): Setup the global pointer used to pass the SgFile to which the Open Fortran Parser
- // should attach the AST. This is a bit ugly, but the parser interface only takes a commandline so it
- // would be more ackward to pass a pointer to a C++ object through the commandline or the Java interface.
- OpenFortranParser_globalFilePointer = const_cast<SgFile*>(this);
- ROSE_ASSERT(OpenFortranParser_globalFilePointer != NULL);
- printf ("Calling openFortranParser_main(): OpenFortranParser_globalFilePointer = %p \n",OpenFortranParser_globalFilePointer);
- // frontendErrorLevel = openFortranParser_main (numberOfCommandLineArguments, inputCommandLine);
- frontendErrorLevel = openFortranParser_main (openFortranParser_argc, openFortranParser_argv);
- printf ("DONE: Calling the openFortranParser_main() function (which loads the JVM) \n");
- // Reset this global pointer after we are done (just to be safe and avoid it being used later and causing strange bugs).
- OpenFortranParser_globalFilePointer = NULL;
- }
- else
- {
- edgFrontEndCommandLineString = std::string(argv[0]) + std::string(" ") + CommandlineProcessing::generateStringFromArgList(inputCommandLine,false,false);
- if ( get_verbose() > 1 )
- printf ("edgFrontEndCommandLineString = %s \n",edgFrontEndCommandLineString.c_str());
- int edg_argc = 0;
- char **edg_argv = NULL;
- CommandlineProcessing::generateArgcArgvFromList(inputCommandLine, edg_argc, edg_argv);
- frontendErrorLevel = edg_main (edg_argc, edg_argv, *this);
- }
- if ( get_verbose() > 1 )
- printf ("DONE: frontend called (frontendErrorLevel = %d) \n",frontendErrorLevel);
- // If we had any errors reporte by the EDG frontend then quite now
- if (frontendErrorLevel > 3)
- {
- // cout << "Errors in EDG Processing: (edg_errorLevel > 3)" << endl;
- if ( get_verbose() > 1 )
- printf ("frontendErrorLevel = %d \n",frontendErrorLevel);
- // DQ (9/22/2006): We need to invert the test result (return code) for
- // negative tests (where failure is expected and success is an error).
- if (get_negative_test() == true)
- {
- if ( get_verbose() > 1 )
- {
- printf ("(evaluation of frontend results) This is a negative tests, so an error in compilation is a PASS but a successful \n");
- printf ("compilation is not a FAIL since the faulure might happen in the compilation of the generated code by the vendor compiler. \n");
- }
- exit(0);
- }
- else
- {
- // Exit because there are errors in the input program
- cout << "Errors in EDG Processing: (frontendErrorLevel > 3)" << endl;
- ROSE_ABORT();
- }
- }
- // if there are warnings report that there are in the verbose mode and continue
- if (frontendErrorLevel > 0)
- {
- if ( get_verbose() >= 1 )
- cout << "Warnings in Rose parser/IR translation processing! (continuing ...) " << endl;
- }
- }
- }
- // DQ (4/20/2006): This code was moved from the SgFile constructor so that is would
- // permit the separate construction of the SgProject and call to the front-end cleaner.
- // DQ (5/22/2005): This is a older function with a newer more up-to-date comment on why we have it.
- // This function is a repository for minor AST fixups done as a post-processing step in the
- // construction of the Sage III AST from the EDG frontend. In some cases it fixes specific
- // problems in either EDG or the translation of EDG to Sage III (more the later than the former).
- // In other cases if does post-processing (e.g. setting parent pointers in the AST) can could
- // only done from a more complete global view of the staticly defined AST. In many cases these
- // AST fixups are not so temporary so the name of the function might change at some point.
- // Notice that all AST fixup is done before attachment of the comments to the AST.
- // temporaryAstFixes(this);
- AstPostProcessing(this);
- // This is set in the unparser now so that we can handle the source file plus all header files
- ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList == NULL);
- // Build the empty list container so that we can just add lists for new files as they are encountered
- p_preprocessorDirectivesAndCommentsList = new ROSEAttributesListContainer();
- ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList != NULL);
- // DQ (4/19/2006): since they can take a while and includes substantial
- // file I/O we make this optional (selected from the command line).
- // bool collectAllCommentsAndDirectives = get_collectAllCommentsAndDirectives();
- // DQ (4/19/2006): attachAllPreprocessingInfo() is now merged into the attachPreprocessingInfo()
- // function.
- // DQ (4/6/2006): This is also the correct function to call to use Wave.
- // Markus Kowarschik: attach preprocessor directives to AST nodes
- // This uses the AST traversal and so needs to be done after the
- // call to temporaryAstFixes(), above.
- if (get_skip_commentsAndDirectives() == false)
- {
- if (get_verbose() > 1)
- {
- printf ("In SgFile::callFrontEnd(): calling attachAllPreprocessingInfo() \n");
- }
- attachPreprocessingInfo(this);
- if (get_verbose() > 1)
- {
- printf ("In SgFile::callFrontEnd(): Done with attachAllPreprocessingInfo() \n");
- }
- }
- // DQ (4/11/2006): This is Lingxiao's work (new patch, since the first and second attempts didn't work)
- // to support attaching comments from all header files to the AST. It seems that both
- // attachPreprocessingInfo() and attachAllPreprocessingInfo() can be run as a mechanism to test
- // Lingxiao's work on at least the source file. Note that performance associated with collecting
- // all comments and CPP directives from header files might be a problem.
- // DQ (4/1/2006): This will have to be fixed a little later (next release)
- // DQ (3/29/2006): This is Lingxiao's work to support attaching comments from all header files to the
- // AST (the previous mechanism only extracted comments from the source file and atted them to the AST,
- // the part of the AST representing the input source file).
- // attachAllPreprocessingInfo(this,collectAllCommentsAndDirectives);
- // display("At bottom of SgFile::callFrontEnd()");
- // return the error code associated with the call to the C++ Front-end
- return frontendErrorLevel;
- }
- void
- SgFile::stripRoseCommandLineOptions ( vector<string>& argv )
- {
- // Strip out the rose specific commandline options
- // the assume all other arguments are to be passed onto the C or C++ compiler
- int optionCount = 0;
- // int i = 0;
- #if ROSE_INTERNAL_DEBUG
- // printf ("ROSE_DEBUG = %d \n",ROSE_DEBUG);
- // printf ("get_verbose() = %s value = %d \n",(get_verbose() > 1) ? "true" : "false",get_verbose());
- if ( (ROSE_DEBUG >= 1) || (get_verbose() > 2 )
- {
- printf ("In stripRoseCommandLineOptions: List ALL arguments: argc = %zu \n",argv.size());
- for (size_t i=0; i < argv.size(); i++)
- printf (" argv[%d] = %s \n",i,argv[i]);
- }
- #endif
- // Split out the ROSE options first
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- optionCount = sla(argv, "-" , "($)", "(h|help)",1);
- optionCount = sla(argv, "-rose:", "($)", "(h|help)",1);
- optionCount = sla(argv, "-rose:", "($)", "(V|version)", 1);
- // optionCount = sla(argv, "-rose:", "($)", "(v|verbose)",1);
- int integerOption = 0;
- optionCount = sla(argv, "-rose:", "($)^", "(v|verbose)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)", "(C|C_only)",1);
- optionCount = sla(argv, "-rose:", "($)", "(C99|C99_only)",1);
- // DQ (8/11/2007): Support for Fortran and its different flavors
- optionCount = sla(argv, "-rose:", "($)", "(f|F|Fortran)",1);
- optionCount = sla(argv, "-rose:", "($)", "(f77|F77|Fortran77)",1);
- optionCount = sla(argv, "-rose:", "($)", "(f90|F90|Fortran90)",1);
- optionCount = sla(argv, "-rose:", "($)", "(f95|F95|Fortran95)",1);
- optionCount = sla(argv, "-rose:", "($)", "(f2003|F2003|Fortran2003)",1);
- // DQ (8/27/2007):Support for Fortran language output format
- optionCount = sla(argv, "-rose:", "($)", "(fixedOutput|fixedFormatOutput)",1);
- optionCount = sla(argv, "-rose:", "($)", "(freeOutput|freeFormatOutput)",1);
- optionCount = sla(argv, "-rose:", "($)", "(C_output_language|Cxx_output_language|Fortran_output_language|Promela_output_language)",1);
- // DQ (5/19/2005): The output file name is constructed from the input source name (as I recall)
- // optionCount = sla(argv, "-rose:", "($)^", "(o|output)", &p_unparse_output_filename ,1);
- optionCount = sla(argv, "-rose:", "($)", "(skip_rose)",1);
- optionCount = sla(argv, "-rose:", "($)", "(skip_transformation)",1);
- optionCount = sla(argv, "-rose:", "($)", "(skip_unparse)",1);
- optionCount = sla(argv, "-rose:", "($)", "(unparse_includes)",1);
- optionCount = sla(argv, "-rose:", "($)", "(collectAllCommentsAndDirectives)",1);
- optionCount = sla(argv, "-rose:", "($)", "(skip_commentsAndDirectives)",1);
- optionCount = sla(argv, "-rose:", "($)", "(skipfinalCompileStep)",1);
- optionCount = sla(argv, "-rose:", "($)", "(prelink)",1);
- optionCount = sla(argv, "-" , "($)", "(ansi)",1);
- optionCount = sla(argv, "-rose:", "($)", "(markGeneratedFiles)",1);
- optionCount = sla(argv, "-rose:", "($)", "(negative_test)",1);
- integerOption = 0;
- optionCount = sla(argv, "-rose:", "($)^", "(embedColorCodesInGeneratedCode)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)^", "(generateSourcePositionCodes)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)", "(outputGrammarTreeFiles)",1);
- optionCount = sla(argv, "-rose:", "($)", "(outputGrammarTreeFilesForHeaderFiles)",1);
- optionCount = sla(argv, "-rose:", "($)", "(outputGrammarTreeFilesForEDG)",1);
- optionCount = sla(argv, "-rose:", "($)", "(new_unparser)",1);
- optionCount = sla(argv, "-rose:", "($)", "(negative_test)",1);
- optionCount = sla(argv, "-rose:", "($)", "(strict)",1);
- integerOption = 0;
- optionCount = sla(argv, "-rose:", "($)^", "test", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)", "(skipfinalCompileStep)",1);
- optionCount = sla(argv, "-rose:", "($)", "(prelink)",1);
- char* templateInstationationOption = NULL;
- optionCount = sla(argv, "-rose:", "($)^", "(instantiation)",templateInstationationOption,1);
- // DQ (6/17/2005): Added support for AST merging (sharing common parts of the AST most often represented in common header files of a project)
- optionCount = sla(argv, "-rose:", "($)", "(astMerge)",1);
- char* filename = NULL;
- optionCount = sla(argv, "-rose:", "($)^", "(astMergeCommandFile)",filename,1);
- optionCount = sla(argv, "-rose:", "($)^", "(compilationPerformanceFile)",filename,1);
- //AS(093007) Remove paramaters relating to excluding and include comments and directives
- optionCount = sla(argv, "-rose:", "($)^", "(excludeCommentsAndDirectives)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)^", "(excludeCommentsAndDirectivesFrom)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)^", "(includeCommentsAndDirectives)", &integerOption, 1);
- optionCount = sla(argv, "-rose:", "($)^", "(includeCommentsAndDirectivesFrom)", &integerOption, 1);
- }
- void
- SgFile::stripEdgCommandLineOptions ( vector<string> & argv )
- {
- // Strip out the EDG specific commandline options the assume all
- // other arguments are to be passed onto the C or C++ compiler
- #if 0
- if ( (ROSE_DEBUG >= 0) || (get_verbose() > 1) )
- {
- Rose_STL_Container<string> l = CommandlineProcessing::generateArgListFromArgcArgv (argc,argv);
- printf ("In SgFile::stripEdgCommandLineOptions: argv = \n%s \n",StringUtility::listToString(l).c_str());
- }
- #endif
- // Split out the EDG options (ignore the returned Rose_STL_Container<string> object)
- CommandlineProcessing::removeArgs (argv,"-edg:");
- CommandlineProcessing::removeArgs (argv,"--edg:");
- CommandlineProcessing::removeArgsWithParameters (argv,"-edg_parameter:");
- CommandlineProcessing::removeArgsWithParameters (argv,"--edg_parameter:");
- #if 0
- Rose_STL_Container<string> l = CommandlineProcessing::generateArgListFromArgcArgv (argc,argv);
- printf ("In SgFile::stripEdgCommandLineOptions: argv = \n%s \n",StringUtility::listToString(l).c_str());
- printf ("Exiting in stripEdgCommandLineOptions() \n");
- ROSE_ASSERT (1 == 2);
- #endif
- }
- void
- SgFile::processRoseCommandLineOptions ( vector<string> & argv )
- {
- // Strip out the rose specific command line options
- // then search for all filenames (options without the "-" prefix)
- // the assume all other arguments are to be passed onto the C or C++ compiler
- // int optionCount = 0;
- // int i = 0;
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // Split out the ROSE options first
- // printf ("Before processing ROSE options argc = %d \n",argc);
- //
- // help option (allows alternative -h or -help instead of just -rose:help)
- // This is the only rose options that does not require the "-rose:" prefix
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(h|help)",true) == true ||
- CommandlineProcessing::isOption(argv,"--", "(h|help)",true) == true ||
- CommandlineProcessing::isOption(argv,"-","(h|help)",true) == true )
- {
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- // ROSE::usage(0);
- usage(0);
- // exit(0);
- }
- //
- // version option
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(V|version)",true) == true )
- {
- // function in SAGE III to access version number of EDG
- extern std::string edgVersionString();
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- printf (" Using C++ and C frontend from EDG (version %s) internally \n",edgVersionString().c_str());
- }
- //
- // markGeneratedFiles option
- //
- set_markGeneratedFiles(false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(markGeneratedFiles)",true) == true )
- {
- // Optionally mark the generated files with "#define ROSE_GENERATED_CODE"
- set_markGeneratedFiles(true);
- }
- //
- // embedColorCodesInGeneratedCode option
- //
- int integerOptionForEmbedColorCodesInGeneratedCode = 0;
- if ( CommandlineProcessing::isOptionWithParameter(argv,"-rose:","(embedColorCodesInGeneratedCode)",integerOptionForEmbedColorCodesInGeneratedCode,true) == true )
- {
- printf ("Calling set_embedColorCodesInGeneratedCode(%d) \n",integerOptionForEmbedColorCodesInGeneratedCode);
- set_embedColorCodesInGeneratedCode(integerOptionForEmbedColorCodesInGeneratedCode);
- }
- //
- // generateSourcePositionCodes option
- //
- int integerOptionForGenerateSourcePositionCodes = 0;
- if ( CommandlineProcessing::isOptionWithParameter(argv,"-rose:","(generateSourcePositionCodes)",integerOptionForGenerateSourcePositionCodes,true) == true )
- {
- printf ("Calling set_generateSourcePositionCodes(%d) \n",integerOptionForGenerateSourcePositionCodes);
- set_generateSourcePositionCodes(integerOptionForGenerateSourcePositionCodes);
- }
- //
- // verbose option
- //
- // DQ (4/20/2006): This can already be set (to none zero value) if the SgProject was previously build already (see tutorial/selectedFileTranslation.C)
- // ROSE_ASSERT (get_verbose() == 0);
- // if ( CommandlineProcessing::isOption(argv,"-rose:","(v|verbose)",true) )
- int integerOptionForVerbose = 0;
- if ( CommandlineProcessing::isOptionWithParameter(argv,"-rose:","(v|verbose)",integerOptionForVerbose,true) == true )
- {
- // set_verbose(true);
- set_verbose(integerOptionForVerbose);
- // DQ (8/12/2004): The semantics is to set the global concept of a value
- // for verbose to the maximum of that from the individual files.
- if (SgProject::get_verbose() < integerOptionForVerbose)
- SgProject::set_verbose(integerOptionForVerbose);
- if ( SgProject::get_verbose() >= 1 )
- printf ("verbose mode ON \n");
- }
- //
- // C only option (turns on EDG "--c" option and g++ "-xc" option)
- //
- // DQ (12/2/2006): Note that the filename extension could have set this to C++ mode and we only don't want an explicit specification of "-rose:C" to change this.
- set_C_only(false);
- ROSE_ASSERT (get_C_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(C|C_only)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("C only mode ON \n");
- set_C_only(true);
- if (get_sourceFileUsesCppFileExtension() == true)
- {
- printf ("Warning, C++ source file name specificed with explicit -rose:C C language option! (ignoring explicit option to mimic gcc behavior) \n");
- set_C_only(false);
- }
- }
- //
- // C99 only option (turns on EDG "--c" option and g++ "-xc" option)
- //
- set_C99_only(false);
- ROSE_ASSERT (get_C99_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(C99|C99_only)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("C99 mode ON \n");
- set_C99_only(true);
- }
- set_Fortran_only(false);
- ROSE_ASSERT (get_Fortran_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(f|F|Fortran)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran only mode ON \n");
- set_Fortran_only(true);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with explicit -rose:Fortran Fortran language option! \n");
- set_Fortran_only(false);
- }
- }
- set_F77_only(false);
- ROSE_ASSERT (get_F77_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(f77|F77|Fortran77)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran77 only mode ON \n");
- set_F77_only(true);
- set_Fortran_only(true);
- if (get_sourceFileUsesFortran77FileExtension() == false)
- {
- printf ("Warning, Non Fortran77 source file name specificed with explicit -rose:Fortran77 Fortran 77 language option! \n");
- set_F77_only(false);
- }
- }
- set_F90_only(false);
- ROSE_ASSERT (get_F90_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(f90|F90|Fortran90)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran90 only mode ON \n");
- set_F90_only(true);
- set_Fortran_only(true);
- if (get_sourceFileUsesFortran90FileExtension() == false)
- {
- printf ("Warning, Non Fortran90 source file name specificed with explicit -rose:Fortran90 Fortran 90 language option! \n");
- set_F90_only(false);
- }
- }
- set_F95_only(false);
- ROSE_ASSERT (get_F95_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(f95|F95|Fortran95)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran95 only mode ON \n");
- set_F95_only(true);
- set_Fortran_only(true);
- if (get_sourceFileUsesFortran95FileExtension() == false)
- {
- printf ("Warning, Non Fortran95 source file name specificed with explicit -rose:Fortran95 Fortran 95 language option! \n");
- set_F95_only(false);
- }
- }
- set_F2003_only(false);
- ROSE_ASSERT (get_F2003_only() == false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(f2003|F2003|Fortran2003)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran2003 only mode ON \n");
- set_F2003_only(true);
- set_Fortran_only(true);
- if (get_sourceFileUsesFortran2003FileExtension() == false)
- {
- printf ("Warning, Non Fortran2003 source file name specificed with explicit -rose:Fortran2003 Fortran 2003 language option! \n");
- set_F2003_only(false);
- }
- }
- // Fixed format v.s. free format option handling (ROSE defaults to fix or free format, depending on the file extension).
- // F77 default is fixed format, F90 and later default is free format.
- // Fortran source file format options for different compilers(for IBM/XL,Intel,Portland,GNU):
- // IBM/XL Intel Portland GNU
- // -qfixed -fixed -Mfixed -ffixed-form
- // -qfree -free -Mfree -free-form
- // GNU gfortran also supports -fno-fixed-form (we could use this to turn off all fixed form
- // formatting independent of the input source).
- set_fixedFormat(false);
- ROSE_ASSERT (get_fixedFormat() == false);
- if ( CommandlineProcessing::isOption(argv,"-","(ffixed-form|fixed|Mfixed|qfixed)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran fixed format mode explicitly set: ON \n");
- set_fixedFormat(true);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with explicit fixed format code generation (unparser) option! \n");
- set_fixedFormat(false);
- }
- }
- set_freeFormat(false);
- ROSE_ASSERT (get_freeFormat() == false);
- if ( CommandlineProcessing::isOption(argv,"-","(ffree-form|free|Mfree|qfree)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran free format mode explicitly set: ON \n");
- set_freeFormat(true);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with explicit free format code generation (unparser) option! \n");
- set_freeFormat(false);
- }
- }
- // DQ (8/19/2007): This option only controls the output format (unparsing) of Fortran code (free or fixed format).
- // It has no effect on C/C++ code generation (unparsing).
- set_outputFormat(SgFile::e_unknown_output_format);
- ROSE_ASSERT (get_outputFormat() == SgFile::e_unknown_output_format);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(fixedOutput|fixedFormatOutput)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran fixed format output specified \n");
- set_outputFormat(SgFile::e_fixed_form_output_format);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with code generation option: free format! \n");
- ROSE_ASSERT(false);
- }
- }
- if ( CommandlineProcessing::isOption(argv,"-rose:","(freeOutput|freeFormatOutput)",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran free format mode explicitly set: ON \n");
- set_outputFormat(SgFile::e_free_form_output_format);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with code generation option: fixed format! \n");
- ROSE_ASSERT(false);
- }
- }
- set_fortran_implicit_none(false);
- ROSE_ASSERT (get_fortran_implicit_none() == false);
- if ( CommandlineProcessing::isOption(argv,"-","fimplicit_none",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran free format mode explicitly set: ON \n");
- set_fortran_implicit_none(true);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with explicit free format code generation (unparser) option! \n");
- set_fortran_implicit_none(false);
- }
- }
- // DQ (8/19/2007): I have added the option here so that we can start to support OpenMP for Fortran.
- // Allows handling of OpenMP "!$omp" directives in free form and "c$omp", *$omp and "!$omp" directives in fixed form, enables "!$" conditional
- // compilation sentinels in free form and "c$", "*$" and "!$" sentinels in fixed form and when linking arranges for the OpenMP runtime library
- // to be linked in. (Not implemented yet).
- set_fortran_openmp(false);
- ROSE_ASSERT (get_fortran_openmp() == false);
- if ( CommandlineProcessing::isOption(argv,"-","fopenmp",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Fortran OpenMP option specified \n");
- set_fortran_openmp(true);
- if (get_sourceFileUsesFortranFileExtension() == false)
- {
- printf ("Warning, Non Fortran source file name specificed with explicit OpenMP option! \n");
- set_fortran_openmp(false);
- }
- }
- //
- // strict ANSI/ISO mode option
- //
- // set_strict_language_handling(false);
- if ( CommandlineProcessing::isOption(argv,"-rose:","(strict)",true) == true )
- {
- // Optionally specify strict language handling
- set_strict_language_handling(true);
- }
- //
- // specify output file option
- //
- // DQ (10/15/2005): There is a valid default value here, but we want to overwrite it!
- std::string stringParameter;
- if ( CommandlineProcessing::isOptionWithParameter(argv,"-rose:","(o|output)",stringParameter,true) == true )
- {
- // printf ("-rose:output %s \n",stringParameter.c_str());
- if (get_unparse_output_filename().empty() == false)
- {
- printf ("Overwriting value in get_unparse_output_filename() = %s \n",get_unparse_output_filename().c_str());
- }
- // DQ (10/15/2005): This is so much simpler!
- p_unparse_output_filename = stringParameter;
- }
- // printf ("After processing -rose:output option argc = %d \n",argc);
- // ROSE_ABORT();
- // DQ (4/20/2006): Added to support fall through option to be supported by user translators.
- //
- // skip_rose option (just call the backend compiler directly): This causes Rose to act identally
- // to the backend compiler (with no creation of the ROSE AST, translation, code generation, etc.).
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(skip_rose)",true) == true )
- {
- printf ("option -rose:skip_rose found \n");
- // set_skip_rose(true);
- // Need these to be set correctly as well
- p_useBackendOnly = true;
- // p_skip_buildHigherLevelGrammars = true;
- p_disable_edg_backend = true; // This variable should be called frontend NOT backend???
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = false;
- // Skip all processing of comments
- set_skip_commentsAndDirectives(true);
- set_collectAllCommentsAndDirectives(false);
- }
- //
- // skip_transformation option: if transformations of the AST check this variable then the
- // resulting translators can skip the transformatios via this command-line specified option.
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(skip_transformation)",true) == true )
- {
- printf ("option -rose:skip_transformation found \n");
- set_skip_transformation(true);
- }
- //
- // skip_unparse option: if analysis only (without transformatio is required, then this can significantly
- // improve the performance since it will also skip the backend compilation, as I recall)
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(skip_unparse)",true) == true )
- {
- printf ("option -rose:skip_unparse found \n");
- set_skip_unparse(true);
- }
- // unparser language option
- // DQ (8/27/2007): This option controls the output language (which language unparser is to be used).
- // This allows the code generation of one language to be tested using input of another langauge. It is
- // mostly a mechanism to test the unparser in the early stages of their development. Unshared language
- // constructs are not supported and would have the be translated. This step does none of this sort of
- // translation, which might be difficult debendingon the input and output languages selected.
- // Supported options are:
- // e_default_output_language
- // e_C_output_language
- // e_Cxx_output_language
- // e_Fortran_output_language
- // e_Promela_output_language
- set_outputLanguage(SgFile::e_default_output_language);
- ROSE_ASSERT (get_outputLanguage() == SgFile::e_default_output_language);
- if ( CommandlineProcessing::isOption(argv,"-rose:","C_output_language",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Use the C language code generator (unparser) \n");
- set_outputLanguage(SgFile::e_C_output_language);
- }
- if ( CommandlineProcessing::isOption(argv,"-rose:","Cxx_output_language",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Use the C++ language code generator (unparser) \n");
- set_outputLanguage(SgFile::e_Cxx_output_language);
- }
- if ( CommandlineProcessing::isOption(argv,"-rose:","Fortran_output_language",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Use the Fortran language code generator (unparser) \n");
- set_outputLanguage(SgFile::e_Fortran_output_language);
- }
- if ( CommandlineProcessing::isOption(argv,"-rose:","Promela_output_language",true) == true )
- {
- if ( SgProject::get_verbose() >= 1 )
- printf ("Use the Promela language code generator (unparser) \n");
- set_outputLanguage(SgFile::e_Promela_output_language);
- }
- //
- // unparse_includes option
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(unparse_includes)",true) == true )
- {
- printf ("option -rose:unparse_includes found \n");
- set_unparse_includes(true);
- }
- //
- // collectAllCommentsAndDirectives option: operates across all files (include files) and significantly slows the compilation.
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(collectAllCommentsAndDirectives)",true) == true )
- {
- // printf ("option -rose:collectAllCommentsAndDirectives found \n");
- set_collectAllCommentsAndDirectives(true);
- }
- //
- // skip_commentsAndDirectives option: if analysis that does not use comments or CPP directives is required
- // then this option can improve the performance of the compilation.
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(skip_commentsAndDirectives)",true) == true )
- {
- printf ("option -rose:skip_commentsAndDirectives found \n");
- set_skip_commentsAndDirectives(true);
- // If we are skipping comments then we should not be collecting all comments (does not make sense)
- ROSE_ASSERT(get_collectAllCommentsAndDirectives() == false);
- // set_collectAllCommentsAndDirectives(false);
- }
- //
- // internal testing option (for internal use only, these may disappear at some point)
- //
- int integerOption = 0;
- if ( CommandlineProcessing::isOptionWithParameter(argv,"-rose:","test",integerOption,true) == true )
- {
- // printf ("option -rose:test %d found \n",integerOption);
- p_testingLevel = integerOption;
- switch (integerOption)
- {
- case 0 :
- // transparent mode (does nothing)
- // p_skip_buildHigherLevelGrammars = true;
- p_disable_edg_backend = true; // This variable should be called frontend NOT backend???
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = true;
- break;
- case 1 :
- // run the KCC front end only (can't unparse or compile output)
- // p_skip_buildHigherLevelGrammars = true;
- p_new_frontend = true;
- p_KCC_frontend = true;
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = true;
- break;
- case 2 :
- // run the newer version of EDG (compiled separately from SAGE) "edgFrontEnd"
- // (can't unparse or compile output)
- // p_skip_buildHigherLevelGrammars = true;
- p_new_frontend = true;
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = true;
- break;
- case 3 :
- // run internal (older) version of edg front end (compiled with SAGE)
- // p_skip_buildHigherLevelGrammars = true;
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = true;
- break;
- case 4 :
- // all of 3 (above) plus parse into SAGE program tree
- // p_skip_buildHigherLevelGrammars = true;
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = true;
- break;
- case 5 :
- // all of 4 (above) plus unparse to generate (untransformed source code)
- // p_skip_buildHigherLevelGrammars = true;
- p_skip_transformation = true;
- p_skipfinalCompileStep = true;
- break;
- case 6 :
- // all of 4 (above) plus compile generated source code
- // p_skip_buildHigherLevelGrammars = true;
- p_skip_transformation = true;
- break;
- case 7 :
- // all of 5 (above) plus parse into higher level grammars before unparsing
- p_skip_transformation = true;
- p_skipfinalCompileStep = true;
- break;
- case 8 :
- // all of 7 (above) plus compile resulting unparsed code (without transformations)
- p_skip_transformation = true;
- break;
- case 9 :
- // all of 8 (above) plus run transformations before unparsing (do everything)
- break;
- default:
- // default mode is an error
- printf ("Default reached in processing -rose:test # option (use 0-6, input option = %d) \n",integerOption);
- ROSE_ABORT();
- break;
- }
- }
- #if 0
- printf ("Exiting after test of test option! \n");
- exit (0);
- #endif
- // printf ("After processing -rose:test # option argc = %d \n",argc);
- //
- // new_unparser option
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(skipfinalCompileStep)",true) == true )
- {
- printf ("option -rose:skipfinalCompileStep found \n");
- set_skipfinalCompileStep(true);
- }
- //
- // Standard compiler options (allows alternative -E option to just run CPP)
- //
- if ( CommandlineProcessing::isOption(argv,"-","(E)",true) == true )
- {
- // printf ("/* option -E found (just run backend compiler with -E to call CPP) */ \n");
- p_useBackendOnly = true;
- // p_skip_buildHigherLevelGrammars = true;
- p_disable_edg_backend = true; // This variable should be called frontend NOT backend???
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = false;
- }
- //
- // Standard compiler options (allows alternative -H option to just output header file info)
- //
- if ( CommandlineProcessing::isOption(argv,"-","(H)",true) == true )
- {
- // printf ("option -H found (just run backend compiler with -E to call CPP) \n");
- p_useBackendOnly = true;
- // p_skip_buildHigherLevelGrammars = true;
- p_disable_edg_backend = true; // This variable should be called frontend NOT backend???
- p_skip_transformation = true;
- p_skip_unparse = true;
- p_skipfinalCompileStep = false;
- }
- //
- // negative_test option: allows passing all tests to be treated as an error!
- //
- if ( CommandlineProcessing::isOption(argv,"-rose:","(negative_test)",true) == true )
- {
- printf ("option -rose:negative_test found \n");
- set_negative_test(true);
- }
- #if 1
- //
- // We have processed all rose supported command line options.
- // Anything left in argv now should be a typo or option for either EDG or the C or C++ compiler.
- //
- if ( get_verbose() > 1 )
- {
- cout << "The remaining non-rose options will be passed onto either EDG or the C or C++ the compiler: " << endl;
- for (unsigned int i = 1; i < argv.size(); i++)
- {
- cout << " argv[" << i << "]= " << argv[i] << endl;
- }
- }
- // debugging aid
- // display("SgFile::processRoseCommandLineOptions()");
- #endif
- }
- void
- SgFile::processBackendSpecificCommandLineOptions ( const vector<string>& argvOrig )
- {
- // DQ (6/21/2005): This function processes commandline options that are specific to the backend
- // but which the front-end or ROSE should know about. Examples include template options that
- // would influence how ROSE instatiates or outputs templates in the code generation phase.
- // This function leaves all commandline options in place (for use by the backend)
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- vector<string> argv = argvOrig;
- //
- // -ansi option (fairly general option name across a number of compilers, I think)
- //
- if ( CommandlineProcessing::isOption(argv,"-","ansi",true) == true )
- {
- set_strict_language_handling(true);
- }
- //
- // -fno-implicit-templates option
- //
- p_no_implicit_templates = false;
- if ( CommandlineProcessing::isOption(argv,"-f","no-implicit-templates",true) == true )
- {
- // don't instantiate any inline templates
- printf ("ROSE sees use of -fno-implicit-templates option for use by g++ \n");
- // printf ("ERROR: This g++ specific option is not yet supported \n");
- // ROSE_ASSERT(false);
- p_no_implicit_templates = true;
- }
- //
- // -fno-implicit-inline-templates option
- //
- p_no_implicit_inline_templates = false;
- if ( CommandlineProcessing::isOption(argv,"-f","no-implicit-inline-templates",true) == true )
- {
- // don't instantiate any inline templates
- printf ("ROSE sees use of -fno-implicit-inline-templates option for use by g++ \n");
- p_no_implicit_inline_templates = true;
- }
- }
- bool
- SgFile::isPrelinkPhase() const
- {
- // This function checks if the "-prelink" option was passed to the ROSE preprocessor
- // It could alternatively just check the commandline and set a flag in the SgFile object.
- // But then there would be a redundent flag in each SgFile object (perhaps the design needs to
- // be better, using a common base class for commandline options (in both the SgProject and
- // the SgFile (would not be a new IR node)).
- bool returnValue = false;
- // DQ (5/9/2004): If the parent is not set then this was compiled as a SgFile directly
- // (likely by the rewrite mechanism). IF so it can't be a prelink phase, which is
- // called only on SgProjects). Not happy with this mechanism!
- if (get_parent() != NULL)
- {
- ROSE_ASSERT ( get_parent() != NULL );
- SgProject* project = isSgProject(get_parent());
- ROSE_ASSERT ( project != NULL );
- returnValue = project->get_prelink();
- }
- return returnValue;
- // Note that project can be false if this is called on an intermediate file
- // generated by the rewrite system.
- // return (project == NULL) ? false : project->get_prelink();
- }
- SgProject*
- SgFile::get_project()
- {
- // If the project is a parent of the current SgFile then we find it, else return NULL.
- SgNode* parent = get_parent();
- // DQ (7/12/2005): The parent is NULL if we have only built a single file (e.g. within the rewrite mechanism)
- // ROSE_ASSERT(parent != NULL);
- SgProject* project = NULL;
- // DQ (7/12/2005): The parent is NULL if we have only built a single file (e.g. within the rewrite mechanism)
- // Just return NULL in this case!
- if (parent != NULL)
- {
- project = isSgProject(parent);
- while ( project == NULL && parent->get_parent() != NULL )
- {
- parent = parent->get_parent();
- ROSE_ASSERT(parent != NULL);
- project = isSgProject(parent);
- }
- ROSE_ASSERT ( project != NULL );
- }
- return project;
- }
- void
- SgFile::build_EDG_CommandLine (
- vector<string> & inputCommandLine, vector<string> & argv, int fileNameIndex )
- {
- // This function builds the command line input for the edg_main (the EDG C++ Front-End)
- // There are numerous options that must be set for different architectures. We can find
- // a more general setup of these options within something like Duct-Tape. In this function
- // argv and argc are the parameters from the user's commandline, and inputCommandLine and
- // numberOfCommandLineArguments are parameters for the new command line that will be build
- // for EDG.
- // Old information recorded here (but not useful any more):
- // Complete Command line required to run ROSE Preprocessor (old version for SUN CC 4.2
- // compiler worked out by Kei Davis at LANL):
- // ../src/rose -D__CPLUSPLUS -D__STDC__=0 -Dsun -Dsparc -Dunix -D__KCC -D__sun__
- // -D__sparc__ -D__unix__ -D_parc -D__unix -D__SVR4 -D_NO_LONGLONG
- // -I/opt/SUNWspro/SC4.2/include/CC/ -I$APlusPlus/include test1.C
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // printf ("##### Inside of SgFile::build_EDG_CommandLine file = %s \n",get_file_info()->get_filenameString().c_str());
- // printf ("##### Inside of SgFile::build_EDG_CommandLine file = %s = %s \n",get_file_info()->get_filenameString().c_str(),get_sourceFileNameWithPath().c_str());
- ROSE_ASSERT(get_file_info()->get_filenameString() == get_sourceFileNameWithPath());
- // ROSE_ASSERT (p_useBackendOnly == false);
- // DQ (4/21/2006): I think we can now assert this!
- ROSE_ASSERT(fileNameIndex == 0);
- // printf ("Inside of SgFile::build_EDG_CommandLine(): fileNameIndex = %d \n",fileNameIndex);
- // BP: (11/26/2001) trying out a new method of figuring out internal compiler definitions
- #if defined(CXX_SPEC_DEF)
- #if 1
- string configDefsString = CXX_SPEC_DEF;
- const string Cxx_ConfigIncludeString = CXX_INCLUDE_STRING;
- const string C_ConfigIncludeString = C_INCLUDE_STRING;
- // Removed reference to __restrict__ so it could be placed into the preinclude vendor specific header file for ROSE.
- // DQ (9/10/2004): Attept to add support for restrict (but I think this just sets it to true, using "-Dxxx=" works)
- // const string roseSpecificDefs = "-DUSE_RESTRICT_POINTERS_IN_ROSE_TRANSFORMATIONS -DUSE_ROSE -D__restrict__=";
- const string roseSpecificDefs = "-DUSE_RESTRICT_POINTERS_IN_ROSE_TRANSFORMATIONS -DUSE_ROSE";
- ROSE_ASSERT(configDefsString.empty() == false);
- ROSE_ASSERT(Cxx_ConfigIncludeString.empty() == false);
- ROSE_ASSERT(C_ConfigIncludeString.empty() == false);
- // printf ("configDefsString = %s \n",configDefsString);
- #if 0
- printf ("Cxx_ConfigIncludeString = %s \n",Cxx_ConfigIncludeString.c_str());
- printf ("C_ConfigIncludeString = %s \n",C_ConfigIncludeString.c_str());
- #endif
- // AS (03/08/2006) Added support for g++ preincludes
- // Rose_STL_Container<std::string> listOfPreincludes;
- // DQ (12/1/2006): Code added by Andreas (07/03/06) and moved to a new position
- // so that we could modify the string input from CXX_SPEC_DEF (configDefsString).
- string preinclude_string_target = "-include";
- string preinclude_string;
- for (unsigned int i=1; i < argv.size(); i++)
- {
- // AS (070306) Handle g++ --include directives
- std::string stack_arg(argv[i]);
- // std::cout << "stack arg is: " << stack_arg << std::endl;
- if( stack_arg.find(preinclude_string_target) <= 2)
- {
- i++;
- ROSE_ASSERT(i<argv.size());
- string currentArgument(argv[i]);
-
- string headerSuffix = ".h";
- int jlength = headerSuffix.size();
- int length = currentArgument.size();
- ROSE_ASSERT( length > jlength);
- ROSE_ASSERT( ( currentArgument.compare(length - jlength, jlength, headerSuffix) == 0 ) || CommandlineProcessing::isSourceFilename(currentArgument));
- string sourceFilePath = StringUtility::getPathFromFileName(currentArgument);
- currentArgument = StringUtility::stripPathFromFileName(currentArgument);
- if (sourceFilePath == "" )
- sourceFilePath = "./";
- sourceFilePath = StringUtility::getAbsolutePathFromRelativePath(sourceFilePath);
- currentArgument = sourceFilePath+"/"+currentArgument;
- // std::cout << "Found preinclude : " << currentArgument << std::endl;
- preinclude_string += " --preinclude " + currentArgument + " ";
- }
- }
- configDefsString += preinclude_string;
- string initString;
- // This is OK since these use the existing memory and not the C language
- // malloc/free (which would interfere with C++'s new/delete)
- initString = configDefsString;
- initString += " ";
- // initString += Cxx_ConfigIncludeString;
- // DQ (12/2/2006): Both GNU and EDG determin the language mode from the source file name extension.
- // In ROSE we also require that C files be explicitly specified to use the C language mode. Thus
- // C++ source files will be treated as C++ even if the C language rules are specified, however they
- // are restricted to the C subset of C++.
- // bool treatAsCSourceFile = ((get_C_only() == true || get_C99_only() == true) && (get_sourceFileUsesCppFileExtension() == false));
- // if (treatAsCSourceFile == true)
- // Find the C++ sys include path for the rose_edg_required_macros_and_functions.h
- string roseHeaderDirCPP = " --sys_include ";
- Rose_STL_Container<string> internalIncludePathListForHeader = CommandlineProcessing::generateArgListFromString(Cxx_ConfigIncludeString);
- for (Rose_STL_Container<string>::iterator i = internalIncludePathListForHeader.begin(); i != internalIncludePathListForHeader.end(); i++)
- {
- if (i->substr(0,13) == "--sys_include")
- {
- i++;
- if ( ( i != internalIncludePathListForHeader.end() ) && ( (i->substr(0,8) != "--sys_include") || (i->substr(0,2) == "-I") ))
- {
- string file = (*i) + "/rose_edg_required_macros_and_functions.h";
- FILE* testIfFileExist = fopen(file.c_str(),"r");
- if (testIfFileExist)
- {
- roseHeaderDirCPP+=(*i);
- fclose(testIfFileExist);
- break;
- }
- }
- }
- }
- // Find the C sys include path for the rose_edg_required_macros_and_functions.h
- string roseHeaderDirC = " --sys_include ";
- internalIncludePathListForHeader = CommandlineProcessing::generateArgListFromString(C_ConfigIncludeString);
- for (Rose_STL_Container<string>::iterator i = internalIncludePathListForHeader.begin(); i != internalIncludePathListForHeader.end(); i++)
- {
- if (i->substr(0,13) == "--sys_include")
- {
- i++;
- if ( (i != internalIncludePathListForHeader.end() ) && ( (i->substr(0,13) != "--sys_include") || (i->substr(0,2) == "-I") ))
- {
- string file = (*i) + "/rose_edg_required_macros_and_functions.h";
- FILE* testIfFileExist = fopen(file.c_str(),"r");
- // std::cout << file << std::endl;
- if (testIfFileExist)
- {
- roseHeaderDirC+=(*i);
- fclose(testIfFileExist);
- break;
- }
- }
- }
- }
- if (get_C_only() == true || get_C99_only() == true)
- {
- // AS(02/21/07) Add support for the gcc 'nostdinc' and 'nostdinc++' options
- string roseHeaderDir = " --sys_include ";
- // DQ (11/29/2006): if required turn on the use of the __cplusplus macro
- // if (get_requires_cplusplus_macro() == true)
- if (get_sourceFileUsesCppFileExtension() == true)
- {
- // The value here should be 1 to match that of GNU gcc (the C++ standard requires this to be "199711L")
- // initString += " -D__cplusplus=0 ";
- initString += " -D__cplusplus=1 ";
- if ( CommandlineProcessing::isOption(argv,"-","nostdinc",false) == true )
- {
- initString+=roseHeaderDirC;
- // no standard includes when -nostdinc is specified
- }
- else
- {
- if ( CommandlineProcessing::isOption(argv,"-","nostdinc++",false) == true )
- {
- initString += roseHeaderDirCPP;
- initString += C_ConfigIncludeString;
- }
- else
- {
- initString += Cxx_ConfigIncludeString;
- }
- }
- // DQ (11/29/2006): Specify C++ mode for handling in rose_edg_required_macros_and_functions.h
- initString += " -DROSE_CPP_MODE=1 ";
- }
- else
- {
- if ( CommandlineProcessing::isOption(argv,"-","nostdinc",false) == true )
- {
- initString += roseHeaderDirC;
- // no standard includes when -nostdinc is specified
- }
- else
- {
- initString += C_ConfigIncludeString;
- }
-
- // DQ (11/29/2006): Specify C mode for handling in rose_edg_required_macros_and_functions.h
- initString += " -DROSE_CPP_MODE=0 ";
- }
- }
- else
- {
- if ( CommandlineProcessing::isOption(argv,"-","nostdinc",false) == true )
- {
- initString+=roseHeaderDirCPP;
- // no standard includes when -nostdinc is specified
- }
- else
- {
- if ( CommandlineProcessing::isOption(argv,"-","nostdinc++",false) == true )
- {
- initString += roseHeaderDirCPP;
- initString += C_ConfigIncludeString;
- }
- else
- {
- initString += Cxx_ConfigIncludeString;
- }
- }
- // DQ (11/29/2006): Specify C++ mode for handling in rose_edg_required_macros_and_functions.h
- initString += " -DROSE_CPP_MODE=1 ";
- }
- // AS(02/24/06) Add support for the gcc "-isystem" option (this added a specificed directory
- // to the start of the system include path). This maps to the "--sys_include" in EDG.
- string isystem_string_target = "-isystem";
- string isystem_string;
- for (unsigned int i=1; i < argv.size(); i++)
- {
- // AS (070306) Handle g++ --include directives
- std::string stack_arg(argv[i]);
- // std::cout << "stack arg is: " << stack_arg << std::endl;
- if( stack_arg.find(isystem_string_target) <= 2){
- i++;
- ROSE_ASSERT(i<argv.size());
- std::string currentArgument(argv[i]);
- // std::cout << "Current argument " << currentArgument << std::endl;
-
- currentArgument = StringUtility::getAbsolutePathFromRelativePath(currentArgument);
- isystem_string += " --sys_include " + currentArgument + " ";
- }
- }
- initString += isystem_string;
- initString += " ";
- initString += roseSpecificDefs;
- // DQ (9/17/2006): We should be able to build a version of this code which hands a std::string to StringUtility::splitStringIntoStrings()
- // Separate the string into substrings consistant with the structure of argv command line input
- inputCommandLine.clear();
- StringUtility::splitStringIntoStrings(initString, ' ', inputCommandLine);
- #endif
- #else
- // Output an error and exit
- cout << "ERROR: The preprocessor definition CXX_SPEC_DEF should have been defined by the configure process!!" << endl;
- ROSE_ABORT();
- #endif
- // We only provide options to change the default values!
- // Handle option for use of ROSE as a C compiler instead of C++
- // some C code can not be compiled with a C++ compiler.
- if (get_C_only() == true)
- {
- // Add option to indicate use of C code (not C++) to EDG frontend
- inputCommandLine.push_back("--c");
- }
- if (get_C99_only() == true)
- {
- // Add option to indicate use of C code (not C++) to EDG frontend
- inputCommandLine.push_back("--c99");
- }
- if (get_strict_language_handling() == true)
- {
- inputCommandLine.push_back("--strict");
- }
- //
- // edg_new_frontend option
- //
- if ( CommandlineProcessing::isOption(argv,"-edg:","(new_frontend)",true) == true || (get_new_frontend() == true) )
- {
- // printf ("option -edg:new_frontend found \n");
- set_new_frontend(true);
- // if we use the new EDG frontend (not connected to SAGE) then we can't
- // generate C++ code so we don't want to call the C++ compiler
- set_skipfinalCompileStep(true);
- }
- //
- // edg_KCC_frontend option
- //
- if ( CommandlineProcessing::isOption(argv,"-edg:","(KCC_frontend)",true) == true || (get_KCC_frontend() == true) )
- {
- // printf ("option -edg:KCC_frontend found \n");
- set_KCC_frontend(true);
- // if we use the new EDG frontend (not connected to SAGE) then we can't
- // generate C++ code so we don't want to call the C++ compiler
- set_skipfinalCompileStep(true);
- }
- //
- // edg_backend option
- //
- if ( CommandlineProcessing::isOption(argv,"-edg:","(disable_edg_backend)",true) == true || (get_disable_edg_backend() == true) )
- {
- // printf ("option -edg:disable_edg_backend found \n");
- set_disable_edg_backend(true);
- }
- #if 0
- //
- // sage_backend option
- //
- if ( CommandlineProcessing::isOption(argv,"-edg:","(disable_edg_backend)",true) == true || (get_disable_edg_backend() == true) )
- {
- // printf ("option -edg:disable_edg_backend found \n");
- set_disable_edg_backend(true);
- }
- #endif
- #if 0
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of argc
- optionCount = sla(&argc, argv, "-sage:", "($)", "(disable_sage_backend)",1);
- if( optionCount > 0 || (get_disable_sage_backend() == true) == true )
- {
- printf ("option -sage:disable_sage_backend found \n");
- set_disable_sage_backend(true);
- inputCommandLine.push_back("--disable_sage_backend");
- // We we aren't going to process the code through the backend then there is nothing to compile
- set_skipfinalCompileStep(true);
- }
- // printf ("After processing -sage:disable_sage_backend option argc = %d \n",argc);
- #endif
- #if 0
- //
- // cp_backend option
- //
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- optionCount = sla(&argc, argv, "-sage:", "($)", "(enable_cp_backend)",1);
- if ( optionCount > 0 || (get_enable_cp_backend() == true) )
- {
- // printf ("option -sage:enable_cp_backend found \n");
- set_enable_cp_backend(true);
- inputCommandLine.push_back("--enable_cp_backend");
- }
- // printf ("After processing -sage:enable_cp_backend option argc = %d \n",argc);
- //
- // preinit_il option
- //
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- optionCount = sla(&argc, argv, "-sage:", "($)", "(preinit_il)",1);
- if( optionCount > 0 || (get_preinit_il() == true))
- {
- printf ("option -sage:preinit_il found \n");
- set_preinit_il(true);
- inputCommandLine.push_back("--preinit_il");
- }
- // printf ("After processing -sage:preinit_il option argc = %zu \n",argv.size());
- #endif
- // ***********************************************************************
- // Now process the -D options, -I options and the filenames so that these
- // can also be used for the command line passed to the EDG frontend.
- // ***********************************************************************
- // *******************************
- // Add all input macro definitions
- // *******************************
- vector<string> macroDefineOptions;
- // DQ (9/25/2006): Fixed handling of "-D DEFINE_ERROR_WITH_SPACE -DDEFINE_OK_WITHOUT_SPACE"
- // skip the 0th entry since this is just the name of the program (e.g. rose)
- unsigned int argIndex = 1;
- while (argIndex < argv.size())
- {
- // most options appear as -<option>
- // have to process +w2 (warnings option) on some compilers so include +<option>
- if ( (argv[argIndex][0] == '-') && (argv[argIndex][1] == 'D') )
- {
- unsigned int length = argv[argIndex].size();
- // printf ("Look for include path: argv[%d] = %s length = %d \n",argIndex,argv[argIndex],length);
- macroDefineOptions.push_back(argv[argIndex]);
- // DQ (9/19/2006): There must be an option string associated with each "-D" option
- // ROSE_ASSERT(length > 2);
- if (length == 2)
- {
- printf ("Handling the case of \"-D\" with orphened option (unclear if this is legal) \n");
- macroDefineOptions.push_back("-D" + argv[argIndex + 1]);
- ++argIndex;
- }
- }
- argIndex++;
- }
- #if 0
- for (int i=0; i < macroDefineOptionCounter; i++)
- {
- printf (" macroDefineOptions[%d] = %s \n",i,macroDefineOptions[i]);
- }
- #endif
- // Add filenames (of source files) to so that the EDG front end will know what files to process
- inputCommandLine.insert(inputCommandLine.end(), macroDefineOptions.begin(), macroDefineOptions.end());
- // DQ (9/24/2006): Add -D option so that we can know when to turn on vendor compiler specific macros for ANSI/ISO compatability.
- if (get_strict_language_handling() == true)
- {
- inputCommandLine.push_back("-DROSE_STRICT_LANGUAGE_HANDLING");
- }
- // ********************************************************************************************
- // Now add the include paths to the end so that EDG knows where to find header files to process
- // ********************************************************************************************
- // Now add the include paths to the end so that EDG knows where to find head files to process
- // Add all input include paths so that the EDG front end will know where to find headers
- //AS(063006) Changed implementation so that real paths can be found later
- vector<string> includePaths;
- // skip the 0th entry since this is just the name of the program (e.g. rose)
- for (unsigned int i=1; i < argv.size(); i++)
- {
- // most options appear as -<option>
- // have to process +w2 (warnings option) on some compilers so include +<option>
- if ( argv[i].size() >= 2 && (argv[i][0] == '-') && (argv[i][1] == 'I') )
- {
- // int length = strlen(argv[i]);
- // printf ("Look for include path: argv[%d] = %s length = %d \n",i,argv[i],length);
-
- // AS: Did changes to get absolute path
- std::string includeDirectorySpecifier = argv[i].substr(2);
- includeDirectorySpecifier = "-I"+StringUtility::getAbsolutePathFromRelativePath(includeDirectorySpecifier );
- includePaths.push_back(includeDirectorySpecifier);
- }
- }
- #if 0
- for (int i=0; i < includePathCounter; i++)
- {
- printf (" includePaths[%d] = %s \n",i,includePaths[i]);
- }
- #endif
- // Add the -I definitions to the command line
- inputCommandLine.insert(inputCommandLine.end(), includePaths.begin(), includePaths.end());
- // *******************************************************************
- // Handle general edg options (-xxx)
- // *******************************************************************
- // Strip out all the -edg:xxx options and put them into the edg command line as -xxx
- // Resets modifiedArgc and allocates memory to modifiedArgv
- Rose_STL_Container<string> edgOptionList = CommandlineProcessing::generateOptionList (argv,"-edg:");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"-",edgOptionList);
- // *******************************************************************
- // Handle general edg options (--xxx)
- // *******************************************************************
- // Strip out all the -edg:xxx options and put them into the edg command line as --xxx
- // Resets modifiedArgc and allocates memory to modifiedArgv
- edgOptionList = CommandlineProcessing::generateOptionList (argv,"--edg:");
- // DQ (8/6/2006): there are a number of options that when specified in their EDG forms
- // should turn on ROSE mechanisms. "--edg:c" should turn on C mode in ROSE.
- // printf ("--edg option processing: edgOptionList.size() = %zu \n",edgOptionList.size());
- Rose_STL_Container<string>::iterator i = edgOptionList.begin();
- while (i != edgOptionList.end())
- {
- // fprintf (stderr, "edgOptionList: i = %s \n",i->c_str());
- if (*i == "c" || *i == "old_c")
- {
- // This is the EDG option "--c" obtained from the ROSE "--edg:c" option
- set_C_only(true);
- }
- if (*i == "c99")
- {
- // This is the EDG option "--c99" obtained from the ROSE "--edg:c99" option
- set_C99_only(true);
- }
- i++;
- }
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"--",edgOptionList);
- // *******************************************************************
- // Handle general edg options (-xxx abc)
- // *******************************************************************
- // Handle edg options taking a parameter (string or integer)
- edgOptionList = CommandlineProcessing::generateOptionWithNameParameterList (argv,"-edg_parameter:");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"-",edgOptionList);
- // *******************************************************************
- // Handle general edg options (--xxx abc)
- // *******************************************************************
- // Handle edg options taking a parameter (string or integer)
- edgOptionList = CommandlineProcessing::generateOptionWithNameParameterList (argv,"--edg_parameter:");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"--",edgOptionList);
- // *******************************************************************
- // Some EDG options have to turn on mechanims in ROSE
- // *******************************************************************
- #if 0
- printf ("Some EDG options have to turn on mechanims in ROSE edgOptionList.size() = %ld \n",edgOptionList.size());
- Rose_STL_Container<string>::iterator j = edgOptionList.begin();
- while (j != edgOptionList.end())
- {
- printf ("edgOptionList: j = %s \n",j->c_str());
- j++;
- }
- #endif
- // *******************************************************************
- // Handle specific edg options (-c)
- // *******************************************************************
- //
- // specify compilation only option (new style command line processing)
- //
- #if 0
- if ( CommandlineProcessing::isOption(argc,argv,"-","c",false) == true )
- {
- printf ("In build_EDG_CommandLine(): Option -c found (compile only)! \n");
- set_compileOnly(true);
- }
- else
- {
- printf ("In build_EDG_CommandLine(): Option -c not found (compile AND link) adding --auto_instantiation ... \n");
- Rose_STL_Container<string> additionalOptions_a;
- Rose_STL_Container<string> additionalOptions_b;
- // Even though this is not an error to EDG, it does not appear to force instantiation of all templates
- additionalOptions_a.push_back("auto_instantiation");
- CommandlineProcessing::addListToCommandLine(numberOfCommandLineArguments,inputCommandLine,"--",additionalOptions_a);
- // DQ (5/12/05): Set the instantiation mode to "used" for specify what sort of templates to instantiate automatically
- // (generate "-tused" instead of "--instantiate used" since EDG does not seems to accept options containing white space).
- additionalOptions_b.push_back("tused");
- CommandlineProcessing::addListToCommandLine(numberOfCommandLineArguments,inputCommandLine, "-",additionalOptions_b);
- }
- #else
- bool autoInstantiation = false;
- if ( CommandlineProcessing::isOption(argv,"-","c",false) == true )
- {
- // printf ("In build_EDG_CommandLine(): Option -c found (compile only)! \n");
- set_compileOnly(true);
- }
- else
- {
- // printf ("In build_EDG_CommandLine(): Option -c not found (compile AND link) set autoInstantiation = true ... \n");
- autoInstantiation = true;
- }
- if (isPrelinkPhase() == true)
- {
- printf ("In build_EDG_CommandLine(): isPrelinkPhase() == true set autoInstantiation = true ... \n");
- autoInstantiation = true;
- }
- // DQ (10/15/2005): Trap out case of C programs where it is an EDG error to specify template instantiation details
- if (get_C_only() == true ||get_C99_only() == true )
- {
- // printf ("In build_EDG_CommandLine(): compiling input as C program so turn off all template instantiation details \n");
- autoInstantiation = false;
- }
- Rose_STL_Container<string> additionalOptions_a;
- Rose_STL_Container<string> additionalOptions_b;
- #if 1
- if (autoInstantiation == true)
- {
- // printf ("In build_EDG_CommandLine(): autoInstantiation = true adding --auto_instantiation -tused ... \n");
- // Even though this is not an error to EDG, it does not appear to force instantiation of all templates (because we need "-tused")
- additionalOptions_a.push_back("auto_instantiation");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"--",additionalOptions_a);
- // DQ (5/12/05): Set the instantiation mode to "used" for specify what sort of templates to instantiate automatically
- // (generate "-tused" instead of "--instantiate used" since EDG does not seems to accept options containing white space).
- additionalOptions_b.push_back("tused");
- CommandlineProcessing::addListToCommandLine(inputCommandLine, "-",additionalOptions_b);
- }
- else
- {
- // There are additional cases where we want to force instantiation of all used templates.
- // DQ (5/20/2005): Force instantiation of all used templated unless it is specified to instantiate no templates (explicitly to ROSE)
- bool instantiateAll = false;
- if (get_project() != NULL)
- {
- instantiateAll = (get_project()->get_template_instantiation_mode() == SgProject::e_default) ||
- (get_project()->get_template_instantiation_mode() == SgProject::e_used) ||
- (get_project()->get_template_instantiation_mode() == SgProject::e_all) ||
- (get_project()->get_template_instantiation_mode() == SgProject::e_local);
- }
- // printf ("get_project()->get_template_instantiation_mode() = %d \n",get_project()->get_template_instantiation_mode());
- // printf ("In build_EDG_CommandLine(): instantiateAll = %s if true then adding --auto_instantiation -tlocal ... \n",
- // instantiateAll ? "true" : "false");
- // DQ (6/1/2005): This is the case of explicitly specifying the complation of C code and
- // not C++ code (EDG reports an error if auto_instantiation is specified for this case).
- if (get_C_only() == true || get_C99_only() == true)
- {
- // printf ("In build_EDG_CommandLine(): compiling input as C program so turn off all template instantiation details \n");
- instantiateAll = false;
- }
- if (instantiateAll == true)
- {
- // printf ("In build_EDG_CommandLine(): autoInstantiation = true adding --auto_instantiation -tlocal ... \n");
- additionalOptions_a.push_back("auto_instantiation");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"--",additionalOptions_a);
- // additionalOptions_b.push_back("tused");
- additionalOptions_b.push_back("tlocal");
- CommandlineProcessing::addListToCommandLine(inputCommandLine, "-",additionalOptions_b);
- }
- }
- #else
- // DQ (5/20/05): Set the instantiation mode to "used" for specify what sort of templates to instantiate automatically
- // (generate "-tused" instead of "--instantiate used" since EDG does not seems to accept options containing white space).
- printf ("In build_EDG_CommandLine(): autoInstantiation = true adding --auto_instantiation -tused ... \n");
-
- // Even though this is not an error to EDG, it does not appear to force instantiation of all templates (because we need "-tused")
- additionalOptions_a.push_back("auto_instantiation");
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"--",additionalOptions_a);
- additionalOptions_b.push_back("tused");
- CommandlineProcessing::addListToCommandLine(inputCommandLine, "-",additionalOptions_b);
- #endif
- #endif
- // printf ("###### Located source filename = %s \n",get_sourceFileNameWithPath().c_str());
- // ROSE_ASSERT ( get_numberOfSourceFileNames() > 0 );
- ROSE_ASSERT ( get_sourceFileNameWithPath().empty() == false);
- //AS Added support for absolute paths
- Rose_STL_Container<string> fileList;
- std::string sourceFile = get_sourceFileNameWithPath();
- std::string sourceFilePath = StringUtility::getPathFromFileName(sourceFile);
- sourceFile = StringUtility::stripPathFromFileName(sourceFile);
- if(sourceFilePath == "" )
- sourceFilePath = "./";
- sourceFilePath = StringUtility::getAbsolutePathFromRelativePath(sourceFilePath);
- fileList.push_back(sourceFilePath+"/"+sourceFile);
-
- CommandlineProcessing::addListToCommandLine(inputCommandLine,"",fileList);
- // AS Add Support for g++ style preincludes
- // CommandlineProcessing::addListToCommandLine(inputCommandLine,"--preinclude ",listOfPreincludes);
- // ROSE_ASSERT (saveSkipfinalCompileStep == p_skipfinalCompileStep);
- // Debugging (verbose) output
- if ( (get_verbose() > 1) )
- {
- std::string argString = CommandlineProcessing::generateStringFromArgList(inputCommandLine,false,false);
- printf ("In build_EDG_CommandLine(): Input Command Line Arguments: \n%s \n",argString.c_str());
- // Alternative way of displaying the commandline parameters
- for (unsigned int i=0; i < inputCommandLine.size(); i++)
- printf ("inputCommandLine[%u] = %s \n",i,inputCommandLine[i].c_str());
- }
- #if 0
- printf ("Exiting at base of build_EDG_CommandLine() \n");
- ROSE_ABORT();
- #endif
- // display("at base of build_EDG_CommandLine()");
- }
- #if 1
- // DQ (2/11/2004): This is still defined in the ROSE/src/command_line_options
- void
- SgFile::usage ( int status )
- {
- if (status != 0)
- fprintf (stderr,"Try option `--help' for more information.\n");
- else
- {
- // it would be nice to insert the version of ROSE being used (using the VERSION macro)
- fputs(
- "\n"
- "This ROSE translator provides a means for operating on C, C++, and Fortran\n"
- "source code, as well as on x86 and ARM object code.\n"
- "\n"
- "Usage: rose [OPTION]... FILENAME...\n"
- "\n"
- "If a long option shows a mandatory argument, it is mandatory for the equivalent\n"
- "short option as well, and similarly for optional arguments.\n"
- "\n"
- "Main operation mode:\n"
- " -rose:(o|output) FILENAME\n"
- " file containing final unparsed C++ code\n"
- "\n"
- "Operation modifiers:\n"
- " -rose:C_only, -rose:C follow C89 standard, disable C++\n"
- " -rose:C99_only, -rose:C99\n"
- " follow C99 standard, disable C++\n"
- " -rose:Fortran, -rose:F, -rose:f\n"
- " compile Fortran code, determining version of\n"
- " Fortran from file suffix)\n"
- " -rose:Fortran77, -rose:F77, -rose:f77\n"
- " compile Fortran 77 code\n"
- " -rose:Fortran90, -rose:F90, -rose:f90\n"
- " compile Fortran 90 code\n"
- " -rose:Fortran95, -rose:F95, -rose:f95\n"
- " compile Fortran 95 code\n"
- " -rose:Fortran2003, -rose:F2003, -rose:f2003\n"
- " compile Fortran 2003 code\n"
- " -rose:strict strict enforcement of ANSI/ISO standards\n"
- " -rose:astMerge merge ASTs from different files\n"
- " -rose:astMergeCommandFile FILE\n"
- " filename where compiler command lines are stored\n"
- " for later processing (using AST merge mechanism)\n"
- " -rose:compilationPerformanceFile FILE\n"
- " filename where compiler performance for internal\n"
- " phases (in CSV form) is placed for later\n"
- " processing (using script/graphPerformance)\n"
- " -rose:skip_rose process command line and call backend directly,\n"
- " skipping all ROSE-specific processing\n"
- " -rose:skip_transformation\n"
- " read input file and skip all transformations\n"
- " -rose:skip_unparse read and process input file but skip generation of\n"
- " final C++ output file\n"
- " -rose:unparse_includes unparse all include files into the source file.\n"
- " This is a backup option for fail-safe processing\n"
- " of CPP directives (which can be tricky)\n"
- " -rose:collectAllCommentsAndDirectives\n"
- " store all comments and CPP directives in header\n"
- " files into the AST\n"
- " -rose:excludeCommentsAndDirectives PATH\n"
- " provide path to exclude when using the\n"
- " collectAllCommentsAndDirectives option\n"
- " -rose:excludeCommentsAndDirectivesFrom FILENAME\n"
- " provide filename to file with paths to exclude\n"
- " when using the collectAllCommentsAndDirectives\n"
- " option\n"
- " -rose:includeCommentsAndDirectives PATH\n"
- " provide path to include when using the\n"
- " collectAllCommentsAndDirectives option\n"
- " -rose:includeCommentsAndDirectivesFrom FILENAME\n"
- " provide filename to file with paths to include\n"
- " when using the collectAllCommentsAndDirectives\n"
- " option\n"
- " -rose:skip_commentsAndDirectives\n"
- " ignore all comments and CPP directives (can\n"
- " generate (unparse) invalid code if not used with\n"
- " -rose:unparse_includes)\n"
- " -rose:skipfinalCompileStep\n"
- " read input file and skip all transformations\n"
- " -rose:prelink activate prelink mechanism to force instantiation\n"
- " of templates and assignment to files\n"
- " -rose:instantiation XXX control template instantiation\n"
- " XXX is one of (none, used, all, local)\n"
- "\n"
- "GNU g++ options recognized:\n"
- " -ansi equivalent to -rose:strict\n"
- " -fno-implicit-templates disable output of template instantiations in\n"
- " generated source\n"
- " -fno-implicit-inline-templates\n"
- " disable output of inlined template instantiations\n"
- " in generated source\n"
- "\n"
- "Informative output:\n"
- " -rose:help, --help, -help, --h\n"
- " print this help, then exit\n"
- " -rose:version, --version, --V\n"
- " print ROSE program version number, then exit\n"
- " -rose:markGeneratedFiles\n"
- " add \"#define ROSE_GENERATED_CODE\" to top of all\n"
- " generated code\n"
- " -rose:verbose [LEVEL] verbosely list internal processing (default=0)\n"
- " Higher values generate more output (can be\n"
- " applied to individual files and to the project\n"
- " separately).\n"
- " -rose:embedColorCodesInGeneratedCode LEVEL\n"
- " embed color codes into generated output for\n"
- " visualization of highlighted text using tview\n"
- " tool for constructs specified by LEVEL\n"
- " LEVEL is one of:\n"
- " 1: missing position information\n"
- " 2: compiler-generated code\n"
- " 3: other code\n"
- " -rose:generateSourcePositionCodes LEVEL\n"
- " generate separate file of source position\n"
- " information for highlighting original source\n"
- " file using tview tool for constructs specified\n"
- " by LEVEL\n"
- " LEVEL is one of:\n"
- " 1: statements, preprocessor directives and\n"
- " comments\n"
- " 2: expressions\n"
- "\n"
- "Control EDG frontend processing:\n"
- " -edg:new_frontend force use of external EDG front end (disables use\n"
- " of rest of ROSE/SAGE)\n"
- " -edg:KCC_frontend for use of KCC (with -c option) as new frontend\n"
- " (must be specified with -edg:new_frontend)\n"
- " -edg:XXX pass -XXX to EDG front-end\n"
- " --edg:XXX pass --XXX to EDG front-end\n"
- " -edg_parameter: XXX YYY pass -XXX YYY to EDG front-end\n"
- " --edg_parameter: XXX YYY pass --XXX YYY to EDG front-end\n"
- "\n"
- "Control code generation:\n"
- " -rose:C_output_language\n"
- " force use of C as output language (currently\n"
- " generates C/C++)\n"
- " -rose:Cxx_output_language\n"
- " force use of C++ as output language\n"
- " -rose:Fortran_output_language\n"
- " force use of Fortran as output language\n"
- " -rose:Promela_output_language\n"
- " force use of Promela as output language (not\n"
- " supported)\n"
- "\n"
- "Testing Options:\n"
- " -rose:negative_test test ROSE using input that is expected to fail\n"
- " (returns 0 if input test failed, else error if\n"
- " passed)\n"
- " -rose:test LEVEL limit parts of ROSE which are run\n"
- " LEVEL is one of:\n"
- " 0: transparent (ROSE translator does nothing)\n"
- " 1: run the KCC front end only (assumes it is in\n"
- " path)\n"
- " 2: run the newer version of EDG (compiled\n"
- " separately from SAGE) 'edgFrontEnd'\n"
- " (see\n"
- " src/frontend/EDG/EDG_3.3/src/Makefile.am\n"
- " for instructions on how to build EDG\n"
- " without SAGE III)\n"
- " 3: run internal (older) version of edg front end\n"
- " (deprecated option)\n"
- " 4: same as 3 plus parse into Sage III program\n"
- " tree\n"
- " 5: same as 4 plus unparse untransformed source\n"
- " code\n"
- " 6: same as 5 plus compile generated source code\n"
- " 7: same as 5 plus build higher level grammars\n"
- " before unparsing\n"
- " 8: same as 6 plus run midend (transformations)\n"
- " before unparsing\n"
- "\n"
- "Report bugs to <dquinlan@llnl.gov>.\n"
- , stdout);
- // Obsolete options
- // -sage:sage_backend have EDG call the sage backend
- // -sage:disable_cp_backend prevent EDG from calling the cp backend
- // -rose:outputGrammarTreeFiles write out program tree representation in C++ grammar (useful for internal debugging)
- // -rose:outputGrammarTreeFilesForHeaderFiles (include header files in above option (must be specified after above option)
- // DQ (5/20/2005): More obsolete options
- // -edg:disable_edg_backend prevent EDG from calling the sage backend
- // -sage:disable_sage_backend prevent EDG from calling the sage backend
- // -sage:enable_cp_backend have EDG call the cp backend
- // -sage:preinit_il do a preinit stage between the front-end and
- }
- #if 1
- // Comment this out for now while we test!
- exit (status);
- #endif
- }
- #endif
- //! get the current directory
- string
- SgFile::getWorkingDirectory ()
- {
- int i = 0; // index variable declaration
- const int maxPathNameLength = 1024;
- char* currentDirectory = new char [maxPathNameLength];
- for (i=0; i < maxPathNameLength; i++)
- currentDirectory[i] = '\0'; // set to NULL string
- char* returnString = getcwd(currentDirectory,maxPathNameLength - 1);
- ROSE_ASSERT (returnString != NULL);
- currentDirectory[maxPathNameLength - 1] = 0; // Just in case
- // The semantics of the getcwd is that these shuld be the same (see if they are)
- // printf ("In ROSE::getWorkingDirectory: Current directory = %s \n",currentDirectory);
- // printf ("In ROSE::getWorkingDirectory: Current directory = %s \n",returnString);
- // live with the possible memory leak for now
- // delete currentDirectory;
- currentDirectory = NULL;
- return returnString;
- }
- //! get the source directory
- string
- SgFile::getSourceDirectory ()
- {
- #if 0
- int i = 0; // index variable declaration
- const int maxPathNameLength = 1024;
- char* currentDirectory = new char [maxPathNameLength];
- for (i=0; i < maxPathNameLength; i++)
- currentDirectory[i] = '\0'; // set to NULL string
- #endif
- printf ("SgFile::getSourceDirectory not implemented! \n");
- ROSE_ABORT();
- return "";
- }
- string
- SgFile::generateOutputFileName() const
- {
- // DQ (10/16/2005): This function abstracts the generation of an
- // output file name from the source file name.
- std::string sourceFileName = get_sourceFileNameWithPath();
- // std::string baseFileName = ROSE::stripPathFromFileName(sourceFileName.c_str());
- std::string baseFileName = StringUtility::stripPathFromFileName(sourceFileName);
- std::string baseFileNameWithoutSuffix = StringUtility::stripFileSuffixFromFileName(baseFileName);
- // printf ("sourceFileName = %s oldFileName = %s\n",sourceFileName.c_str(),baseFileName.c_str());
- std::string objectFileName;
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- #if 0
- printf ("sourceFileName = %s \n",sourceFileName.c_str());
- printf ("baseFileName = %s \n",baseFileName.c_str());
- printf ("baseFileNameWithoutSuffix = %s \n",baseFileNameWithoutSuffix.c_str());
- #endif
- #ifndef USE_ORIGINAL_SOURCE_FILE_NAME_IN_PRELINKING
- // DQ (8/12/2007): I think this was part of the prelinker which is not no longer used!
- // printf ("isPrelinkPhase() = %s \n",isPrelinkPhase() ? "true" : "false");
- ROSE_ASSERT(isPrelinkPhase() == false);
- if (isPrelinkPhase() == true)
- {
- // test for leading "rose_" prefix in name (it should be present)
- ROSE_ASSERT(baseFileName.find("rose_") == 0);
- // and remove it since we want the unmodified file name to be used as a name of the object file!
- baseFileName.erase(0,5);
- // test for leading "rose_" prefix in name (it should NOT be present now)
- ROSE_ASSERT(baseFileName.find("rose_") == std::string::npos);
- }
- #endif
- #if 0
- // DQ (12/5/2006): Make sure that the baseFileName is long enough (fixed small filename test).
- // DQ (12/8/2004): Build the *.o file based on the old name not the new name (what was I thinking!)
- // AS(07/07/04) modified to create .o files for .cpp files also
- // if ( baseFileName.substr(baseFileName.length()-4, baseFileName.length()) == std::string(".cpp") )
- if ( (baseFileName.length() >= 4) && (baseFileName.substr(baseFileName.length()-4, baseFileName.length()) == std::string(".cpp") ) )
- {
- objectFileName = baseFileName.substr(0,baseFileName.length()-4) + std::string(".o");
- }
- else
- {
- // DQ (12/5/2006): Make sure that the baseFileName is long enough (fixed small filename test).
- // DQ (9/10/2004): Added support for ".cc" suffix to handle KOLAH and Kull files
- // if ( baseFileName.substr(baseFileName.length()-3, baseFileName.length()) == std::string(".cc") )
- if ( (baseFileName.length() >= 3) && (baseFileName.substr(baseFileName.length()-3, baseFileName.length()) == std::string(".cc") ) )
- {
- objectFileName = baseFileName.substr(0,baseFileName.length()-3) + std::string(".o");
- }
- else
- {
- // DQ (12/5/2006): Added a lower bound for baseFileName size.
- if (baseFileName.length() >= 2)
- {
- objectFileName = baseFileName.substr(0,baseFileName.length()-2) + std::string(".o");
- }
- else
- {
- printf ("Error: base filename = %s is too short \n",baseFileName.c_str());
- // Maybe we should allow this to a least be defined if we decide later that files names can be allowed to be this short.
- objectFileName = baseFileName;
- }
- ROSE_ASSERT(baseFileName.length() >= 2);
- }
- }
- #else
- // DQ (8/12/2007): Newer simpler code, made possible because of better internal support.
- // This version is also now language independent and so supports the Fortran work.
- objectFileName = baseFileNameWithoutSuffix + ".o";
- #endif
- // printf ("At base of SgFile::generateOutputFileName(): objectFileName = %s \n",objectFileName.c_str());
- // display("In SgFile::generateOutputFileName()");
- return objectFileName;
- }
- string
- SgFile::buildCompilerCommandLineOptions ( vector<string> & argv, int fileNameIndex, const string& compilerName )
- {
- // This function assembles the commandline that will be passed to the backend (vendor) C++/C compiler
- // (using the new generated source code from the ROSE unparser).
- // DQ (4/21/2006): I think we can now assert this!
- ROSE_ASSERT(fileNameIndex == 0);
- // display("Data in SgFile in buildCompilerCommandLineOptions()");
- // To use rose in place of a C or C++ compiler specify the compiler name using
- // rose -compiler <originalCompilerName> ...
- // the default value of "originalCompilerName" is "CC"
- std::string compilerNameString = compilerName;
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- #if 0
- printf ("C compiler = %s \n",BACKEND_C_COMPILER_NAME_WITH_PATH);
- printf ("C++ compiler = %s \n",BACKEND_CXX_COMPILER_NAME_WITH_PATH);
- printf ("get_C_only() = %s \n",(get_C_only() == true) ? "true" : "false");
- printf ("get_C99_only() = %s \n",(get_C99_only() == true) ? "true" : "false");
- printf ("get_Fortran_only() = %s \n",(get_Fortran_only() == true) ? "true" : "false");
- printf ("get_F77_only() = %s \n",(get_F77_only() == true) ? "true" : "false");
- printf ("get_F90_only() = %s \n",(get_F90_only() == true) ? "true" : "false");
- printf ("get_F95_only() = %s \n",(get_F95_only() == true) ? "true" : "false");
- printf ("get_F2003_only() = %s \n",(get_F2003_only() == true) ? "true" : "false");
- #endif
- // DQ (9/10/2006): We now explicitly store the C and C++ compiler names with
- // paths so that we can assemble the final commandline to compile the generated
- // code within ROSE.
- // We need a better way of identifying the C compiler which might not be known
- // ideally it should be specified at configure time so that it can be known in
- // case the -rose:C_only option is used.
- if (get_C_only() == true || get_C99_only() == true)
- {
- // compilerNameString = "gcc ";
- compilerNameString = BACKEND_C_COMPILER_NAME_WITH_PATH;
- }
- else
- {
- compilerNameString = BACKEND_CXX_COMPILER_NAME_WITH_PATH;
- if (get_Fortran_only() == true)
- {
- // compilerNameString = "f77 ";
- compilerNameString = "gfortran ";
- }
- }
- // printf ("compilerName = %s \n",compilerName);
- // printf ("compilerNameString = %s \n",compilerNameString.c_str());
- if (compilerNameString.find("icc") != string::npos)
- {
- // This is the Intel C compiler: icc, we need to add the -restrict option
- compilerNameString += " -restrict";
- }
- if (compilerNameString.find("icpc") != string::npos)
- {
- // This is the Intel C++ compiler: icc, we need to add the -restrict option
- compilerNameString += " -restrict";
- }
- // DQ (9/24/2006): Not clear if we want this, if we just skip stripping it out then it will be passed to the backend directly!
- // But we have to add it in the case of "-rose:strict", so we have to add it uniformally and strip it from the input.
- if (get_strict_language_handling() == true)
- {
- // Check if it is appears as "-ansi" on the original commandline
- if ( CommandlineProcessing::isOption(argv,"-","ansi",false) == true )
- {
- printf ("Option -ansi detected on the original commandline \n");
- }
- else
- {
- // This is might be specific to GNU
- compilerNameString += " -ansi ";
- }
- }
- // printf ("Selected compiler = %s \n",compilerNameString.c_str());
- // Since we need to do this often, support is provided in the utility_functions.C
- // and we can simplify this code.
- std::string currentDirectory = getWorkingDirectory();
- // printf ("In buildCompilerCommandLineOptions(): currentDirectory = %s \n",currentDirectory);
- // specify compilation only option (new style command line processing)
- if ( CommandlineProcessing::isOption(argv,"-","c",false) == true )
- {
- // printf ("Option -c found (compile only)! \n");
- set_compileOnly(true);
- }
- else
- {
- // printf ("Option -c not found (compile AND link) ... \n");
- // compilerNameString += " -c ";
- }
- // DQ (3/31/2004): New cleaned up source file handling
- Rose_STL_Container<string> argcArgvList = argv;
- // DQ (9/25/2007): Moved to std::vector from std::list uniformally within ROSE.
- // Remove the first argument (argv[0])
- // argcArgvList.pop_front();
- argcArgvList.erase(argcArgvList.begin());
- SgProject* project = isSgProject(this->get_parent());
- ROSE_ASSERT (project != NULL);
- Rose_STL_Container<string> sourceFilenames = project->get_sourceFileNameList();
- // printf ("sourceFilenames.size() = %zu sourceFilenames = %s \n",sourceFilenames.size(),StringUtility::listToString(sourceFilenames).c_str());
- // DQ (4/20/2006): Modified to only do this when generating code and compiling it
- // Remove the source names from the argcArgvList (translated versions of these will be inserted later)
- // if (get_skip_unparse() == true && get_skipfinalCompileStep() == false)
- if (get_skip_unparse() == false)
- {
- for (Rose_STL_Container<string>::iterator i = sourceFilenames.begin(); i != sourceFilenames.end(); i++)
- {
- // printf ("Removing sourceFilenames list element i = %s \n",(*i).c_str());
- #if USE_ABSOLUTE_PATHS_IN_SOURCE_FILE_LIST
- #error "USE_ABSOLUTE_PATHS_IN_SOURCE_FILE_LIST is not supported yet"
- // DQ (9/1/2006): Check for use of absolute path and convert filename to absolute path if required
- bool usesAbsolutePath = ((*i)[0] == '/');
- if (usesAbsolutePath == false)
- {
- string targetSourceFileToRemove = StringUtility::getAbsolutePathFromRelativePath(*i);
- // printf ("Converting source file to absolute path to search for it and remove it! targetSourceFileToRemove = %s \n",targetSourceFileToRemove.c_str());
- argcArgvList.remove(targetSourceFileToRemove);
- }
- else
- {
- // printf ("This source file used the absolute path so no conversion to absolute path is required! \n");
- argcArgvList.remove(*i);
- }
- #else
- // DQ (9/25/2007): Moved to std::vector from std::list uniformally within ROSE.
- // printf ("Skipping test for absolute path removing the source filename as it appears in the source file name list file = % \n",i->c_str());
- // argcArgvList.remove(*i);
- argcArgvList.erase(find(argcArgvList.begin(),argcArgvList.end(),*i));
- #endif
- }
- }
- // printf ("After removing source file name: argcArgvList.size() = %zu argcArgvList = %s \n",argcArgvList.size(),StringUtility::listToString(argcArgvList).c_str());
- // ROSE_ASSERT(false);
- // AS(080704) Fix so that if user specifies name of -o file rose do not specify another in addition
- bool objectNameSpecified = false;
- for (Rose_STL_Container<string>::iterator i = argcArgvList.begin(); i != argcArgvList.end(); i++)
- {
- // printf ("In SgFile::buildCompilerCommandLineOptions(): Loop over commandline arguments i = %s \n",i->c_str());
- // DQ (8/17/2006): This fails for directories such as "ROSE/projects/OpenMP_Translator/tests/npb2.3-omp-c"
- // which can be repeated in the specification of include directives on the commandline.
- // We need to check for the leading characters and nothing else.
- // if (i->find("-o") != std::string::npos)
- // if (i->find("-o ") != std::string::npos)
- // printf ("i->substr(0,2) = %s \n",i->substr(0,2).c_str());
- if (i->substr(0,2) == "-o")
- {
- // DQ (6/12/2005): Added error checking!
- if (objectNameSpecified == true)
- {
- // Error: "-o" has been specified twice
- printf ("Error: \"-o \" has been specified twice \n");
- }
- ROSE_ASSERT(objectNameSpecified == false);
- objectNameSpecified = true;
- }
- }
- // DQ (4/14/2005): Fixup quoted strings in args fix "-DTEST_STRING_MACRO="Thu Apr 14 08:18:33 PDT 2005"
- // to be -DTEST_STRING_MACRO=\""Thu Apr 14 08:18:33 PDT 2005"\" This is a problem in the compilation of
- // a Kull file (version.cc), when the backend is specified as /usr/apps/kull/tools/mpig++-3.4.1. The
- // problem is that /usr/apps/kull/tools/mpig++-3.4.1 is a wrapper for a shell script /usr/local/bin/mpiCC
- // which does not tend to observe quotes well. The solution is to add additional escaped quotes.
- for (Rose_STL_Container<string>::iterator i = argcArgvList.begin(); i != argcArgvList.end(); i++)
- {
- #if 0
- printf ("sizeof(std::string::size_type) = %d \n",sizeof(std::string::size_type));
- printf ("sizeof(std::string::iterator) = %d \n",sizeof(std::string::iterator));
- printf ("sizeof(unsigned int) = %d \n",sizeof(unsigned int));
- printf ("sizeof(unsigned long) = %d \n",sizeof(unsigned long));
- #endif
- // DQ (1/26/2006): Fix for 64 bit support.
- // unsigned int startingQuote = i->find("\"");
- std::string::size_type startingQuote = i->find("\"");
- if (startingQuote != std::string::npos)
- {
- // This string at least has a quote
- // unsigned int endingQuote = i->rfind("\"");
- std::string::size_type endingQuote = i->rfind("\"");
- // There should be a double quote on both ends of the string
- ROSE_ASSERT (endingQuote != std::string::npos);
- std::string quotedSubstring = i->substr(startingQuote,endingQuote);
- // printf ("quotedSubstring = %s \n",quotedSubstring.c_str());
- std::string fixedQuotedSubstring = std::string("\\\"") + quotedSubstring + std::string("\\\"");
- // printf ("fixedQuotedSubstring = %s \n",fixedQuotedSubstring.c_str());
- // Now replace the quotedSubstring with the fixedQuotedSubstring
- i->replace(startingQuote,endingQuote,fixedQuotedSubstring);
- // printf ("Modified argument = %s \n",(*i).c_str());
- }
- }
- // Add any options specified by the user (and add space at the end)
- compilerNameString += std::string(" ") + StringUtility::listToString(argcArgvList) + std::string(" ");
- // printf ("buildCompilerCommandLineOptions() #1: compilerNameString = \n%s \n",compilerNameString.c_str());
- std::string sourceFileName = get_sourceFileNameWithPath();
- std::string oldFileNamePathOnly = ROSE::getPathFromFileName(sourceFileName.c_str());
- std::string oldFileName = ROSE::stripPathFromFileName(sourceFileName.c_str());
- #if 0
- printf ("oldFileNamePathOnly = %s \n",oldFileNamePathOnly.c_str());
- printf ("oldFileName = %s \n",oldFileName.c_str());
- #endif
- // DQ (12/8/2004): Add -Ipath option so that source file's directory will be searched for any
- // possible headers. This is especially important when we are compiling the generated file
- // located in a different directory! (When the original source file included header files
- // in the source directory!) This is only important when get_useBackendOnly() == false
- // since otherwise the source file is the original source file and the compiler will search
- // its directory for header files. Be sure the put the oldFile's source directory last in the
- // list of -I options so that it will be searched last (preserving the semantics of #include "...").
- // Only add the path if it is a valid name (not an empty name, in which case skip it since the oldFile
- // is in the current directory (likely a generated file itself; e.g. swig or ROSE applied recursively, etc.)).
- // printf ("oldFileNamePathOnly.length() = %d \n",oldFileNamePathOnly.length());
- if (oldFileNamePathOnly.empty() == false)
- compilerNameString += std::string("-I") + oldFileNamePathOnly + " ";
- // DQ (4/20/2006): This allows the ROSE translator to be just a wrapper for the backend (vendor) compiler.
- // compilerNameString += get_unparse_output_filename();
- if (get_skip_unparse() == false)
- {
- // Generate the name of the ROSE generated source file (instead of the original source file)
- // this file will be compiled by the backend (vendor) compiler.
- ROSE_ASSERT(get_unparse_output_filename().empty() == false);
- compilerNameString += get_unparse_output_filename();
- }
- else
- {
- // In this case the compilerNameString already has the original file name since it was not removed
- // compilerNameString += get_unparse_output_filename();
- // printf ("Case of skip_unparse() == true: original source file name should be present compilerNameString = %s \n",compilerNameString.c_str());
- }
-
- if ( get_compileOnly() == true )
- {
- std::string objectFileName = generateOutputFileName();
- // printf ("In buildCompilerCommandLineOptions: objectNameSpecified = %s objectFileName = %s \n",objectNameSpecified ? "true" : "false",objectFileName.c_str());
- // DQ (7/14/2004): Suggested fix from Andreas
- if (objectNameSpecified == false)
- {
- compilerNameString += " -o " + currentDirectory + "/" + objectFileName;
- }
- }
- // printf ("At base of buildCompilerCommandLineOptions: compilerNameString = \n%s\n",compilerNameString.c_str());
- #if 0
- printf ("Exiting at base of buildCompilerCommandLineOptions() ... \n");
- ROSE_ASSERT (false);
- #endif
- return compilerNameString;
- }
- // Forward declarations of classes used to control and tailor the code generation.
- // class UnparseDelegate;
- // class UnparseFormatHelp;
- // DQ (3/18/2006): Modified interface to allow specification of pointer to user
- // defined UnparseFormatHelp object (to control code generation).
- // DQ (8/20/2005): Removed default parameter from extern function declaration
- // extern void unparseFile( SgFile&, UnparseDelegate* repl = NULL );
- extern void unparseFile( SgFile* file, UnparseFormatHelp *unparseFormatHelp = NULL, UnparseDelegate* unparseDelegate = NULL );
- void
- // SgFile::unparse ()
- SgFile::unparse ( UnparseFormatHelp *unparseFormatHelp, UnparseDelegate* unparseDelegate )
- {
- // DQ (7/12/2005): Introduce tracking of performance of ROSE.
- TimingPerformance timer ("AST Code Generation (unparsing):");
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // printf ("Inside of SgFile::unparse () ROSE_DEBUG = %d \n",ROSE_DEBUG);
- #if 0
- // DQ (4/21/2006): this has been moved to the backen unparseFile function (as late as possible)
- ROSE_ASSERT (get_unparse_output_filename().empty() == true);
- string outputFilename;
- if (get_skip_unparse() == true)
- {
- // We we are skipping the unparsing then we didn't generate an intermediate
- // file and so we want to compile the original source file.
- outputFilename = get_sourceFileNameWithPath();
- }
- else
- {
- // If we did unparse an intermediate file then we want to compile that
- // file instead of the original source file.
- outputFilename = "rose_" + get_sourceFileNameWithoutPath();
- }
- set_unparse_output_filename(outputFilename);
- ROSE_ASSERT (get_unparse_output_filename().empty() == false);
- printf ("Inside of SgFile::unparse(UnparseFormatHelp*,UnparseDelegate*) outputFilename = %s \n",outputFilename.c_str());
- #endif
- // Check that these are set and not reset to null!
- // ROSE_ASSERT (p_commandLineArgumentList != NULL);
- // Call the unparser mechanism
- // unparseFile ( *this );
- unparseFile ( this, unparseFormatHelp, unparseDelegate );
- // Check that these are set and not reset to null!
- // ROSE_ASSERT (p_commandLineArgumentList != NULL);
- }
- int
- SgFile::compileOutput ( vector<string>& argv, int fileNameIndex, const string& compilerNameOrig )
- {
- // DQ (7/12/2005): Introduce tracking of performance of ROSE.
- TimingPerformance timer ("AST Object Code Generation (compile output):");
- // DQ (4/21/2006): I think we can now assert this!
- ROSE_ASSERT(fileNameIndex == 0);
- // This function does the final compilation of the unparsed file
- // Remaining arguments from the original compile time are used as well
- // as additional arguments added by the buildCompilerCommandLineOptions() function
- // DQ NOTE: This function has to be modified to compile more than
- // just one file (as part of the multi-file support)
- // ROSE_ASSERT (sageProject.numberOfFiles() == 1);
- // ******************************************************************************
- // At this point in the control flow (for ROSE) we have returned from the processing
- // via the EDG frontend (or skipped it if that option was specified).
- // The following has been done or explicitly skipped if such options were specified
- // on the commandline:
- // 1) The application program has been parsed
- // 2) All AST's have been build (one for each grammar)
- // 3) The transformations have been edited into the C++ AST
- // 4) The C++ AST has been unparsed to form the final output file (all code has
- // been generated into a different filename)
- // ******************************************************************************
- // What remains is to run the specified compiler (typically the C++ compiler) using
- // the generated output file (unparsed and transformed application code).
- int returnValueForRose = 0;
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // BP : 11/13/2001, checking to see that the compiler name is set
- string compilerName = compilerNameOrig + " ";
- // DQ (4/21/2006): Setup the output file name.
- // Rose_STL_Container<string> fileList = CommandlineProcessing::generateSourceFilenames(argc,argv);
- // ROSE_ASSERT (fileList.size() == 1);
- // p_sourceFileNameWithPath = *(fileList.begin());
- // p_sourceFileNameWithoutPath = ROSE::stripPathFromFileName(p_sourceFileNameWithPath.c_str());
- #if 1
- // ROSE_ASSERT (get_unparse_output_filename().empty() == true);
- // DQ (4/21/2006): If we have not set the unparse_output_filename then we could not have called
- // unparse and we want to compile the original source file as a backup mechanism to generate an
- // object file.
- if (get_unparse_output_filename().empty() == true)
- {
- ROSE_ASSERT(get_skip_unparse() == true);
- string outputFilename = get_sourceFileNameWithPath();
- #if 0
- if (get_skip_unparse() == true)
- {
- // We we are skipping the unparsing then we didn't generate an intermediate
- // file and so we want to compile the original source file.
- outputFilename = get_sourceFileNameWithPath();
- }
- else
- {
- // If we did unparse an intermediate file then we want to compile that
- // file instead of the original source file.
- outputFilename = "rose_" + get_sourceFileNameWithoutPath();
- }
- #endif
- set_unparse_output_filename(outputFilename);
- // DQ (6/25/2006): I think it is OK to not have an output file name specified.
- // display ("In SgFile::compileOutput(): get_unparse_output_filename().empty() == true");
- }
- #endif
- ROSE_ASSERT (get_unparse_output_filename().empty() == false);
- // Now call the compiler that rose is replacing
- // if (get_useBackendOnly() == false)
- if ( SgProject::get_verbose() >= 1 )
- printf ("Now call the backend (vendor's) compiler for file = %s \n",get_unparse_output_filename().c_str());
- // Build the commandline to hand off to the C++/C compiler
- std::string compilerNameString = buildCompilerCommandLineOptions (argv,fileNameIndex, compilerName );
- // ROSE_ASSERT (compilerNameString != NULL);
- int returnValueForCompiler = 0;
- // error checking
- // display("Called from SgFile::compileOutput()");
- // allow conditional skipping of the final compile step for testing ROSE
- if (get_skipfinalCompileStep() == false)
- {
- if ( get_verbose() > 1 )
- printf ("calling system(%s) \n",compilerNameString.c_str());
- returnValueForCompiler = system (compilerNameString.c_str());
- }
- else
- {
- if ( get_verbose() > 1 )
- printf ("COMPILER NOT CALLED: compilerNameString = %s \n",compilerNameString.c_str());
- printf ("Skipped call to backend vendor compiler! \n");
- }
- // DQ (7/20/2006): Catch errors returned from unix "system" function (commonly "out of memory" errors, suggested by Peter and Jeremiah).
- if (returnValueForCompiler < 0)
- {
- perror("Serious Error returned from internal system command");
- }
- // Assemble an exit status that combines the values for ROSE and the C++/C compiler
- // return an exit status which is the boolean OR of the bits from the EDG/SAGE/ROSE and the compile step
- int finalCompiledExitStatus = returnValueForRose | returnValueForCompiler;
- // It is a strange property of the UNIX $status that it does not map uniformally from
- // the return value of the "exit" command (or "return" statement). So if the exit
- // status from the compilation stage is nonzero then we just make the exit status 1
- // (this does seem to be a portable solution).
- // FYI: only the first 8 bits of the exit value are significant (Solaris uses 'exit_value mod 256').
- if (finalCompiledExitStatus != 0)
- {
- // If this it is non-zero then make it 1 to be more clear to external tools (e.g. make)
- finalCompiledExitStatus = 1;
- }
- // DQ (9/19/2006): We need to invert the test result (return code) for
- // negative tests (where failure is expected and success is an error).
- if (get_negative_test() == true)
- {
- if ( get_verbose() > 1 )
- printf ("This is a negative tests, so an error in compilation is a PASS and successful compilation is a FAIL (vendor compiler return value = %d) \n",returnValueForCompiler);
- // printf (" (before) finalCompiledExitStatus = %d \n",finalCompiledExitStatus);
- finalCompiledExitStatus = (finalCompiledExitStatus == 0) ? /* error */ 1 : /* success */ 0;
- // printf (" (after) finalCompiledExitStatus = %d \n",finalCompiledExitStatus);
- }
- // printf ("Program Terminated Normally (exit status = %d)! \n\n\n\n",finalCompiledExitStatus);
- return finalCompiledExitStatus;
- }
- void
- SgFile::display ( const std::string & label ) const
- {
- // This function prints out the member data values within the object
- printf ("\nIn SgFile::display(%s) \n",label.c_str());
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- printf (" p_root is %s pointer \n",(p_root != NULL) ? "VALID" : "NULL");
- ROSE_ASSERT (p_root != NULL);
- // printf ("Output the SgFile::p_file_info object = %p \n",get_file_info());
- // get_file_info()->display("Called from SgFile::display");
- printf ("Output the SgFile::p_startOfConstruct object = %p \n",get_startOfConstruct());
- ROSE_ASSERT (get_startOfConstruct() != NULL);
- get_startOfConstruct()->display("Called from SgFile::display");
- printf (" p_preprocessorDirectivesAndCommentsList is %s pointer \n",(p_preprocessorDirectivesAndCommentsList != NULL) ? "VALID" : "NULL");
- // ROSE_ASSERT (p_preprocessorDirectivesAndCommentsList != NULL);
- // printf (" p_unparse_output_filename = %s \n",(p_unparse_output_filename != NULL) ? p_unparse_output_filename : "NULL POINTER");
- printf (" p_unparse_output_filename = %s \n",p_unparse_output_filename.c_str());
- printf (" p_verbose = %s (value=%d) \n", (p_verbose > 1) ? "true" : "false",p_verbose);
- printf (" p_useBackendOnly = %s \n",(p_useBackendOnly == true) ? "true" : "false");
- printf (" p_skip_transformation = %s \n",(p_skip_transformation == true) ? "true" : "false");
- printf (" p_skip_unparse = %s \n",(p_skip_unparse == true) ? "true" : "false");
- printf (" p_outputGrammarTreeFiles = %s \n",(p_outputGrammarTreeFiles == true) ? "true" : "false");
- printf (" p_outputGrammarTreeFilesForHeaderFiles = %s \n",(p_outputGrammarTreeFilesForHeaderFiles == true) ? "true" : "false");
- printf (" p_unparse_includes = %s \n",(p_unparse_includes == true) ? "true" : "false");
- printf (" p_KCC_frontend = %s \n",(p_KCC_frontend == true) ? "true" : "false");
- printf (" p_new_frontend = %s \n",(p_new_frontend == true) ? "true" : "false");
- printf (" p_skipfinalCompileStep = %s \n",(p_skipfinalCompileStep == true) ? "true" : "false");
- printf (" p_disable_edg_backend = %s \n",(p_disable_edg_backend == true) ? "true" : "false");
- printf (" p_disable_sage_backend = %s \n",(p_disable_sage_backend == true) ? "true" : "false");
- printf (" p_testingLevel = %d \n",p_testingLevel);
- printf (" p_preinit_il = %s \n",(p_preinit_il == true) ? "true" : "false");
- printf (" p_enable_cp_backend = %s \n",(p_enable_cp_backend == true) ? "true" : "false");
- // printf (" p_numberOfSourceFileNames = %d \n",p_numberOfSourceFileNames);
- printf (" p_C_only() = %s \n",(p_C_only == true) ? "true" : "false");
- printf (" p_C99_only() = %s \n",(p_C99_only == true) ? "true" : "false");
- printf (" p_Fortran_only() = %s \n",(p_Fortran_only == true) ? "true" : "false");
- printf (" p_F77_only() = %s \n",(p_F77_only == true) ? "true" : "false");
- printf (" p_F90_only() = %s \n",(p_F90_only == true) ? "true" : "false");
- printf (" p_F95_only() = %s \n",(p_F95_only == true) ? "true" : "false");
- printf (" p_F2003_only() = %s \n",(p_F2003_only == true) ? "true" : "false");
- #if 0
- for (int i = 0; i < p_numberOfSourceFileNames; i++)
- {
- printf (" p_sourceFileNamesWithPath [%d] = %s \n",
- i,(p_sourceFileNamesWithPath[i] != NULL) ? p_sourceFileNamesWithPath[i] : "NULL STRING");
- printf (" p_sourceFileNamesWithoutPath [%d] = %s \n",
- i,(p_sourceFileNamesWithoutPath[i] != NULL) ? p_sourceFileNamesWithoutPath[i] : "NULL STRING");
- }
- #else
- printf (" p_sourceFileNameWithPath = %s \n",p_sourceFileNameWithPath.c_str());
- printf (" p_sourceFileNameWithoutPath = %s \n",p_sourceFileNameWithoutPath.c_str());
- #endif
- // printf (" p_skip_buildHigherLevelGrammars = %s \n",(p_skip_buildHigherLevelGrammars == true) ? "true" : "false");
- printf (" p_outputGrammarTreeFilesForEDG = %s \n",(p_outputGrammarTreeFilesForEDG == true) ? "true" : "false");
- // DQ (1/17/2006): test this
- // ROSE_ASSERT(get_fileInfo() != NULL);
- // printf ("p_ = %s \n",(p_ == true) ? "true" : "false");
- // printf (" is %s pointer \n",( != NULL) ? "VALID" : "NULL");
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 331 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Common.code"
- // *** COMMON CODE SECTION BEGINS HERE ***
- int
- SgFile::getVariant() const
- {
- // This function is used in ROSE while "variant()" is used in SAGE
- assert(this != NULL);
- return variant();
- }
- // This function is used in ROSE in treeTraversal code
- // eventually replaces getVariant() and variant()
- // though after variant() has been removed for a while we will
- // want to change the name of variantT() back to variant()
- // (since the "T" was ment to stand for temporary).
- // When this happens the variantT() will be depricated.
- VariantT
- SgFile::variantT() const {
- return V_SgFile;
- }
- #if 0
- int
- SgFile::variant() const
- {
- // This function is used in SAGE
- assert(this != NULL);
- return FileTag;
- }
- #endif
- const char*
- SgFile::sage_class_name() const
- {
- assert(this != NULL);
- return "SgFile";
- }
- std::string
- SgFile::class_name() const
- {
- assert(this != NULL);
- return "SgFile";
- }
- // DQ (11/26/2005): Support for visitor pattern mechanims
- // (inferior to ROSE traversal mechanism, experimental).
- void
- SgFile::executeVisitorMemberFunction (ROSE_VisitorPattern & visitor)
- {
- ROSE_ASSERT(this != NULL);
- visitor.visit(this);
- }
- // *** COMMON CODE SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1387 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Node.code"
- #if 0
- //! Error checking support
- /*! Verifies the following:
- - working getVariant() member function
- - calls base class's error() member function
- Every class has one of these functions.
- */
- bool
- SgFile::error()
- {
- // Put error checking here
- ROSE_ASSERT (this != NULL);
- if (getVariant() != FileTag)
- {
- printf ("Error in SgFile::error(): SgFile object has a %s variant \n",
- Cxx_GrammarTerminalNames[getVariant()].name);
- // printf ("Error in SgFile::error() \n");
- ROSE_ABORT();
- }
- ROSE_ASSERT (getVariant() == FileTag);
- return SgSupport::error();
- }
- #endif
- // End of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarVariantFunctionDefinitionMacros.macro"
- int
- SgFile::variant() const
- {
- // This function is generated from grammarVariantFunctionDefinitionMacros.macro
- #ifdef DEBUG
- // printf ("In SgFile::variant() const \n");
- #endif
- assert(this != NULL);
- return FileTag;
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarIsClassNameFunctionDefinitionMacros.macro"
- SgFile* isSgFile ( SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<SgFile*>(inputDerivedClassPointer);
- }
- // DQ (11/8/2003): Added version of functions taking const pointer
- const SgFile* isSgFile ( const SgNode* inputDerivedClassPointer )
- {
- return dynamic_cast<const SgFile*>(inputDerivedClassPointer);
- }
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- /**
- \brief Generated destructor
- This destructor is automatically generated (by ROSETTA). This destructor
- only frees memory of data members associated with the parts of the current IR node which
- are NOT traversed. Those data members that are part of a traversal can be freed using
- a traversal (calling this destructor on all children in a post-order traversal). Such
- a traversal which deletes a whole AST is provided by DeleteSgTree(SgNode*).
- \internal All IR nodes with data members specified using setDataPrototype() within ROSETTA
- are specified as NO_DELETE is also specified as DEF_TRAVERSAL. Those marked as
- NO_TRAVERSAL can be marked as NO_DELETE or DEF_DELETE.
- \note All SgSymbol IR nodes are deleted when the symbol table is deleted. Currently most
- SgType IR nodes are not deleted (since they are shared). Also, all STL lists of
- pointers are not yet implemented to call delete on eash pointer in the container.
- (This could be done by derivation from the STL containers to define containers that
- automatically deleted their members.)
- */
- SgFile::~SgFile ()
- {
- #if 0
- // debugging information!
- printf ("In SgFile::~SgFile (destructor) \n");
- #endif
- #if 1
- // DQ (6/25/2006): Commented out destructor body to allow the File I/O to work.
-
- delete p_startOfConstruct;
- delete p_preprocessorDirectivesAndCommentsList;
- // case: not a listType for startOfConstruct
- p_startOfConstruct = NULL; // non list case
- // case: not a listType for root
- p_root = NULL; // non list case
- // case: not a listType for verbose
- p_verbose = 0; // non list case
- // case: not a listType for C_only
- p_C_only = false; // non list case
- // case: not a listType for C99_only
- p_C99_only = false; // non list case
- // case: not a listType for Fortran_only
- p_Fortran_only = false; // non list case
- // case: not a listType for F77_only
- p_F77_only = false; // non list case
- // case: not a listType for F90_only
- p_F90_only = false; // non list case
- // case: not a listType for F95_only
- p_F95_only = false; // non list case
- // case: not a listType for F2003_only
- p_F2003_only = false; // non list case
- // case: not a listType for fixedFormat
- p_fixedFormat = false; // non list case
- // case: not a listType for freeFormat
- p_freeFormat = false; // non list case
- // case: not a listType for outputFormat
- p_outputFormat = SgFile::e_unknown_output_format; // non list case
- // case: not a listType for fortran_implicit_none
- p_fortran_implicit_none = false; // non list case
- // case: not a listType for fortran_openmp
- p_fortran_openmp = false; // non list case
- // case: not a listType for skip_transformation
- p_skip_transformation = false; // non list case
- // case: not a listType for skip_unparse
- p_skip_unparse = false; // non list case
- // case: not a listType for unparse_includes
- p_unparse_includes = false; // non list case
- // case: not a listType for skipfinalCompileStep
- p_skipfinalCompileStep = false; // non list case
- // case: not a listType for outputLanguage
- p_outputLanguage = SgFile::e_default_output_language; // non list case
- // case: not a listType for sourceFileNameWithPath
- p_sourceFileNameWithPath = ""; // non list case
- // case: not a listType for sourceFileNameWithoutPath
- p_sourceFileNameWithoutPath = ""; // non list case
- // case: not a listType for unparse_output_filename
- p_unparse_output_filename = ""; // non list case
- // case: not a listType for useBackendOnly
- p_useBackendOnly = false; // non list case
- // case: not a listType for compileOnly
- p_compileOnly = false; // non list case
- // case: not a listType for savedFrontendCommandLine
- p_savedFrontendCommandLine = ""; // non list case
- // case: not a listType for no_implicit_templates
- p_no_implicit_templates = false; // non list case
- // case: not a listType for no_implicit_inline_templates
- p_no_implicit_inline_templates = false; // non list case
- // case: not a listType for skip_commentsAndDirectives
- p_skip_commentsAndDirectives = false; // non list case
- // case: not a listType for collectAllCommentsAndDirectives
- p_collectAllCommentsAndDirectives = false; // non list case
- // case: not a listType for preprocessorDirectivesAndCommentsList
- p_preprocessorDirectivesAndCommentsList = NULL; // non list case
- // case: not a listType for attributeMechanism
- p_attributeMechanism = NULL; // non list case
- // case: not a listType for KCC_frontend
- p_KCC_frontend = false; // non list case
- // case: not a listType for new_frontend
- p_new_frontend = false; // non list case
- // case: not a listType for travTraceToDOT
- p_travTraceToDOT = false; // non list case
- // case: not a listType for disable_edg_backend
- p_disable_edg_backend = false; // non list case
- // case: not a listType for disable_sage_backend
- p_disable_sage_backend = false; // non list case
- // case: not a listType for testingLevel
- p_testingLevel = -1; // non list case
- // case: not a listType for preinit_il
- p_preinit_il = false; // non list case
- // case: not a listType for enable_cp_backend
- p_enable_cp_backend = false; // non list case
- // case: not a listType for outputGrammarTreeFiles
- p_outputGrammarTreeFiles = false; // non list case
- // case: not a listType for outputGrammarTreeFilesForHeaderFiles
- p_outputGrammarTreeFilesForHeaderFiles = false; // non list case
- // case: not a listType for outputGrammarTreeFilesForEDG
- p_outputGrammarTreeFilesForEDG = false; // non list case
- // case: not a listType for markGeneratedFiles
- p_markGeneratedFiles = false; // non list case
- // case: not a listType for negative_test
- p_negative_test = false; // non list case
- // case: not a listType for strict_language_handling
- p_strict_language_handling = false; // non list case
- // case: not a listType for embedColorCodesInGeneratedCode
- p_embedColorCodesInGeneratedCode = 0; // non list case
- // case: not a listType for generateSourcePositionCodes
- p_generateSourcePositionCodes = 0; // non list case
- // case: not a listType for sourceFileUsesCppFileExtension
- p_sourceFileUsesCppFileExtension = false; // non list case
- // case: not a listType for sourceFileUsesFortranFileExtension
- p_sourceFileUsesFortranFileExtension = false; // non list case
- // case: not a listType for sourceFileUsesFortran77FileExtension
- p_sourceFileUsesFortran77FileExtension = false; // non list case
- // case: not a listType for sourceFileUsesFortran90FileExtension
- p_sourceFileUsesFortran90FileExtension = false; // non list case
- // case: not a listType for sourceFileUsesFortran95FileExtension
- p_sourceFileUsesFortran95FileExtension = false; // non list case
- // case: not a listType for sourceFileUsesFortran2003FileExtension
- p_sourceFileUsesFortran2003FileExtension = false; // non list case
- // case: not a listType for binaryFile
- p_binaryFile = NULL; // non list case
- #line 32 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarDestructorDefinitionMacros.macro"
- #endif
- }
- #line 1 ""
- #line 1 ""
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro after marker MEMBER_FUNCTION_DEFINITIONS"
- #line 7 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions common across all array grammar objects
- // ********************************************************
- #line 1 ""
- #line 1 ""
- #line 1 ""
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/grammarClassDefinitionMacros.macro"
- // ********************************************************
- // member functions specific to each node in the grammar
- // ********************************************************
- #line 6 "../Grammar/grammarClassDefinitionMacros.macro before marker MEMBER_FUNCTION_DEFINITIONS"
- #line 1 ""
- #line 1 ""
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgFilePtrListPtr
- SgProject::get_fileList () const
- {
- assert (this != NULL);
- return p_fileList;
- }
- void
- SgProject::set_fileList ( SgFilePtrListPtr fileList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_fileList = fileList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_originalCommandLineArgumentList () const
- {
- assert (this != NULL);
- return p_originalCommandLineArgumentList;
- }
- void
- SgProject::set_originalCommandLineArgumentList ( SgStringList originalCommandLineArgumentList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_originalCommandLineArgumentList = originalCommandLineArgumentList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgProject::get_frontendErrorCode () const
- {
- assert (this != NULL);
- return p_frontendErrorCode;
- }
- void
- SgProject::set_frontendErrorCode ( int frontendErrorCode )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_frontendErrorCode = frontendErrorCode;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- int
- SgProject::get_backendErrorCode () const
- {
- assert (this != NULL);
- return p_backendErrorCode;
- }
- void
- SgProject::set_backendErrorCode ( int backendErrorCode )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_backendErrorCode = backendErrorCode;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgProject::get_outputFileName () const
- {
- assert (this != NULL);
- return p_outputFileName;
- }
- void
- SgProject::set_outputFileName ( std::string outputFileName )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_outputFileName = outputFileName;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_sourceFileNameList () const
- {
- assert (this != NULL);
- return p_sourceFileNameList;
- }
- void
- SgProject::set_sourceFileNameList ( SgStringList sourceFileNameList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_sourceFileNameList = sourceFileNameList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_objectFileNameList () const
- {
- assert (this != NULL);
- return p_objectFileNameList;
- }
- void
- SgProject::set_objectFileNameList ( SgStringList objectFileNameList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_objectFileNameList = objectFileNameList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_libraryFileList () const
- {
- assert (this != NULL);
- return p_libraryFileList;
- }
- void
- SgProject::set_libraryFileList ( SgStringList libraryFileList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_libraryFileList = libraryFileList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_librarySpecifierList () const
- {
- assert (this != NULL);
- return p_librarySpecifierList;
- }
- void
- SgProject::set_librarySpecifierList ( SgStringList librarySpecifierList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_librarySpecifierList = librarySpecifierList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_libraryDirectorySpecifierList () const
- {
- assert (this != NULL);
- return p_libraryDirectorySpecifierList;
- }
- void
- SgProject::set_libraryDirectorySpecifierList ( SgStringList libraryDirectorySpecifierList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_libraryDirectorySpecifierList = libraryDirectorySpecifierList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgStringList
- SgProject::get_includeDirectorySpecifierList () const
- {
- assert (this != NULL);
- return p_includeDirectorySpecifierList;
- }
- void
- SgProject::set_includeDirectorySpecifierList ( SgStringList includeDirectorySpecifierList )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_includeDirectorySpecifierList = includeDirectorySpecifierList;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgProject::get_compileOnly () const
- {
- assert (this != NULL);
- return p_compileOnly;
- }
- void
- SgProject::set_compileOnly ( bool compileOnly )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_compileOnly = compileOnly;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgProject::get_prelink () const
- {
- assert (this != NULL);
- return p_prelink;
- }
- void
- SgProject::set_prelink ( bool prelink )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_prelink = prelink;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- SgProject::template_instantiation_enum
- SgProject::get_template_instantiation_mode () const
- {
- assert (this != NULL);
- return p_template_instantiation_mode;
- }
- void
- SgProject::set_template_instantiation_mode ( SgProject::template_instantiation_enum template_instantiation_mode )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_template_instantiation_mode = template_instantiation_mode;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgProject::get_astMerge () const
- {
- assert (this != NULL);
- return p_astMerge;
- }
- void
- SgProject::set_astMerge ( bool astMerge )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_astMerge = astMerge;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgProject::get_astMergeCommandFile () const
- {
- assert (this != NULL);
- return p_astMergeCommandFile;
- }
- void
- SgProject::set_astMergeCommandFile ( std::string astMergeCommandFile )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_astMergeCommandFile = astMergeCommandFile;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- bool
- SgProject::get_C_PreprocessorOnly () const
- {
- assert (this != NULL);
- return p_C_PreprocessorOnly;
- }
- void
- SgProject::set_C_PreprocessorOnly ( bool C_PreprocessorOnly )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_C_PreprocessorOnly = C_PreprocessorOnly;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- AstAttributeMechanism*
- SgProject::get_attributeMechanism () const
- {
- assert (this != NULL);
- return p_attributeMechanism;
- }
- void
- SgProject::set_attributeMechanism ( AstAttributeMechanism* attributeMechanism )
- {
- assert (this != NULL);
- set_isModified(true);
-
- #if DEBUG_SAGE_ACCESS_FUNCTIONS
- if (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism)
- {
- printf ("Warning: attributeMechanism = %p overwriting valid pointer p_attributeMechanism = %p \n",attributeMechanism,p_attributeMechanism);
- #if DEBUG_SAGE_ACCESS_FUNCTIONS_ASSERTION
- printf ("Error fails assertion (p_attributeMechanism != NULL && attributeMechanism != NULL && p_attributeMechanism != attributeMechanism) is false\n");
- ROSE_ASSERT(false);
- #endif
- }
- #endif
- p_attributeMechanism = attributeMechanism;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 836 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- #if 0
- // DQ (4/10/2006): Removed in favor of implementation at SgNode using
- // a pointer and the interface represented directly at the SgNode
- AstAttributeMechanism &
- SgProject::attribute()
- {
- // DQ (1/2/2006): This function preserves as much of
- // the syntax of attribute being a public data member.
- if (p_attribute == NULL)
- {
- printf ("Error: p_attribute == NULL (node = %s) \n",class_name().c_str());
- ROSE_ASSERT(false);
- }
- return *p_attribute;
- }
- #endif
- void
- SgProject::addNewAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->add(s,a);
- }
- void
- SgProject::setAttribute( std::string s, AstAttribute* a )
- {
- if (get_attributeMechanism() == NULL)
- {
- set_attributeMechanism( new AstAttributeMechanism() );
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- }
- get_attributeMechanism()->set(s,a);
- }
- AstAttribute*
- SgProject::getAttribute(std::string s) const
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- AstAttribute* returnValue = get_attributeMechanism()->operator[](s);
- ROSE_ASSERT(returnValue != NULL);
- return returnValue;
- }
- void
- SgProject::updateAttribute( std::string s, AstAttribute* a )
- {
- // formerly called: replace
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->replace(s,a);
- }
- void
- SgProject::removeAttribute(std::string s)
- {
- ROSE_ASSERT(get_attributeMechanism() != NULL);
- get_attributeMechanism()->remove(s);
- // DQ (1/2/2006): If we have no more attributes then remove the attribute container
- int remainingCount = numberOfAttributes();
- // printf ("In AstTextAttributesHandling::visit(): remaining number of attributes = %d \n",remainingCount);
- if (remainingCount == 0)
- {
- delete get_attributeMechanism();
- set_attributeMechanism(NULL);
- }
- }
- bool
- SgProject::attributeExists(std::string s) const
- {
- bool returnValue = false;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->exists(s);
- return returnValue;
- }
- int
- SgProject::numberOfAttributes() const
- {
- int returnValue = 0;
- if (get_attributeMechanism() != NULL)
- returnValue = get_attributeMechanism()->size();
- return returnValue;
- }
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 1 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/dataMemberAccessFunctions.macro"
- // *** DATA ACCESS FUNCTION SECTION BEGINS HERE ***
- std::string
- SgProject::get_compilationPerformanceFile () const
- {
- assert (this != NULL);
- return p_compilationPerformanceFile;
- }
- void
- SgProject::set_compilationPerformanceFile ( std::string compilationPerformanceFile )
- {
- assert (this != NULL);
- set_isModified(true);
-
- p_compilationPerformanceFile = compilationPerformanceFile;
- }
- // *** DATA ACCESS FUNCTION SECTION ENDS HERE ***
- // End of memberFunctionString
- // Start of memberFunctionString
- #line 12529 "/home/dquinlan/ROSE/NEW_ROSE/src/ROSETTA/Grammar/Support.code"
- //! Declaration of space for static variables
- //static int SgProject::p_defaultNumberOfCommandLineArguments = 0;
- //static char** SgProject::p_defaultCommandLineArgumentList = NULL;
- //! (static data) global concept of verbose level which controls useful output from the compiler
- int SgProject::p_verbose = 0;
- //! this can constructor can be used but parse(int argc, char** argv) needs to be called
- SgProject::SgProject()
- {
- initialization();
- }
- SgProject::SgProject( const SgProject & project )
- {
- // This copy constructor is not supported, it is implemented with to return an error message!
- initialization();
- // What is the point of this code!
- // p_numberOfCommandLineArguments(project.p_numberOfCommandLineArguments),
- // p_commandLineArgumentList(project.p_commandLineArgumentList),
- // p_defaultNumberOfCommandLineArguments(project.p_defaultNumberOfCommandLineArguments),
- // p_defaultCommandLineArgumentList(project.p_defaultCommandLineArgumentList),
- // Build the empty STL lists
- p_fileList = new SgFilePtrList();
- ROSE_ASSERT (p_fileList != NULL);
- // print error message and quit
- printf ("ERROR: this SgProject copy constructor is not supposed to be used \n");
- printf (" use SgProject ( int & argc, char** & argv , int & errorCode ) OR copy member function instead \n");
- ROSE_ABORT();
- }
- //! constructor invokes EDG front end and creates AST. Use frontend() instead.
- SgProject::SgProject ( int argc, char** argv)
- {
- initialization();
- std::vector<std::string> argvList(argv, argv + argc);
- int errorCode = parse(argvList);
- set_frontendErrorCode(errorCode);
- }
- //! constructor invokes EDG front end and creates AST. Use frontend() instead.
- SgProject::SgProject ( const std::vector<std::string>& argv )
- {
- initialization();
- int errorCode = parse(argv);
- set_frontendErrorCode(errorCode);
- }
- #if 0
- // DQ (10/16/2005): Depreicated a long time ago, removed it now!
- //! Deprecated, do not use.
- SgProject::SgProject ( int& argc, char** argv, int& refErrorCode)
- {
- printf ("This SgProject constructor is deprecated, do not use. \n");
- initialization();
- int errorCode;
- errorCode = parse(argc,argv);
- set_frontendErrorCode(errorCode);
- refErrorCode = errorCode;
- }
- #endif
- void
- SgProject::initialization()
- {
- // DQ (10/16/2005): This function initializes default values (until we use an automatically generated version)
- p_fileList = NULL;
- // p_numberOfCommandLineArguments = 0;
- // p_commandLineArgumentList = NULL;
- // p_defaultNumberOfCommandLineArguments = 0;
- // p_defaultCommandLineArgumentList = NULL;
- p_frontendErrorCode = 0;
- p_backendErrorCode = 0;
- p_outputFileName = "";
- p_compileOnly = false;
- p_prelink = false;
- p_template_instantiation_mode = e_unknown;
- p_astMerge = false;
- p_astMergeCommandFile = "";
- p_compilationPerformanceFile = "";
- p_C_PreprocessorOnly = false;
- // DQ (5/2/2006): Added initialization to prevent valgrind warning.
- p_attributeMechanism = NULL;
- }
- // DQ (2/1/2007): Added new operator so that w could depricate the inconsistant usage of
- // SgFile& in get_file() member function. The get_file() member function is now depricated.
- SgFile*
- SgProject::operator[]( unsigned int i )
- {
- ROSE_ASSERT(i < get_fileList()->size());
- // Since we use an STL vector internally we can use the vector::operator[] directly.
- return p_fileList->operator[](i);
- }
- //! internal function to invoke the EDG frontend and generate the AST
- int
- SgProject::parse(const vector<string>& argv)
- {
- // Not sure that if we are just linking that we should call a function called "parse()"!!!
- // DQ (7/6/2005): Introduce tracking of performance of ROSE.
- TimingPerformance timer ("AST (SgProject::parse(argc,argv)):");
- // builds file list (or none if this is a link line)
- processCommandLine(argv);
- #if 0
- std::string outputFileName = get_outputFileName();
- int outputFilenameLength = outputFileName.length();
- if (outputFilenameLength <= 2)
- {
- printf ("Warning in SgProject::parse(): abnormally short output filename = %s \n",outputFileName.c_str());
- }
- ROSE_ASSERT (outputFilenameLength > 2);
- // DQ (9/30/2006): This is a better way to get the suffix, but I don't think we really need this code here!
- // std::string suffix = outputFileName.substr(outputFilenameLength-2,2);
- std::string suffix;
- size_t suffix_separator_location = filename.rfind('.');
- if (suffix_separator_location == string::npos)
- {
- printf ("In SgProject::parse(): No suffix identified \n");
- }
- else
- {
- suffix = filename.substr(suffix_separator_location);
- printf ("In SgProject::parse(): Suffix = %s \n",suffix.c_str());
- }
- #endif
- int errorCode = 0;
- // DQ (7/7/2005): Added support for AST Merge Mechanism
- if (p_astMerge == true)
- {
- // If astMerge is specified, then the command file is accessed to execute all
- // the commands from each of the associated working directories. Each new AST
- // in merged with the previous AST.
- if (p_astMergeCommandFile != "")
- {
- // If using astMerge mechanism we have to save the command line and
- // working directories to a separate file. This permits a makefile to
- // call a ROSE translator repeatedly and the command line for each
- // file be saved.
- errorCode = AstMergeSupport(this);
- }
- else
- {
- // DQ (5/26/2007): This case could make sense, if there were more than
- // one file on the command line (or if we wanted to force a single file
- // to share as much as possible in a merge with itself, there is a
- // typical 20% reduction in memory useage for this case since the
- // types are then better shared than is possible during initial construction
- // of the AST).
- #if 0
- // error case
- printf ("astMerge requires specification of a command file \n");
- ROSE_ASSERT(false);
- errorCode = -1;
- #endif
- errorCode = AstMergeSupport(this);
- }
- }
- else
- {
- // DQ (7/7/2005): Specification of the AST merge command filename triggers accumulation
- // of working directories and commandlines into the specified file (no other processing
- // is done, the AST (beyond the SgProject) is not built).
- if (p_astMergeCommandFile != "")
- {
- // If using astMerge mechanism we have to save the command line and
- // working directories to a separate file.
- // DQ (5/26/2007): This might be a problem where object files are required to be built
- // and so we might have to call the backend compiler as a way of forcing the correct
- // object files to be built so that, for example, libraries can be constructed when
- // operating across multiple directories.
- errorCode = buildAstMergeCommandFile(this);
- }
- else
- {
- // Normal case without AST Merge: Compiling ...
- if (get_sourceFileNameList().size() > 0)
- {
- // This is a compile line
- // printf ("Compiling project: outputFileName = %s \n",outputFileName.c_str());
- errorCode = parse();
- }
- // DQ (5/26/2007): This is meaningless, so remove it!
- // errorCode = errorCode;
- }
- }
- return errorCode;
- }
- void
- SgProject::processCommandLine(const vector<string>& input_argv)
- {
- // This functions only copies the command line and extracts information from the
- // command line which is useful at the SgProject level (other information useful
- // at the SgFile level is not extracted).
- // Specifically:
- // 1) --help is processed (along with -help, to be friendly)
- // 2) -o <filename> is processed (since both the compilation and the linking
- // phases must know the output file name and it makes sense to process that once).
- // 3) Lists of files and libraries are processed (sense they too are required in
- // both comilation and linking). (e.g. -l<libname>, -L <directory>, <libname>.a,
- // <filename>.C, <filename>.c, -I<directory name>, <filename>.h
- // NOTE: there is no side-effect to argc and argv. Thus the original ROSE translator can
- // see all options. Any ROSE or EDG specific options can be striped by calling the
- // appropriate functions to strip them out.
- // This function now makes an internal copy of the command line parameters to
- // allow the originals to remain unmodified (SLA modifies the command line).
- // printf ("Inside of SgProject::processCommandLine() \n");
- // local copies of argc and argv variables
- // The purpose of building local copies is to avoid
- // the modification of the command line by SLA (to save the original command line)
- vector<string> local_commandLineArgumentList = input_argv;
- // Save a deep copy fo the original command line input the the translator
- // pass in out copies of the argc and argv to make clear that we don't modify argc and argv
- set_originalCommandLineArgumentList( local_commandLineArgumentList );
- // printf ("DONE with copy of command line in SgProject constructor! \n");
- // Build the empty STL lists
- p_fileList = new SgFilePtrList();
- ROSE_ASSERT (p_fileList != NULL);
- // return value for calls to SLA
- int optionCount = 0;
- //
- // help option (allows alternative -h or -help instead of just -rose:help)
- //
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- // optionCount = sla(&argc, argv, "-", "($)", "(h|help)",1);
- optionCount = sla_none(local_commandLineArgumentList, "-", "($)", "(h|help)",1);
- if( optionCount > 0 )
- {
- // printf ("option -help found \n");
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- // ROSE::usage(0);
- SgFile::usage(0);
- exit(0);
- }
- // printf ("After SgProject processing -help option argc = %d \n",argc);
- //
- // help option (allows alternative --h or --help)
- //
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- // optionCount = sla(&argc, argv, "--", "($)", "(h|help)",1);
- optionCount = sla_none(local_commandLineArgumentList, "--", "($)", "(h|help)",1);
- if( optionCount > 0 )
- {
- // printf ("option --help found \n");
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- // ROSE::usage(0);
- SgFile::usage(0);
- exit(0);
- }
- //
- // version option (allows alternative --version or --V)
- //
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- // optionCount = sla(&argc, argv, "--", "($)", "(V|version)",1);
- optionCount = sla_none(local_commandLineArgumentList, "--", "($)", "(V|version)",1);
- if ( optionCount > 0 )
- {
- // printf ("SgProject::processCommandLine(): option --version found \n");
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- exit(0);
- }
- // Use 1 at end of argument list to SLA to force removal of option from argv and decrement of agrc
- // optionCount = sla(&argc, argv, "--", "($)", "(V|version)",1);
- optionCount = sla_none(local_commandLineArgumentList, "-rose:", "($)", "(V|version)",1);
- if ( optionCount > 0 )
- {
- // printf ("SgProject::processCommandLine(): option --version found \n");
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- exit(0);
- }
- #if 0
- // DQ (8/6/2006): Not sure that I want this here!
- //
- // version option (using -rose:version)
- //
- if ( CommandlineProcessing::isOption(argc,argv,"-rose:","(V|version)",true) == true )
- {
- // function in SAGE III to access version number of EDG
- extern std::string edgVersionString();
- printf ("\nROSE (pre-release alpha version: %s) \n",VERSION);
- printf (" Using C++ and C frontend from EDG (version %s) internally \n",edgVersionString().c_str());
-