Skip to content

Commit 88b8939

Browse files
committed
feat: support function references in frameless icall instructions
1 parent e4796ce commit 88b8939

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/main/kotlin/com/github/xepozz/php_opcodes_language/Opcodes.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ enum class Opcodes() {
44
INIT_NS_FCALL_BY_NAME,
55
INIT_FCALL,
66
INIT_FCALL_BY_NAME,
7+
FRAMELESS_ICALL_0,
8+
FRAMELESS_ICALL_1,
9+
FRAMELESS_ICALL_2,
10+
FRAMELESS_ICALL_3,
711
NEW,
812
FETCH_CLASS_CONSTANT,
913
FETCH_STATIC_PROP_R,

src/main/kotlin/com/github/xepozz/php_opcodes_language/language/reference/PHPOpReferenceContributor.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,39 @@ class PHPOpReferenceContributor : PsiReferenceContributor() {
204204
}
205205
)
206206

207+
registrar.registerReferenceProvider(
208+
PlatformPatterns.psiElement(PHPOpParameter::class.java)
209+
.withParent(
210+
PlatformPatterns.psiElement(PHPOpParenExpr::class.java)
211+
.withParent(
212+
PlatformPatterns.psiElement(PHPOpArgument::class.java)
213+
.withParent(
214+
PlatformPatterns.psiElement(PHPOpInstruction::class.java)
215+
.withName(
216+
*arrayOf(
217+
Opcodes.FRAMELESS_ICALL_0,
218+
Opcodes.FRAMELESS_ICALL_1,
219+
Opcodes.FRAMELESS_ICALL_2,
220+
Opcodes.FRAMELESS_ICALL_3,
221+
)
222+
.map { it.name }
223+
.toTypedArray(),
224+
)
225+
)
226+
)
227+
),
228+
object : PsiReferenceProvider() {
229+
override fun getReferencesByElement(
230+
element: PsiElement,
231+
context: ProcessingContext
232+
): Array<out PsiReference> {
233+
println("PHPOpTypes.IDENTIFIER: ${element.text}")
234+
val functionName = element.text
235+
return arrayOf(PhpFunctionNameReference(element, functionName))
236+
}
237+
}
238+
)
239+
207240
registrar.registerReferenceProvider(
208241
PlatformPatterns.psiElement(PHPOpStringLiteral::class.java)
209242
.withParent(

0 commit comments

Comments
 (0)