java/ch/wlkl/env/Env.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ch.wlkl.env;

import java.util.Stack;

/**
 *
 * @author walter
 */
public class Env {
    public final static Env env = new Env();
    Stack<IOSimple> ioStack = new Stack();
    public static IOSimple io ;
    public static All2S all2s ;
    static {
        push(new IOSimple());
    }
    
    public static String a2r(Object... o) {
        return all2s.pa2r("\n  ", o);
    }


    public static void out(String m) {
        io.out(m);
    }

    public static void out(Object... o) {
        io.out(o);
    }

    public static void outPa(String  m) {
        io.outPa(m);
    }

    public static void outPa(Object... o) {
        io.outPa(o);
    }
    public static IOSimple ind(int d) {
        return io.ind(d);
    }
    
    public static String srcAt(String s, int pos) {
        return io.srcAt(s, pos);
    }

    public static void dy(String s,  Object... o) {
        io.dy(s, o);
    }

    public static void dy(String m, String  s, int x) {
        io.dy(m, s, x);
    }

    public static void implement(String m, Object... o) {
        dy("not implemented/configured: " + m, o);
    }

    public static void err(String m, Object... o) {
        io.err(m, o);
    }

   public static String assFail(String m, Object... l) {
        return io.assFail(m, l);
    }

   public static String assFail(String m, String s, int pos) {
        return io.assFail(m, s, pos);
    }

    public static void debug(String  m, Object... o) {
        io.debug(0, m, o);
    }

    public static void debug(int l, String  m, Object... o) {
        io.debug(l, m, o);
    }

    public static void push(IOSimple nn) {
        assert io == null || io.all2s == env.all2s;
        env.ioStack.push(io);
        io = nn;
        env.all2s = nn.all2s;
    }

    public static IOSimple pop() {
        assert io.all2s == env.all2s;
        IOSimple old = io;
        io = env.ioStack.pop();
        env.all2s = io.all2s;
        return old;
    }    
}