Skip to content

Commit

Permalink
Merge pull request #454 from nasa/issue-453-qualified-names
Browse files Browse the repository at this point in the history
Fix bug in handling of qualified names
  • Loading branch information
bocchino authored Jun 25, 2024
2 parents 718c5ec + d5539e9 commit 41c344a
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 114 deletions.
2 changes: 1 addition & 1 deletion compiler/lib/src/main/scala/analysis/Semantics/Name.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Name {
}

/** Convert a qualified name to an identifier list */
def toIdentList: List[Unqualified] = (base :: qualifier).reverse
def toIdentList: List[Unqualified] = qualifier :+ base

/** Computes a short qualified name
* Deletes the longest prefix provided by the enclosing scope */
Expand Down
116 changes: 59 additions & 57 deletions compiler/tools/fpp-to-cpp/test/top/NestedNamespacesTopologyAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,82 @@

#include "NestedNamespacesTopologyAc.hpp"

namespace A {
namespace M {

namespace B {

// ----------------------------------------------------------------------
// Component instances
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------
N::O::C c(FW_OPTIONAL_NAME("c"));

void initComponents(const TopologyState& state) {
// Nothing to do
}
// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------

void configComponents(const TopologyState& state) {
// Nothing to do
}

void setBaseIds() {
// Nothing to do
}
void initComponents(const TopologyState& state) {
c.init(InstanceIds::c);
}

void connectComponents() {
// Nothing to do
}
void configComponents(const TopologyState& state) {
// Nothing to do
}

void regCommands() {
// Nothing to do
}
void setBaseIds() {
c.setIdBase(BaseIds::c);
}

void readParameters() {
// Nothing to do
}
void connectComponents() {
// Nothing to do
}

void loadParameters() {
// Nothing to do
}
void regCommands() {
// Nothing to do
}

void startTasks(const TopologyState& state) {
// Nothing to do
}
void readParameters() {
// Nothing to do
}

void stopTasks(const TopologyState& state) {
// Nothing to do
}
void loadParameters() {
// Nothing to do
}

void freeThreads(const TopologyState& state) {
// Nothing to do
}
void startTasks(const TopologyState& state) {
// Nothing to do
}

void tearDownComponents(const TopologyState& state) {
// Nothing to do
}
void stopTasks(const TopologyState& state) {
// Nothing to do
}

// ----------------------------------------------------------------------
// Setup and teardown functions
// ----------------------------------------------------------------------
void freeThreads(const TopologyState& state) {
// Nothing to do
}

void setup(const TopologyState& state) {
initComponents(state);
configComponents(state);
setBaseIds();
connectComponents();
regCommands();
readParameters();
loadParameters();
startTasks(state);
}
void tearDownComponents(const TopologyState& state) {
// Nothing to do
}

void teardown(const TopologyState& state) {
stopTasks(state);
freeThreads(state);
tearDownComponents(state);
}
// ----------------------------------------------------------------------
// Setup and teardown functions
// ----------------------------------------------------------------------

void setup(const TopologyState& state) {
initComponents(state);
configComponents(state);
setBaseIds();
connectComponents();
regCommands();
readParameters();
loadParameters();
startTasks(state);
}

void teardown(const TopologyState& state) {
stopTasks(state);
freeThreads(state);
tearDownComponents(state);
}

}
126 changes: 73 additions & 53 deletions compiler/tools/fpp-to-cpp/test/top/NestedNamespacesTopologyAc.ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,99 @@
// \brief hpp file for NestedNamespaces topology
// ======================================================================

#ifndef A_B_NestedNamespacesTopologyAc_HPP
#define A_B_NestedNamespacesTopologyAc_HPP
#ifndef M_NestedNamespacesTopologyAc_HPP
#define M_NestedNamespacesTopologyAc_HPP

#include "C.hpp"
#include "NestedNamespacesTopologyDefs.hpp"

namespace A {
namespace M {

namespace B {
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------
namespace BaseIds {
enum {
c = 0x100,
};
}

//! Initialize components
void initComponents(
const TopologyState& state //!< The topology state
);
namespace InstanceIds {
enum {
c,
};
}

//! Configure components
void configComponents(
const TopologyState& state //!< The topology state
);
// ----------------------------------------------------------------------
// Component instances
// ----------------------------------------------------------------------

//! Set component base Ids
void setBaseIds();
//! c
extern N::O::C c;

//! Connect components
void connectComponents();
// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------

//! Register commands
void regCommands();
//! Initialize components
void initComponents(
const TopologyState& state //!< The topology state
);

//! Read parameters
void readParameters();
//! Configure components
void configComponents(
const TopologyState& state //!< The topology state
);

//! Load parameters
void loadParameters();
//! Set component base Ids
void setBaseIds();

//! Start tasks
void startTasks(
const TopologyState& state //!< The topology state
);
//! Connect components
void connectComponents();

//! Stop tasks
void stopTasks(
const TopologyState& state //!< The topology state
);
//! Register commands
void regCommands();

//! Free threads
void freeThreads(
const TopologyState& state //!< The topology state
);
//! Read parameters
void readParameters();

//! Tear down components
void tearDownComponents(
const TopologyState& state //!< The topology state
);
//! Load parameters
void loadParameters();

// ----------------------------------------------------------------------
// Setup and teardown functions
// ----------------------------------------------------------------------
//! Start tasks
void startTasks(
const TopologyState& state //!< The topology state
);

//! Set up the topology
void setup(
const TopologyState& state //!< The topology state
);
//! Stop tasks
void stopTasks(
const TopologyState& state //!< The topology state
);

//! Tear down the topology
void teardown(
const TopologyState& state //!< The topology state
);
//! Free threads
void freeThreads(
const TopologyState& state //!< The topology state
);

}
//! Tear down components
void tearDownComponents(
const TopologyState& state //!< The topology state
);

// ----------------------------------------------------------------------
// Setup and teardown functions
// ----------------------------------------------------------------------

//! Set up the topology
void setup(
const TopologyState& state //!< The topology state
);

//! Tear down the topology
void teardown(
const TopologyState& state //!< The topology state
);

}

Expand Down
22 changes: 19 additions & 3 deletions compiler/tools/fpp-to-cpp/test/top/nested_namespaces.fpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
module A {
module M {

module B {
module N {

topology NestedNamespaces {
module O {

passive component C {

}

}

}

}

instance c: M.N.O.C base id 0x100

module M {

topology NestedNamespaces {

instance c

}

}

0 comments on commit 41c344a

Please sign in to comment.