Skip to content

Commit

Permalink
Merge branch 'main' into feature/automated-graph-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA authored Jan 30, 2024
2 parents 07a2e2e + 3dd242a commit 3f61e22
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class MultiValueEvaluator : ValueEvaluator() {
(forStatement.initializerStatement as? DeclarationStatement)?.singleDeclaration

return initializerDecl == node || // The node is the declaration of the loop variable
forStatement.initializerStatement == node || // The node is the initialization
forStatement.initializerStatement == node || // The node is the initialization
(initializerDecl != null &&
initializerDecl ==
node.astParent) || // The parent of the node is the initializer of the loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ private constructor(
inline fun <
reified OldPass : Pass<*>,
reified For : Language<*>,
reified With : Pass<*>> replacePass(): Builder {
reified With : Pass<*>
> replacePass(): Builder {
return replacePass(OldPass::class, For::class, With::class)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ private constructor(
file.language
?.frontend
?.findAnnotation<SupportsParallelParsing>()
?.supported
?: true
?.supported ?: true
// By default, the frontends support parallel parsing. But the
// SupportsParallelParsing annotation can be set to false and force
// to disable it.
Expand Down Expand Up @@ -351,7 +350,7 @@ private constructor(
}
return null
}
component.translationUnits.add(frontend.parse(sourceLocation))
component.addTranslationUnit(frontend.parse(sourceLocation))
} catch (ex: TranslationException) {
log.error("An error occurred during parsing of ${sourceLocation.name}: ${ex.message}")
if (config.failOnError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TranslationResult(
components.add(swc)
}
}
tu?.let { swc.translationUnits.add(it) }
tu?.let { swc.addTranslationUnit(it) }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ val Collection<Type>.commonType: Type?
// only look at its type. Therefore, ancestors with the same type but
// different depths will match here.
it == ancestor
}
?: return@mapNotNull null
} ?: return@mapNotNull null

// We then need to select one of both, depending on the depth
if (ancestor.depth >= other.depth) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class Handler<ResultNode : Node?, HandlerNode, L : LanguageFrontend<in
handler = map[toHandle]
if (
handler != null && // always ok to handle as generic literal expr
!ctx.javaClass.simpleName.contains("LiteralExpr")
!ctx.javaClass.simpleName.contains("LiteralExpr")
) {
errorWithFileLocation(
frontend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ abstract class Language<T : LanguageFrontend<*, *>> : Node() {
// A comparison, so we return the type "boolean"
return this.builtInTypes.values.firstOrNull { it is BooleanType }
?: this.builtInTypes.values.firstOrNull { it.name.localName.startsWith("bool") }
?: unknownType()
?: unknownType()
}

return when (operation.operatorCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ open class Component : Node() {
/** All translation units belonging to this application. */
@AST val translationUnits: MutableList<TranslationUnitDeclaration> = mutableListOf()

@Synchronized
fun addTranslationUnit(tu: TranslationUnitDeclaration) {
translationUnits.add(tu)
}

/**
* All points where unknown data may enter this application, e.g., the main method, or other
* targets such as listeners to external events such as HTTP requests. This also includes the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ inline fun <reified T : Declaration> DeclarationHolder.byNameOrNull(
base =
this.declarations.filterIsInstance<DeclarationHolder>().firstOrNull {
(it as Node).name.lastPartsMatch(baseName)
}
?: return null
} ?: return null
lookup = name.split(".")[1]
}

Expand Down Expand Up @@ -581,8 +580,7 @@ val Node?.assignments: List<Assignment>
get() {
return this?.allChildren<Node>()?.filterIsInstance<AssignmentHolder>()?.flatMap {
it.assignments
}
?: listOf()
} ?: listOf()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ fun <T : Node> T.codeAndLocationFrom(other: Node): T {
* expression handler.
*/
context(CodeAndLocationProvider<AstNode>)

fun <T : Node, AstNode> T.codeAndLocationFromOtherRawNode(rawNode: AstNode): T {
setCodeAndLocation(this@CodeAndLocationProvider, rawNode)
return this
Expand All @@ -299,7 +298,6 @@ fun <T : Node, AstNode> T.codeAndLocationFromOtherRawNode(rawNode: AstNode): T {
* @param parentNode Used to extract the code for this node
*/
context(CodeAndLocationProvider<AstNode>)

fun <T : Node, AstNode> T.codeAndLocationFromChildren(parentNode: AstNode): T {
var first: Node? = null
var last: Node? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fun MetadataProvider?.incompleteType(): Type {

/** Returns a [PointerType] that describes an array reference to the current type. */
context(ContextProvider)

fun Type.array(): Type {
val c =
(this@ContextProvider).ctx
Expand All @@ -65,7 +64,6 @@ fun Type.array(): Type {

/** Returns a [PointerType] that describes a pointer reference to the current type. */
context(ContextProvider)

fun Type.pointer(): Type {
val c =
(this@ContextProvider).ctx
Expand All @@ -78,7 +76,6 @@ fun Type.pointer(): Type {
}

context(ContextProvider)

fun Type.ref(): Type {
val c =
(this@ContextProvider).ctx
Expand Down
Loading

0 comments on commit 3f61e22

Please sign in to comment.