Skip to content

Commit

Permalink
Merge branch 'scala3-migration2' into scala-3-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
bocchino committed May 23, 2022
2 parents e7e2ead + 1afc928 commit 4243726
Show file tree
Hide file tree
Showing 46 changed files with 949 additions and 543 deletions.
7 changes: 5 additions & 2 deletions compiler/install
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fi

wd=`dirname $0`
cd $wd
top=`pwd`
meta=$top/lib/src/main/resources/META-INF/native-image

dir=`dirname $dest`
dir=`cd $dir; pwd`
Expand Down Expand Up @@ -67,7 +69,8 @@ do
echo " $jar"
cp $jar $dest/$tool.jar
echo '#!/bin/sh
java -jar '$dest'/'$tool'.jar "$@"' > $dest/$tool
# See https://www.graalvm.org/22.1/reference-manual/native-image/Agent/
#java -agentlib:native-image-agent=config-merge-dir='$meta' -jar '$dest'/'$tool'.jar "$@"' > $dest/$tool
java -jar "`dirname $0`/'$tool'.jar" "$@"' > $dest/$tool
chmod +x $dest/$tool
done
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
[
{
"name":"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"fpp.compiler.analysis.ComponentInstance[]"
},
{
"name":"fpp.compiler.analysis.Connection[]"
},
{
"name":"fpp.compiler.analysis.Format$Parser$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
},
{
"name":"fpp.compiler.codegen.CppDocCppWriter$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
},
{
"name":"fpp.compiler.codegen.CppDocHppWriter$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
},
{
"name":"fpp.compiler.codegen.Line[]"
},
{
"name":"fpp.compiler.syntax.Lexer$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
Expand All @@ -14,6 +39,9 @@
{
"name":"java.lang.ClassValue"
},
{
"name":"java.lang.String[]"
},
{
"name":"java.lang.invoke.VarHandle",
"methods":[{"name":"releaseFence","parameterTypes":[] }]
Expand All @@ -26,6 +54,14 @@
"name":"scala.util.parsing.input.OffsetPosition$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
},
{
"name":"scala.xml.XML$",
"fields":[{"name":"0bitmap$2", "allowUnsafeAccess":true}]
},
{
"name":"scala.xml.parsing.FactoryAdapter",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
},
{
"name":"scopt.OParser$",
"fields":[{"name":"0bitmap$1", "allowUnsafeAccess":true}]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resources":{
"includes":[]},
"bundles":[]
"bundles":[{"name":"com.sun.org.apache.xerces.internal.impl.msg.XMLMessages"}]
}
1 change: 1 addition & 0 deletions compiler/lib/src/main/scala/ast/Ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ object Ast {
name: Ident,
component: AstNode[QualIdent],
baseId: AstNode[Expr],
implType: Option[AstNode[String]],
file: Option[AstNode[String]],
queueSize: Option[AstNode[Expr]],
stackSize: Option[AstNode[Expr]],
Expand Down
1 change: 1 addition & 0 deletions compiler/lib/src/main/scala/codegen/AstWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ object AstWriter extends AstVisitor with LineUtils {
ident(data.name),
addPrefix("component", qualIdent) (data.component.data),
addPrefix("base id", exprNode) (data.baseId),
linesOpt(addPrefix("type", applyToData(string)), data.implType),
linesOpt(applyToData(fileString), data.file),
linesOpt(addPrefix("queue size", exprNode), data.queueSize),
linesOpt(addPrefix("stack size", exprNode), data.stackSize),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,47 @@ case class TopComponentInstances(
aNode: Ast.Annotated[AstNode[Ast.DefTopology]]
) extends TopologyCppWriterUtils(s, aNode) {

def getLines: List[Line] = {
addBannerComment(
"Component instances",
getComponentInstanceLines
)
private val bannerComment = "Component instances"

def getHppLines: List[Line] = addBannerComment(
bannerComment,
getDeclLines
)

def getCppLines: List[Line] = addBannerComment(
bannerComment,
getDefLines
)

private def getDeclLines = {
def getCode(ci: ComponentInstance): List[Line] = {
val implType = getImplType(ci)
val instanceName = getNameAsIdent(ci.qualifiedName)
Line.addPrefixLine (line(s"//! $instanceName")) (
lines(
s"extern $implType $instanceName;"
)
)
}
flattenWithBlankPrefix(instances.map(getCode))
}

private def getComponentInstanceLines: List[Line] = {
private def getDefLines = {
def getCode(ci: ComponentInstance): List[Line] = {
val componentName = getComponentNameAsQualIdent(ci)
val implType = getImplType(ci)
val instanceName = getNameAsIdent(ci.qualifiedName)
Line.addPrefixLine (line(s"// $instanceName")) (
getCodeLinesForPhase (CppWriter.Phases.instances) (ci).getOrElse(
lines(
s"$componentName $instanceName(FW_OPTIONAL_NAME($q$instanceName$q));"
)
getCodeLinesForPhase (CppWriter.Phases.instances) (ci).getOrElse(
lines(
s"$implType $instanceName(FW_OPTIONAL_NAME($q$instanceName$q));"
)
)
}
flattenWithBlankPrefix(instances.map(getCode))
}

private def getImplType(ci: ComponentInstance) = {
val implType = ci.aNode._2.data.implType.map(_.data)
implType.getOrElse(getComponentNameAsQualIdent(ci))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ case class TopConfigObjects(
}
val (map, maxNum) = mapAndMaxNum
wrapInScope(
"Svc::HealthImpl::PingEntry pingEntries[] = {",
"Svc::Health::PingEntry pingEntries[] = {",
// Loop over all ports in the range 0..maxNum.
// Entries are positional, so we must generate code
// for any unconnected entries in this range.
Expand Down
Loading

0 comments on commit 4243726

Please sign in to comment.