Skip to content

Commit

Permalink
(Rosebud) Stub for eventual Jovial nodes
Browse files Browse the repository at this point in the history
RPM-395
  • Loading branch information
matzke1 committed Apr 21, 2023
1 parent 27b8a45 commit 78ad282
Show file tree
Hide file tree
Showing 19 changed files with 176 additions and 21 deletions.
1 change: 1 addition & 0 deletions config/support-rose.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,7 @@ src/Rose/Makefile
src/Rosebud/Makefile
src/generated/Makefile
src/generated/BinaryAnalysis/Makefile
src/generated/Jovial/Makefile
src/ROSETTA/Makefile
src/ROSETTA/src/Makefile
src/backend/Makefile
Expand Down
4 changes: 4 additions & 0 deletions src/AstNodes/Jovial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This directory contains definitions for ROSE IR and AST nodes related
to Jovial analysis.

See the README.md in the parent directory for more details.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ set(rose_LIB_OBJS
RoseAST
RoseCodeGen
roseGeneratedBinaryAnalysis
roseGeneratedJovial
mstl)

set(rose_LIB_SRCS
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ libroseLibraries = \
$(top_builddir)/src/3rdPartyLibraries/MSTL/libmstl.la \
$(top_builddir)/src/backend/libbackend.la \
$(top_builddir)/src/frontend/SageIII/libsage3.la \
$(top_builddir)/src/generated/libroseGeneratedBinaryAnalysis.la \
$(top_builddir)/src/generated/BinaryAnalysis/libroseGeneratedBinaryAnalysis.la \
$(top_builddir)/src/generated/Jovial/libroseGeneratedJovial.la \
$(libroseCxxlibraries) \
$(libroseOpenFortranParserlibraries) \
$(libroseExperimentalFlangParserlibraries) \
Expand Down
2 changes: 1 addition & 1 deletion src/ROSETTA/astNodeList
Original file line number Diff line number Diff line change
Expand Up @@ -1035,4 +1035,4 @@ SgAsmCilStandAloneSigTable
SgAsmCilTypeDefTable
SgAsmCilTypeRefTable
SgAsmCilTypeSpecTable
SgJvmComposite
SgJvmComposite
3 changes: 2 additions & 1 deletion src/ROSETTA/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ set(CxxGrammarMetaProgram_SRCS
buildStorageClasses.C
buildConstructorsWithoutSourcePositionInformation.C
outputClassesAndFields.C
StringUtility.C)
StringUtility.C
jovialNodes.C)

