public BProgramSyncSnapshot setup ( ) { if ( started ) { throw new IllegalStateException ( "Program already set up." ) ; } Set < BThreadSyncSnapshot > bthreads = drainRecentlyRegisteredBthreads ( ) ; if ( eventSelectionStrategy == null ) { eventSelectionStrategy = new SimpleEventSelectionStrategy ( ) ; } FailedAssertion failedAssertion = null ; try { Context cx = ContextFactory . getGlobal ( ) . enterContext ( ) ; cx . setOptimizationLevel ( - 1 ) ; // must use interpreter mode initProgramScope ( cx ) ; // evaluate code in order if ( prependedCode != null ) { prependedCode . forEach ( s -> evaluate ( s , "prependedCode" ) ) ; prependedCode = null ; } setupProgramScope ( programScope ) ; if ( appendedCode != null ) { appendedCode . forEach ( s -> evaluate ( s , "appendedCode" ) ) ; appendedCode = null ; } } catch ( FailedAssertionException fae ) { failedAssertion = new FailedAssertion ( fae . getMessage ( ) , "---init_code" ) ; } finally { Context . exit ( ) ; } started = true ; return new BProgramSyncSnapshot ( this , bthreads , Collections . emptyList ( ) , failedAssertion ) ; }
Sets up the program scope and evaluates the program source .