Package caltrop.interpreter.environment

Examples of caltrop.interpreter.environment.Environment.bind()


            if (repExpr == null) {
                for (int j = 0; j < vars.length; j++) {
                    final InputChannel channel = ((InputPort) (inputPortMap
                            .get(inputPattern.getPortname()))).getChannel(0); // FIXME
                    local.bind(vars[j], new SingleTokenReaderThunk(channel, j));
                }
            } else {
                SimpleThunk repExprThunk = new SimpleThunk(repExpr, context,
                        local);
                local.bind(new EnvironmentKey(inputPattern.getPortname()),
View Full Code Here


                    local.bind(vars[j], new SingleTokenReaderThunk(channel, j));
                }
            } else {
                SimpleThunk repExprThunk = new SimpleThunk(repExpr, context,
                        local);
                local.bind(new EnvironmentKey(inputPattern.getPortname()),
                        repExprThunk);

                for (int j = 0; j < vars.length; j++) {
                    final InputChannel channel = ((InputPort) (inputPortMap
                            .get(inputPattern.getPortname()))).getChannel(0); // FIXME
View Full Code Here

                        repExprThunk);

                for (int j = 0; j < vars.length; j++) {
                    final InputChannel channel = ((InputPort) (inputPortMap
                            .get(inputPattern.getPortname()))).getChannel(0); // FIXME
                    local.bind(vars[j], new MultipleTokenReaderThunk(channel,
                            j, vars.length, repExprThunk, context));
                }
            }
        }
View Full Code Here

        for (int i = 0; i < decls.length; i++) {
            final Expression v = decls[i].getInitialValue();

            if (v == null) {
                local.bind(decls[i].getName(), null);
            } else {
                local.bind(decls[i].getName(), new SimpleThunk(v, context,
                        local));
            }
        }
View Full Code Here

            final Expression v = decls[i].getInitialValue();

            if (v == null) {
                local.bind(decls[i].getName(), null);
            } else {
                local.bind(decls[i].getName(), new SimpleThunk(v, context,
                        local));
            }
        }

        env = local;
View Full Code Here

    }

    public Environment createGlobalEnvironment(Environment parent) {
        Environment env = new HashEnvironment(parent, context());

        env.bind("println", _theContext.createProcedure(new Procedure() {
            public void call(Object[] args) {
                System.out.println(args[0]);
            }

            public int arity() {
View Full Code Here

            public int arity() {
                return 1;
            }
        }));

        env.bind("SOP", _theContext.createFunction(new Function() {
            public Object apply(Object[] args) {
                try {
                    System.out.println(args[0]);
                    return args[0];
                } catch (Exception ex) {
View Full Code Here

            public int arity() {
                return 1;
            }
        }));

        env.bind("logValue", _theContext.createFunction(new Function() {
            public Object apply(Object[] args) {
                try {
                    PrintStream output = new PrintStream(new FileOutputStream(
                            _theContext.stringValue(args[0]), true));
                    output.println(args[1].toString());
View Full Code Here

            public int arity() {
                return 2;
            }
        }));

        env.bind("Integers", _theContext.createFunction(new Function() {
            public Object apply(Object[] args) {
                try {
                    int a = _theContext.intValue(args[0]);
                    int b = _theContext.intValue(args[1]);
                    List res = (b < a) ? Collections.EMPTY_LIST
View Full Code Here

            public int arity() {
                return 2;
            }
        }));

        env.bind("$not", _theContext.createFunction(new Function() {
            public Object apply(Object[] args) {
                try {
                    BooleanToken b = (BooleanToken) args[0];
                    return b.not();
                } catch (Exception ex) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.