# input files to generate source files
set(GRAMMAR_SOURCE_FILES
Expand Down
3 changes: 2 additions & 1 deletion src/ROSETTA/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ CxxGrammarMetaProgram_SOURCES = \
buildConstructorsWithoutSourcePositionInformation.C \
outputClassesAndFields.C \
java/terminals.cpp \
StringUtility.C
StringUtility.C \
jovialNodes.C

# buildConstructorsWithoutSourcePositionInformation.o: buildConstructorsWithoutSourcePositionInformation.C

Expand Down
3 changes: 2 additions & 1 deletion src/ROSETTA/src/Tupfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ include_rules
CxxGrammarMetaProgram_SOURCES = CxxGrammarMetaProgram.C grammar.C GrammarFile.C grammarGenerator.C grammarString.C \
AstNodeClass.C type.C symbol.C expression.C statement.C support.C binaryInstruction.C storageSize.C visitorSupport.C \
poolBasedTraversal.C node.C buildAstFileIO.C buildRoseTraits.C buildStorageClasses.C buildConstructorsWithoutSourcePositionInformation.C \
outputClassesAndFields.C java/terminals.cpp nodeIdSupport.C
outputClassesAndFields.C java/terminals.cpp nodeIdSupport.C \
jovialNodes.C

CxxGrammarMetaProgram_LIBS = \
$(ROSE)/src/Rose/StringUtility/libRoseStringUtility \
Expand Down
1 change: 1 addition & 0 deletions src/ROSETTA/src/grammar.C
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Grammar::Grammar ( const string& inputGrammarName,
ROSE_ASSERT (this->astNodeToVariantMap.size() >= 10); // A reasonable count

// Build up the terminals and nonTerminals defined within the default C++ grammar (using SAGE)
setUpJovialNodes();
setUpSupport();
setUpTypes();
setUpStatements();
Expand Down
1 change: 1 addition & 0 deletions src/ROSETTA/src/grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ class Grammar
AstNodeClass & terminalConstructor ( const std::string& lexeme, Grammar & X, const std::string& stringVar = "", const std::string& tagString = "" );

// These functions build the C++ grammar
void setUpJovialNodes();
void setUpTypes ();
void setUpSymbols ();
void setUpExpressions ();
Expand Down
69 changes: 69 additions & 0 deletions src/ROSETTA/src/jovialNodes.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// THIS FILE IS MACHINE GENERATED -- DO NOT MODIFY
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This file was generated with ROSE's "rosebud" tool by reading node definitions written in a
// C++-like language and emitting this ROSETTA input.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE MANUALLY!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#include <featureTests.h>
#include "ROSETTA_macros.h"
#include "grammar.h"
#include "AstNodeClass.h"

//#undef DOCUMENTATION -- commented out so IDEs can't figure it out
#ifdef DOCUMENTATION
DOCUMENTATION_should_never_be_defined;
#endif

#ifdef DOCUMENTATION
#define DECLARE_LEAF_CLASS(CLASS_WITHOUT_Sg) /*void*/
#else
#define DECLARE_LEAF_CLASS(CLASS_WITHOUT_Sg) \
NEW_TERMINAL_MACRO(CLASS_WITHOUT_Sg, #CLASS_WITHOUT_Sg, #CLASS_WITHOUT_Sg "Tag"); \
CLASS_WITHOUT_Sg.setCppCondition("!defined(DOCUMENTATION)");\
CLASS_WITHOUT_Sg.setAutomaticGenerationOfConstructor(false);\
CLASS_WITHOUT_Sg.setAutomaticGenerationOfDestructor(false)
#endif

#ifdef DOCUMENTATION
#define DECLARE_HEADERS(CLASS_WITHOUT_Sg) /*void*/
#else
#define DECLARE_HEADERS(CLASS_WITHOUT_Sg) \
CLASS_WITHOUT_Sg.setPredeclarationString("Sg" #CLASS_WITHOUT_Sg "_HEADERS", \
ROSE_AUTOMAKE_ABSOLUTE_PATH_TOP_SRCDIR + "/src/ROSETTA/src/jovialNodes.C")
#endif

#ifdef DOCUMENTATION
#define DECLARE_OTHERS(CLASS_WITHOUT_Sg) /*void*/
#else
#define DECLARE_OTHERS(CLASS_WITHOUT_Sg) \
CLASS_WITHOUT_Sg.setFunctionPrototype("Sg" #CLASS_WITHOUT_Sg "_OTHERS", \
ROSE_AUTOMAKE_ABSOLUTE_PATH_TOP_SRCDIR + "/src/ROSETTA/src/jovialNodes.C")
#endif

#ifdef DOCUMENTATION
#define IS_SERIALIZABLE() /*void*/
#else
#define IS_SERIALIZABLE(CLASS_WITHOUT_Sg) \
CLASS_WITHOUT_Sg.isBoostSerializable(true)
#endif


// Since ROSETTA builds classes from the leaves up to the base, and C++ builds classes from the
// base down to the leaves, we need to make sure that doxygen sees the base classes before the derived classes. So
// just list all the non-leaf classes here.
#ifdef DOCUMENTATION
#endif // DOCUMENTATION

#ifndef DOCUMENTATION
void Grammar::setUpJovialNodes() {
#endif // !DOCUMENTATION

#ifndef DOCUMENTATION
} // Grammar::setUpBinaryInstruction
#endif // !DOCUMENTATION
36 changes: 30 additions & 6 deletions src/Rosebud/RosettaGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,15 @@ RosettaGenerator::genTupFile(const std::vector<std::string> &implFileNames) {
<<"include_rules\n"
<<"run $(librose_compile)";

for (const std::string &fileName: implFileNames)
out <<" \\\n " <<fileName;
if (implFileNames.empty()) {
// Create at least one stub file, otherwise some problems might arise building the intermediate library.
std::ofstream stub((implDirectoryName / "stub.C").c_str());
stub <<THIS_LOCATION <<"static void stub() {}\n";
out <<" \\\n stub.C";
} else {
for (const std::string &fileName: implFileNames)
out <<" \\\n " <<fileName;
}

out <<"\n";
}
Expand Down Expand Up @@ -733,8 +740,16 @@ RosettaGenerator::genMakeFile(const std::vector<std::string> &implFileNames) {
<<"noinst_LTLIBRARIES = " <<libraryName <<".la\n"
<<libraryName <<"_la_SOURCES =";

for (const std::string &fileName: implFileNames)
out <<" \\\n " <<fileName;
if (implFileNames.empty()) {
// Create at least one stub file, otherwise some problems might arise building the intermediate library.
std::ofstream stub((implDirectoryName / "stub.C").c_str());
stub <<THIS_LOCATION <<"static void stub() {}\n";
out <<" \\\n stub.C";
} else {
for (const std::string &fileName: implFileNames)
out <<" \\\n " <<fileName;
}

out <<"\n";
}
}
Expand All @@ -757,8 +772,17 @@ RosettaGenerator::genCmakeFile(const std::vector<std::string> &implFileNames) {
<<"#\n"
<<"\n"
<<"add_library(roseGenerated OBJECT";
for (const std::string &fileName: implFileNames)
out <<"\n " <<fileName;

if (implFileNames.empty()) {
// Create at least one stub file, otherwise some problems might arise building the intermediate library.
std::ofstream stub((implDirectoryName / "stub.C").c_str());
stub <<THIS_LOCATION <<"static void stub() {}\n";
out <<"\n stub.C";
} else {
for (const std::string &fileName: implFileNames)
out <<"\n " <<fileName;
}

out <<")\n"
<<"\n"
<<"add_dependencies(" <<libraryName <<" rosetta_generated)\n";
Expand Down
30 changes: 21 additions & 9 deletions src/Rosebud/generate
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,24 @@ fi
[ -f "$RG_SRC/src/Rosebud/rosebud.C" ] ||
die "cannot find top of ROSE source tree at \"$RG_SRC\""

exec "$ROSEBUD_EXE" --backend=rosetta --no-warnings --no-locations \
--rosetta-output="$RG_SRC/src/ROSETTA/src/binaryInstruction.C" \
--rosetta-function="Grammar::setUpBinaryInstructions" \
--rosetta-impl="$RG_SRC/src/generated/BinaryAnalysis" \
--rosetta-cpp-protection='defined(ROSE_ENABLE_BINARY_ANALYSIS)' \
--rosetta-node-list="$RG_SRC/src/ROSETTA/astNodeList" \
--rosetta-strict-parents \
"$@" \
"$RG_SRC"/src/AstNodes/BinaryAnalysis/*.h
"$ROSEBUD_EXE" --no-warnings --no-locations \
--backend=rosetta --serializer=boost \
--rosetta-output="$RG_SRC/src/ROSETTA/src/binaryInstruction.C" \
--rosetta-function="Grammar::setUpBinaryInstructions" \
--rosetta-impl="$RG_SRC/src/generated/BinaryAnalysis" \
--rosetta-cpp-protection='defined(ROSE_ENABLE_BINARY_ANALYSIS)' \
--rosetta-node-list="$RG_SRC/src/ROSETTA/astNodeList" \
--rosetta-strict-parents \
"$@" \
"$RG_SRC"/src/AstNodes/BinaryAnalysis/*.h

"$ROSEBUD_EXE" --warnings --no-locations \
--backend=rosetta --serializer=none \
--rosetta-output="$RG_SRC/src/ROSETTA/src/jovialNodes.C" \
--rosetta-function="Grammar::setUpJovialNodes" \
--rosetta-impl="$RG_SRC/src/generated/Jovial" \
--rosetta-cpp-protection='' \
--rosetta-node-list="$RG_SRC/src/ROSETTA/astNodeList" \
--rosetta-strict-parents \
"$@" \
"$RG_SRC"/src/AstNodes/Jovial/*.h
1 change: 1 addition & 0 deletions src/generated/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(BinaryAnalysis)
add_subdirectory(Jovial)
11 changes: 11 additions & 0 deletions src/generated/Jovial/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##################################################################################################################################
# THIS FILE IS MACHINE GENERATED -- DO NOT MODIFY
##################################################################################################################################
#
# This file was generated by Rosebud
#

add_library(roseGenerated OBJECT
stub.C)

add_dependencies(roseGeneratedJovial rosetta_generated)
13 changes: 13 additions & 0 deletions src/generated/Jovial/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##################################################################################################################################
# THIS FILE IS MACHINE GENERATED -- DO NOT MODIFY
##################################################################################################################################
#
# This file was generated by Rosebud
#

include $(top_srcdir)/config/Makefile.for.ROSE.includes.and.libs

AM_CPPFLAGS = $(ROSE_INCLUDES)
noinst_LTLIBRARIES = libroseGeneratedJovial.la
libroseGeneratedJovial_la_SOURCES = \
stub.C
10 changes: 10 additions & 0 deletions src/generated/Jovial/Tupfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##################################################################################################################################
# THIS FILE IS MACHINE GENERATED -- DO NOT MODIFY
##################################################################################################################################
#
# This file was generated by Rosebud
#

include_rules
run $(librose_compile) \
stub.C
1 change: 1 addition & 0 deletions src/generated/Jovial/stub.C
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static void stub() {}
4 changes: 3 additions & 1 deletion src/generated/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include $(top_srcdir)/config/Makefile.for.ROSE.includes.and.libs
SUBDIRS = BinaryAnalysis
SUBDIRS = \
BinaryAnalysis \
Jovial

0 comments on commit 78ad282

Please sign in to comment.