Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ trait UseAnalyzer extends TypeExpressionAnalyzer {
case direct : Ast.SpecConnectionGraph.Direct => visitList(a, direct.connections, connection)
case pattern : Ast.SpecConnectionGraph.Pattern => for {
a <- qualIdentNode (componentInstanceUse) (a, pattern.source)
a <- visitList(a, pattern.targets, qualIdentNode (componentInstanceUse) _)
a <- visitList(a, pattern.targets, qualIdentNode(componentInstanceUse))
} yield a
}
}
Expand Down
22 changes: 4 additions & 18 deletions compiler/lib/src/main/scala/codegen/CppWriter/AliasCppWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,16 @@ case class AliasCppWriter (
return linesMember(List())
}

val systemHHeaders = List(
"FpConfig.h"
).map(CppWriter.systemHeaderString).map(line)

val standardHeaders = List(
"Fw/Types/BasicTypes.h",
).map(CppWriter.headerString)

val symbolHeaders = writeHIncludeDirectives(s, aNode)
val headers = (standardHeaders ++ symbolHeaders).distinct.sorted.map(line)
linesMember(List.concat(
addBlankPrefix(systemHHeaders),
addBlankPrefix(headers)
))
linesMember(addBlankPrefix(headers))
}

private def getHppIncludes: CppDoc.Member.Lines = {
val systemHppHeaders = List(
"FpConfig.hpp"
).map(CppWriter.systemHeaderString).map(line)

val standardHeaders = List(
aliasType.aliasType match {
case Type.String(_) => "Fw/Types/String.hpp"
Expand All @@ -149,10 +138,7 @@ case class AliasCppWriter (
).map(CppWriter.headerString)
val symbolHeaders = writeHppIncludeDirectives(s, aNode)
val headers = standardHeaders ++ symbolHeaders
linesMember(List.concat(
addBlankPrefix(systemHppHeaders),
addBlankPrefix(headers.distinct.sorted.map(line))
))
linesMember(addBlankPrefix(headers.distinct.sorted.map(line)))
}

private def getHppDefinition: CppDoc.Member.Lines = {
Expand Down Expand Up @@ -182,7 +168,7 @@ case class AliasCppWriter (
ty match {
case Type.Float(f) => aliasType.aliasType.toString().toLowerCase()
case Type.PrimitiveInt(i) => aliasType.aliasType.toString().toLowerCase()
case _ => typeCppWriter.write(ty)
case _ => "_" + typeCppWriter.write(ty)
}
}

Expand All @@ -191,7 +177,7 @@ case class AliasCppWriter (
linesMember(addBlankPrefix(
AnnotationCppWriter.writePreComment(aNode) ++ lines(
s"""|typedef ${typeCppWriter.write(aliasType.aliasType)} $name;
|#define PRI_$name PRI_${fmtSpec}""")
|#define PRI_$name PRI${fmtSpec}""")
))
}
}
37 changes: 2 additions & 35 deletions compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fpp.compiler.codegen
import fpp.compiler.analysis._
import fpp.compiler.ast._
import fpp.compiler.util._
import fpp.compiler.codegen.CppWriterState.builtInTypes

/** C++ Writer state */
case class CppWriterState(
Expand Down Expand Up @@ -137,8 +136,7 @@ case class CppWriterState(
val name = getName(sym)
for {
fileName <- sym match {
case _: Symbol.AbsType =>
if isBuiltInType(name) then None else Some(name)
case _: Symbol.AbsType => Some(name)
case _: Symbol.AliasType => Some(
ComputeCppFiles.FileNames.getAliasType(name)
)
Expand Down Expand Up @@ -172,9 +170,6 @@ case class CppWriterState(
usedSymbols.map(getIncludeFiles).filter(_.isDefined).map(_.get).map(CppWriterState.headerString).toList
}

/** Is t a built-in type? */
def isBuiltInType(typeName: String): Boolean = builtInTypes.contains(typeName)

def isTypeSupportedInC(t: Type): Boolean = {
t match {
case Type.AliasType(node, aliasType) =>
Expand All @@ -184,20 +179,14 @@ case class CppWriterState(
// Make sure all types in the alias chain meet the C requirements
case None => isTypeSupportedInC(aliasType)
}
case Type.AbsType(node) => isBuiltInType(getName(Symbol.AbsType(node)))
case Type.PrimitiveInt(_) => true
case Type.Float(_) => true
case _ => false
}
}

/** Is t a primitive type (not serializable)? */
def isPrimitive(t: Type, typeName: String): Boolean = (
isBuiltInType(typeName) ||
t.getUnderlyingType.isPrimitive ||
// See if this an alias of a builtin type
isBuiltInType(t.getUnderlyingType.toString())
)
def isPrimitive(t: Type, typeName: String): Boolean = t.getUnderlyingType.isPrimitive

/** Is t a string type? */
def isStringType(t: Type) = t.getUnderlyingType match {
Expand All @@ -212,28 +201,6 @@ object CppWriterState {
/** The default default string size */
val defaultDefaultStringSize = 80

/** A mapping from special built-in types to their
* default values */
val zero: Value.Integer = Value.Integer(0)
val builtInTypes: Map[String,Value.Integer] = Map(
"FwChanIdType" -> zero,
"FwDpIdType" -> zero,
"FwDpPriorityType" -> zero,
"FwEnumStoreType" -> zero,
"FwEventIdType" -> zero,
"FwIndexType" -> zero,
"FwOpcodeType" -> zero,
"FwPacketDescriptorType" -> zero,
"FwPrmIdType" -> zero,
"FwSignedSizeType" -> zero,
"FwSizeStoreType" -> zero,
"FwSizeType" -> zero,
"FwTimeBaseStoreType" -> zero,
"FwTimeContextStoreType" -> zero,
"FwTlmPacketizeIdType" -> zero,
"FwTraceIdType" -> zero,
)

/** Construct a header string */
def headerString(s: String): String = {
val q = "\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ object ValueCppWriter {

override def absType(s: CppWriterState, v: Value.AbsType) = {
val aNode = v.t.node
val cppName = s.writeSymbol(Symbol.AbsType(aNode))
CppWriterState.builtInTypes.get(cppName) match {
case Some(v) => write(s, v)
case None => TypeCppWriter.getName(s, v.getType) ++ "()"
}
TypeCppWriter.getName(s, v.getType) ++ "()"
}

override def array(s: CppWriterState, v: Value.Array) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ case class XmlWriterState(
tagFileName <- sym match {
case Symbol.AbsType(aNode) =>
val symbol = Symbol.AbsType(aNode)
// Don't import headers for built-in types
val cppName = writeSymbol(symbol)
if (CppWriterState.builtInTypes.contains(cppName)) None
else {
val name = getName(symbol)
Some("include_header", s"${name}.hpp")
}
val name = getName(symbol)
Some("include_header", s"${name}.hpp")
case Symbol.Array(aNode) => Some(
"import_array_type",
XmlWriterState.getArrayFileName(getName(Symbol.Array(aNode)))
Expand Down
11 changes: 10 additions & 1 deletion compiler/scripts/fprime-gcc
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ case "$os" in
;;
esac

g++ --std=c++11 $flags $os_flags -DTGT_OS_TYPE_$os_type -I $FPRIME -I $FPRIME/config -I $FPRIME/cmake/platform/types -I . $FPRIME_GCC_FLAGS $@
g++ --std=c++11 \
$flags \
$os_flags \
-DTGT_OS_TYPE_$os_type \
-I $FPRIME \
-I $FPRIME/config \
-I $FPRIME/cmake/platform/types \
-I . \
$FPRIME_GCC_FLAGS \
$@
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
1 change: 1 addition & 0 deletions compiler/tools/fpp-filenames/test/include.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-filenames/test/ok.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ state machine SM2 {
state S
}

type FwOpcodeType
type FwOpcodeType = U32
type WithCDefinition = U32
type WithCDefinitionBuiltin = FwOpcodeType
type WithoutCDefinition = A
Expand Down
1 change: 1 addition & 0 deletions compiler/tools/fpp-filenames/test/ok.ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EEnumAc.hpp
EEnumAi.xml
FppConstantsAc.cpp
FppConstantsAc.hpp
FwOpcodeTypeAliasAc.hpp
PPortAc.cpp
PPortAc.hpp
PPortAi.xml
Expand Down
2 changes: 0 additions & 2 deletions compiler/tools/fpp-to-cpp/test/alias/AbsTypeAliasAc.ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#ifndef AbsTypeAliasAc_HPP
#define AbsTypeAliasAc_HPP

#include <FpConfig.hpp>

#include "Fw/Types/BasicTypes.h"
#include "T.hpp"

Expand Down
18 changes: 0 additions & 18 deletions compiler/tools/fpp-to-cpp/test/alias/BuiltInTypeAliasAc.ref.h

This file was deleted.

18 changes: 0 additions & 18 deletions compiler/tools/fpp-to-cpp/test/alias/BuiltInTypeAliasAc.ref.hpp

This file was deleted.

Loading