pluotsorbet/frame.js

35 строки
937 B
JavaScript

/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
'use strict';
Array.prototype.push2 = function(value) {
this.push(value);
this.push(null);
return value;
}
Array.prototype.pop2 = function() {
this.pop();
return this.pop();
}
Array.prototype.pushType = function(signature, value) {
if (signature === "J" || signature === "D") {
this.push2(value);
return;
}
this.push(value);
}
Array.prototype.popType = function(signature) {
return (signature === "J" || signature === "D") ? this.pop2() : this.pop();
}
// A convenience function for retrieving values in reverse order
// from the end of the stack. stack.read(1) returns the topmost item
// on the stack, while stack.read(2) returns the one underneath it.
Array.prototype.read = function(i) {
return this[this.length - i];
};