1 package com.tapina.robe.swi.clib.stdlib; 2 3 import com.tapina.robe.runtime.Environment; 4 import com.tapina.robe.swi.clib.Stub; 5 6 /*** 7 * This function generates a psuedo-random number in the range from 0 to RAND_MAX . 8 * Returns: A psuedo-random number. 9 */ 10 public class Rand extends Stub { 11 private RandomState state; 12 13 public Rand(RandomState state) { 14 this.state = state; 15 } 16 17 public void executeStub(Environment environment) { 18 environment.getCpu().R[0] = state.getRandom().nextInt() & 0x7fffffff; 19 } 20 }