-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Issue #24 value stack (1st draft)
- refactor Values into standalone class - fix up LinuxKernel pattern - javadoc updates only for I*Effector - javadoc runs quietly (build.xml) Signed-off-by: jrte <[email protected]>
- Loading branch information
Showing
7 changed files
with
116 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.characterforming.jrte.engine; | ||
|
||
import java.util.Arrays; | ||
|
||
class Value { | ||
private byte[] val; | ||
private int len; | ||
|
||
Value(int size) { | ||
this.val = new byte[Math.max(size, 16)]; | ||
this.len = 0; | ||
} | ||
|
||
int length() { return this.len; } | ||
|
||
byte[] value() { return this.val; } | ||
|
||
void clear() { this.len = 0; } | ||
|
||
void paste(byte input) { | ||
if (this.len >= this.val.length) { | ||
this.val = Arrays.copyOf(this.val, this.len + (this.len >> 1)); | ||
} | ||
this.val[this.len++] = input; | ||
} | ||
|
||
void paste(byte[] input, int length) { | ||
assert length <= input.length; | ||
int newLength = this.len + length; | ||
if (newLength > this.val.length) { | ||
this.val = Arrays.copyOf(this.val, newLength + (this.len >> 1)); | ||
} | ||
System.arraycopy(input, 0, this.val, this.len, length); | ||
this.len = newLength; | ||
} | ||
|
||
void paste(Value value) { | ||
this.paste(value.val, value.length()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters