// stacks
Stack.prototype.tos=function() {
    return this.s[this.s.length-1];
}
Stack.prototype.push=function(x) {
    this.s.push(x);
}
Stack.prototype.pop=function() {
    return this.s.pop();
}
Stack.prototype.pick=function(n) {
    return this.s[this.s.length-n];
}
function Stack() {
    this.s=new Array;
}
// c-addrs
Caddr.prototype.toString=function() {
    return "[Caddr addr="+this.addr+" ofs="+this.ofs+"]";
}
function Caddr(ca,ofs) {
    this.addr=ca;
    this.ofs=ofs;
}
function toCaddr(v) {
    if (v.addr != undefined) {return v;}
    return new Caddr(v,0);
}
// primitives
function Prim(w) {
  this.w=w;
  this.prim=prims[w];
}

Prim.prototype.toString=function() {
  // return (this.imm?"*":"")+"prim:"+this.w;
  return (this.imm?"*":"")+this.w;
}
// Xt
function Xt(p,w) {
    this.w=w;
    this.prim=p;
}

// special operations
Number.prototype.plus=function(y) {
  return this+y;
}
Caddr.prototype.plus=function(y) {
  return new Caddr(this.addr,this.ofs+y);
}
