@@ -27,16 +27,20 @@ package de.fraunhofer.aisec.cpg.frontends
27
27
28
28
import de.fraunhofer.aisec.cpg.ScopeManager
29
29
import de.fraunhofer.aisec.cpg.TranslationContext
30
- import de.fraunhofer.aisec.cpg.graph.HasOperatorCode
31
- import de.fraunhofer.aisec.cpg.graph.HasOverloadedOperation
32
- import de.fraunhofer.aisec.cpg.graph.LanguageProvider
33
- import de.fraunhofer.aisec.cpg.graph.Name
30
+ import de.fraunhofer.aisec.cpg.graph.*
31
+ import de.fraunhofer.aisec.cpg.graph.declarations.Declaration
34
32
import de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration
35
33
import de.fraunhofer.aisec.cpg.graph.declarations.RecordDeclaration
36
34
import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration
37
- import de.fraunhofer.aisec.cpg.graph.scopes.*
35
+ import de.fraunhofer.aisec.cpg.graph.edges.flows.*
36
+ import de.fraunhofer.aisec.cpg.graph.scopes.GlobalScope
37
+ import de.fraunhofer.aisec.cpg.graph.scopes.RecordScope
38
+ import de.fraunhofer.aisec.cpg.graph.scopes.Scope
39
+ import de.fraunhofer.aisec.cpg.graph.scopes.Symbol
38
40
import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
39
- import de.fraunhofer.aisec.cpg.passes.*
41
+ import de.fraunhofer.aisec.cpg.passes.ResolveCallExpressionAmbiguityPass
42
+ import de.fraunhofer.aisec.cpg.passes.ResolveMemberExpressionAmbiguityPass
43
+ import de.fraunhofer.aisec.cpg.passes.SymbolResolver
40
44
import kotlin.reflect.KClass
41
45
42
46
/* *
@@ -298,6 +302,26 @@ inline infix fun <reified T : HasOverloadedOperation> KClass<T>.of(
298
302
return Pair (T ::class , operatorCode)
299
303
}
300
304
305
+ /* *
306
+ * A language trait that specifies that this language has dynamic declarations, meaning that
307
+ * declarations can be added to the symbol table at runtime. Since we are a static analysis tools,
308
+ * we can only deliver an approximation to the actual behaviour.
309
+ */
310
+ interface HasDynamicDeclarations : LanguageTrait {
311
+
312
+ /* *
313
+ * A callback that can be used by a language to provide a declaration for a reference. The
314
+ * language is responsible for
315
+ * - Adding the declaration to the symbol table (using [ScopeManager.addDeclaration]; as well as
316
+ * adding it to the AST
317
+ * - Injecting the declaration into the EOG path (if necessary). Since this reference might be
318
+ * part of different AST expressions different approaches might be necessary. The utility
319
+ * functions [Node.insertNodeBeforeInEOGPath] and [Node.insertNodeAfterwardInEOGPath] should
320
+ * be used.
321
+ */
322
+ fun SymbolResolver.provideDeclaration (ref : Reference ): Declaration ?
323
+ }
324
+
301
325
/* * Checks whether the name for a function (as [CharSequence]) is a known operator name. */
302
326
context(LanguageProvider )
303
327
val CharSequence .isKnownOperatorName: Boolean
0 commit comments