Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.gradle
.idea
build
build
/src/test/generated_tests/
/out/
2 changes: 2 additions & 0 deletions src/main/java/org/meteordev/starscript/Starscript.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ public Value pop() {

/** Returns a value from the stack without removing it. */
public Value peek() {
if (stack.size() == 0) return Value.null_();
return stack.peek();
}

/** Returns a value from the stack with an offset without removing it. */
public Value peek(int offset) {
if (stack.size() <= offset) return Value.null_();
return stack.peek(offset);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/meteordev/starscript/utils/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ public T peek() {
public T peek(int offset) {
return items[size - 1 - offset];
}

public int size() {
return size;
}
}