1 package com.tapina.robe.swi.clib.stdlib; 2 3 import com.tapina.robe.runtime.CodeBlock; 4 import com.tapina.robe.runtime.Environment; 5 import com.tapina.robe.swi.clib.Stub; 6 7 /*** 8 * This function registers the specified function to be called without arguments when the program terminates normally. 9 * More than one function can be registered in this way. 10 * Returns: Zero if the function succeeds. 11 */ 12 public class AtExit extends Stub { 13 public void executeStub(Environment environment) { 14 final int[] R = environment.getCpu().R; 15 final CodeBlock atexit = environment.getMemoryMap().addEntryPoint(R[0]); 16 Exit.registerExitHandler(atexit); 17 R[0] = 0; 18 } 19 }