3333import luceedebug .IDebugFrame ;
3434import luceedebug .IDebugManager ;
3535import luceedebug .coreinject .frame .DebugFrame ;
36+ import luceedebug .coreinject .frame .Frame ;
3637
3738public class DebugManager implements IDebugManager {
3839
@@ -328,36 +329,37 @@ synchronized private String doDumpAsJSON(PageContext pageContext, Object someDum
328329 }
329330
330331 public Either </*err*/ String , /*ok*/ Either <ICfValueDebuggerBridge , String >> evaluate (Long frameID , String expr ) {
331- final var frame = frameByFrameID .get (frameID );
332- if (frame != null ) {
333- return doEvaluate (frame , expr )
334- .bimap (
335- err -> err ,
336- ok -> {
337- // what about bool, Long, etc. ?...
338- if (ok == null ) {
339- return Either .Right ("null" );
340- }
341- else if (ok instanceof String ) {
342- return Either .Right ("\" " + ((String )ok ).replaceAll ("\" " , "\\ \" " ) + "\" " );
343- }
344- else if (ok instanceof Number || ok instanceof Boolean ) {
345- return Either .Right (ok .toString ());
346- }
347- else {
348- return Either .Left (frame .trackEvalResult (ok ));
349- }
350- }
351- );
352- }
353- else {
332+ final var zzzframe = frameByFrameID .get (frameID );
333+ if (!(zzzframe instanceof Frame )) {
354334 return Either .Left ("<<no such frame>>" );
355335 }
336+
337+ Frame frame = (Frame )zzzframe ;
338+
339+ return doEvaluate (frame , expr )
340+ .bimap (
341+ err -> err ,
342+ ok -> {
343+ // what about bool, Long, etc. ?...
344+ if (ok == null ) {
345+ return Either .Right ("null" );
346+ }
347+ else if (ok instanceof String ) {
348+ return Either .Right ("\" " + ((String )ok ).replaceAll ("\" " , "\\ \" " ) + "\" " );
349+ }
350+ else if (ok instanceof Number || ok instanceof Boolean ) {
351+ return Either .Right (ok .toString ());
352+ }
353+ else {
354+ return Either .Left (frame .trackEvalResult (ok ));
355+ }
356+ }
357+ );
356358 }
357359
358360 // concurrency here needs to be at the level of the DAP server?
359361 // does the DAP server do multiple concurrent requests ... ? ... it's all one socket so probably not ? ... well many inbound messages can be being serviced ...
360- private Either </*err*/ String , /*ok*/ Object > doEvaluate (DebugFrame frame , String expr ) {
362+ private Either </*err*/ String , /*ok*/ Object > doEvaluate (Frame frame , String expr ) {
361363 try {
362364 return CompletableFuture
363365 .supplyAsync (
@@ -392,10 +394,18 @@ public boolean evaluateAsBooleanForConditionalBreakpoint(Thread thread, String e
392394 if (stack .isEmpty ()) {
393395 return false ;
394396 }
395- return doEvaluateAsBoolean (stack .get (stack .size () - 1 ), expr );
397+
398+ DebugFrame frame = stack .get (stack .size () - 1 );
399+
400+ if (frame instanceof Frame ) {
401+ return doEvaluateAsBoolean ((Frame )frame , expr );
402+ }
403+ else {
404+ return false ;
405+ }
396406 }
397407
398- private boolean doEvaluateAsBoolean (DebugFrame frame , String expr ) {
408+ private boolean doEvaluateAsBoolean (Frame frame , String expr ) {
399409 try {
400410 return CompletableFuture
401411 .supplyAsync (
@@ -482,7 +492,7 @@ synchronized public IDebugFrame[] getCfStack(Thread thread) {
482492 if (stack == null ) {
483493 System .out .println ("getCfStack called, frames was null, frames is " + cfStackByThread + ", passed thread was " + thread );
484494 System .out .println (" thread=" + thread + " this=" + this );
485- return new DebugFrame [0 ];
495+ return new Frame [0 ];
486496 }
487497
488498 ArrayList <DebugFrame > result = new ArrayList <>();
@@ -501,7 +511,7 @@ synchronized public IDebugFrame[] getCfStack(Thread thread) {
501511 }
502512 }
503513
504- return result .toArray (new DebugFrame [result .size ()]);
514+ return result .toArray (new Frame [result .size ()]);
505515 }
506516
507517 static class CfStepRequest {
@@ -570,9 +580,12 @@ public void luceedebug_stepNotificationEntry_step(int lineNumber) {
570580 if (request == null ) {
571581 return ;
572582 }
573- else {
583+ else if ( frame instanceof Frame ) {
574584 request .__debug__steps ++;
575- maybeNotifyOfStepCompletion (currentThread , frame , request , minDistanceToLuceedebugStepNotificationEntryFrame + 1 , System .nanoTime ());
585+ maybeNotifyOfStepCompletion (currentThread , (Frame ) frame , request , minDistanceToLuceedebugStepNotificationEntryFrame + 1 , System .nanoTime ());
586+ }
587+ else {
588+ // no-op
576589 }
577590 }
578591
@@ -596,13 +609,16 @@ public void luceedebug_stepNotificationEntry_stepAfterCompletedUdfCall() {
596609 if (request == null ) {
597610 return ;
598611 }
599- else {
612+ else if ( frame instanceof Frame ) {
600613 request .__debug__steps ++;
601- maybeNotifyOfStepCompletion (currentThread , frame , request , minDistanceToLuceedebugStepNotificationEntryFrame + 1 , System .nanoTime ());
614+ maybeNotifyOfStepCompletion (currentThread , (Frame )frame , request , minDistanceToLuceedebugStepNotificationEntryFrame + 1 , System .nanoTime ());
615+ }
616+ else {
617+ // no-op
602618 }
603619 }
604620
605- private void maybeNotifyOfStepCompletion (Thread currentThread , DebugFrame frame , CfStepRequest request , int minDistanceToLuceedebugStepNotificationEntryFrame , long start ) {
621+ private void maybeNotifyOfStepCompletion (Thread currentThread , Frame frame , CfStepRequest request , int minDistanceToLuceedebugStepNotificationEntryFrame , long start ) {
606622 if (frame .isUdfDefaultValueInitFrame && !config_ .getStepIntoUdfDefaultValueInitFrames ()) {
607623 return ;
608624 }
@@ -683,11 +699,7 @@ private DebugFrame maybe_pushCfFrame_worker(PageContext pageContext, String sour
683699
684700 final int depth = stack .size (); // first frame is frame 0, and prior to pushing the first frame the stack is length 0; next frame is frame 1, and prior to pushing it the stack is of length 1, ...
685701
686- final DebugFrame frame = DebugFrame .maybeMakeFrame (sourceFilePath , depth , valTracker , pageContext );
687-
688- if (frame == null ) {
689- return null ;
690- }
702+ final DebugFrame frame = DebugFrame .makeFrame (sourceFilePath , depth , valTracker , pageContext );
691703
692704 stack .add (frame );
693705
@@ -703,11 +715,9 @@ private DebugFrame maybe_pushCfFrame_worker(PageContext pageContext, String sour
703715
704716 public void pushCfFunctionDefaultValueInitializationFrame (lucee .runtime .PageContext pageContext , String sourceFilePath ) {
705717 DebugFrame frame = maybe_pushCfFrame_worker (pageContext , sourceFilePath );
706- if (frame == null ) {
707- return ;
718+ if (frame instanceof Frame ) {
719+ (( Frame ) frame ). isUdfDefaultValueInitFrame = true ;
708720 }
709-
710- frame .isUdfDefaultValueInitFrame = true ;
711721 }
712722
713723 public void popCfFrame () {
0 commit comments