/* StackFrame.java * * Copyright (c) 2000, Ted Nelson and Tuomas Lukka * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README * file for more details. * */ /* * Written by Benjamin Fallenstein */ package org.gzigzag.flowing; import org.gzigzag.*; /** A stack frame for Flowing Clang. */ public abstract class StackFrame { String rcsid = "$Id: StackFrame.java,v 1.5 2000/11/16 20:33:13 bfallenstein Exp $"; public static boolean dbg = true; static final void p(String s) { if(dbg) ZZLogger.log(s); } // METHODS TO BE IMPLEMENTED BY SUBCLASSES /** Get the value associated with a cell. */ public abstract Object getSingle(ZZCell c); /** Set the value associated with a cell. * @param d The Data object in which the value to be set is found. * @param at The value's position in the Data object. */ public abstract void setSingle(ZZCell c, Data d, int at); /** Get position of instruction pointer. */ public abstract ZZCell getPos(); /** Set position of instruction pointer. */ public abstract void setPos(ZZCell c); /** Create a lower-level stackframe. */ public abstract StackFrame call(); /** Return true if this stack frame is parent of given stack frame. */ public abstract boolean parentof(StackFrame sf); /** Return to the next higher stackframe (disconnects this (lower) frame). * Also sets instruction pointer to null, but keeps the values associated * with cells, so that the returned data can be read. Call delete() when * you're done with the values. */ public abstract StackFrame ret(); /** Delete the cells associated with the stackframe, if any. * This renders the values of a structural stackframe inaccessible. */ public void delete() {} // METHODS StackFrame PROVIDES private static final ZZCell[] reverse(ZZCell[] arr) { ZZCell[] res = new ZZCell[arr.length]; for(int i=0; i