Skip to content

Commit

Permalink
looking for bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
iusildra committed May 22, 2023
1 parent 2b9c984 commit e3c93a6
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class RuntimeEvaluation private (
parse(expression).flatMap {
validator.validate(_) match {
case Unrecoverable(e) => Recoverable(s"Can't validate at runtime, recovering with compiler: $e")
case validated => validated
case validated =>
println(s"\u001b[32m[DEBUG] validated: $validated\u001b[0m")
validated
}
}

Expand Down Expand Up @@ -152,10 +154,12 @@ class RuntimeEvaluator(frame: JdiFrame, logger: Logger) {
ofValue <- evaluate(of)
loader <- frame.classLoader()
initMethodName <- Safe(getLastInnerType(tree.`type`.name()).get)
_ = println(s"initMethodName: $initMethodName")
instance <- ofValue.value.`type` match {
case tree.`type` => Safe(ofValue)
case _ => ofValue.asObject.invoke(initMethodName, Seq.empty)
}
_ = println(s"instance of $tree is $instance")
} yield instance
}

Expand All @@ -181,15 +185,19 @@ class RuntimeValidator(frame: JdiFrame, logger: Logger) {
.map { ths => ThisTree(ths.reference.referenceType().asInstanceOf[ClassType]) }
}

def validate(expression: Stat): Validation[RuntimeEvaluationTree] = expression match {
case value: Term.Name => validateName(value, thisTree)
case _: Term.This => thisTree
case sup: Term.Super => Recoverable("Super not (yet) supported at runtime")
case _: Term.Apply | _: Term.ApplyInfix | _: Term.ApplyUnary => validateMethod(extractCall(expression))
case select: Term.Select => validateSelect(select)
case lit: Lit => validateLiteral(lit)
case instance: Term.New => validateNew(instance)
case _ => Recoverable("Expression not supported at runtime")
def validate(expression: Stat): Validation[RuntimeEvaluationTree] = {
val res = expression match {
case value: Term.Name => validateName(value, thisTree)
case _: Term.This => thisTree
case sup: Term.Super => Recoverable("Super not (yet) supported at runtime")
case _: Term.Apply | _: Term.ApplyInfix | _: Term.ApplyUnary => validateMethod(extractCall(expression))
case select: Term.Select => validateSelect(select)
case lit: Lit => validateLiteral(lit)
case instance: Term.New => validateNew(instance)
case _ => Recoverable("Expression not supported at runtime")
}
println(s"Validating $expression to $res")
res
}

/**
Expand Down

0 comments on commit e3c93a6

Please sign in to comment.