mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Uast: UEvaluator.evaluateVariableByReference added
This commit is contained in:
@@ -59,13 +59,20 @@ class TreeBasedEvaluator(
|
||||
return resultCache[expression]?.value
|
||||
}
|
||||
|
||||
override fun evaluate(expression: UExpression, state: UEvaluationState?): UValue {
|
||||
override fun evaluate(expression: UExpression, state: UEvaluationState?): UValue = getEvaluationInfo(expression, state).value
|
||||
|
||||
private fun getEvaluationInfo(expression: UExpression, state: UEvaluationState? = null): UEvaluationInfo {
|
||||
if (state == null) {
|
||||
val result = resultCache[expression]
|
||||
if (result != null) return result.value
|
||||
if (result != null) return result
|
||||
}
|
||||
val inputState = state ?: inputStateCache[expression] ?: expression.createEmptyState()
|
||||
return expression.accept(this, inputState).value
|
||||
return expression.accept(this, inputState)
|
||||
}
|
||||
|
||||
override fun evaluateVariableByReference(variableReference: UReferenceExpression, state: UEvaluationState?): UValue {
|
||||
val target = variableReference.resolveToUElement() as? UVariable ?: return UUndeterminedValue
|
||||
return getEvaluationInfo(variableReference, state).state[target]
|
||||
}
|
||||
|
||||
// ----------------------- //
|
||||
|
||||
@@ -43,6 +43,8 @@ interface UEvaluator {
|
||||
|
||||
fun evaluate(expression: UExpression, state: UEvaluationState? = null): UValue
|
||||
|
||||
fun evaluateVariableByReference(variableReference: UReferenceExpression, state: UEvaluationState? = null): UValue
|
||||
|
||||
fun getDependents(dependency: UDependency): Set<UValue>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user