Package net.fortytwo.ripple.model

Examples of net.fortytwo.ripple.model.StackMapping


                }

                return;
            }
            RippleValue first = left.getFirst();
            final StackMapping f = first.getMapping();

            if (null == f) {
                if (right.isNil()) {
                    //System.out.println("adding solution: " + left);
                    solutions.add(left);
                    return;
                } else {
                    Closure c = new Closure(right.getFirst().getMapping(), first);
                    right = right.getRest();
                    left = left.getRest().push(new Operator(c));
                }
            } else {
                if (0 == f.arity()) {
                    Collector<RippleList> results = new Collector<RippleList>();
                    // Note: synchronous evaluation is required
                    // Note: stack context is trivial
                    f.apply(left.getRest(), results, mc);
                    for (RippleList s : results) {
                        RippleList i = s;
                        RippleList cur = right;
                        while (!cur.isNil()) {
                            i = i.push(cur.getFirst());
View Full Code Here


            if (null != first.getMapping()) {
                RippleList rest = arg.getRest();
                //System.out.println("   rest = " + rest);

                final StackMapping f = first.getMapping();
                //System.out.println("   f = " + f);
                //System.out.println("   f.arity() = " + f.arity());

                // Nullary functions don't need their argument stacks reduced.
                // They shouldn't even care if the stack is empty.
                if (f.arity() == 0) {
                    f.apply(rest, this, mc);
                }

                // Functions with positive arity do require the stack to be
                // reduced, to one level per argument.
                else {
View Full Code Here

                stack.push(result));
    }

    @Override
    public StackMapping getInverse() {
        return new StackMapping() {
            public int arity() {
                return 1;
            }

            public StackMapping getInverse() throws RippleException {
View Full Code Here

                stack.push(result));
    }

    @Override
    public StackMapping getInverse() {
        return new StackMapping() {
            public int arity() {
                return 1;
            }

            public StackMapping getInverse() throws RippleException {
View Full Code Here

                    Closure c = new Closure(ops.getFirst().getMapping(), first);
                    stack = stack.getRest().push(new Operator(c));
                    ops = ops.getRest();
                }
            } else {
                StackMapping f = first.getMapping();

                if (0 == f.arity()) {
                    try {
                        if (ops.isNil()) {
                            f.apply(stack.getRest(), outputSink, mc);
                        } else {
                            f.apply(stack.getRest(), new SpecialSink(ops, mc), mc);
                        }
                    } catch (Throwable t) {
                        // To keep things simple, just eat any errors.
                        logger.severe("error in expression reduction: " + t.getMessage());
                    }
View Full Code Here

                          final ModelConnection mc) throws RippleException {

            boolean b = mc.toBoolean(arg.getFirst());

            if (b) {
                StackMapping a = new WhileApplicator(program, criterion);
                RippleList stack = originalStack.push(program).push(new Operator(a));
                solutions.put(stack);
            } else {
                solutions.put(originalStack);
            }
View Full Code Here

        public void apply(final RippleList arg,
                          final Sink<RippleList> solutions,
                          final ModelConnection mc) throws RippleException {

            RippleList stack = arg;
            StackMapping d = new WhileDecider(stack, program, criterion);

            solutions.put(stack.push(criterion).push(new Operator(d)));
        }
View Full Code Here

                else {
                    RippleList inverted = list.invert();
                    RippleValue f = inverted.getFirst();

                    for (Operator operator : operators) {
                        StackMapping inner = new InnerMapping(mc.list(), inverted.getRest(), operator);
                        solutions.put(rest.push(f).push(mappingVal).push(Operator.OP).push(new Operator(inner)));
                    }
                }
            }
        };
View Full Code Here

                solutions.put(stack.push(newListRest));
            } else {
                // The stack to operate on
                RippleList restStack = stack.push(invertedListHead.getFirst()).push(operator);

                StackMapping restMapping = new InnerMapping(newListRest, invertedListHead.getRest(), operator);
                solutions.put(restStack.push(new Operator(restMapping)));
            }
        }
View Full Code Here

                stack.push(result));
    }

    @Override
    public StackMapping getInverse() {
        return new StackMapping() {
            public int arity() {
                return 1;
            }

            public StackMapping getInverse() throws RippleException {
View Full Code Here

TOP

Related Classes of net.fortytwo.ripple.model.StackMapping

Copyright © 2018 www.massapicom. 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.