public class ForthStringReader extends ForthReader
EVALUATE
.bufferSize, description, lineNumber, position
Constructor and Description |
---|
ForthStringReader(VM vm,
int offset,
int length)
Construct a reader to read a string directly form the
Forth data space, starting at offset and lasting for length
characters.
|
Modifier and Type | Method and Description |
---|---|
protected int |
charAt(int off)
Return the character at the given offset into the buffer or -1
if the character is unavailable.
|
void |
close()
Close the input stream.
|
int |
getBase()
Return the location of the first character in the input stream.
|
int |
read()
Reads a single character.
|
boolean |
refill()
Attempt to fill the input buffer from the input source, and
return true if successful.
|
ForthReader |
restoreInput(VM vm)
Restore the current input environment from the system stack.
|
void |
saveInput(VM vm)
Save the current input parameters on the system stack.
|
backup, getDescription, getLineNumber, getPosition, isEmpty, ready, setLineNumber, setPosition, size
public ForthStringReader(VM vm, int offset, int length)
vm
- the virtual machine where the string is stored.offset
- the start of the stringlength
- the length of the string, in characterspublic int read() throws java.io.IOException
ForthReader
read
in class ForthReader
java.io.IOException
- when there is a problem reading the input
stream.public void close() throws java.io.IOException
ForthReader
close
in class ForthReader
java.io.IOException
protected int charAt(int off)
ForthReader
charAt
in class ForthReader
off
- the offset from the start of the buffer to obtain
a character.public int getBase()
ForthReader
getBase
in class ForthReader
public void saveInput(VM vm)
ForthReader
save-input
function.
Place all of the parameters on the data stack followed by the
number of parameters.saveInput
in class ForthReader
vm
- the virtual machine to use when saving the current
input environment.public ForthReader restoreInput(VM vm)
ForthReader
restore-input
function.
This is the counter part to the saveInput()
method.
The top of the stack holds the number of parameters saved.restoreInput
in class ForthReader
vm
- the virtual machine to recover input parameters
form.null
if the input environment could not
be recovered.public boolean refill()
ForthReader
position
to zero,
set bufferSize
to the number of bytes read,
and return true.
Receipt of a line containing no characters is considered
successful. If there is no input available return false.
This method is called by the Forth function refill
.refill
in class ForthReader