Package abstrasy

Examples of abstrasy.Interpreter


         *                      Si ms est inférieur à zéro, un exception "Out of range" est produite.
         *                      Si ms est égal à zéro, cela revient au même que (receive).
         *                     
         */
       
        Interpreter actor = Interpreter.mySelf();
       
        /**
         * Le programmeur devrait pouvoir utiliser tous les systèmes en même temps:
         * =======================================================================
         * - mutex permet de gérer l'exclusion mutuelle des processus.
View Full Code Here


        startAt.isGoodArgsCnt(3);
        Node func = startAt.getSubNode(2, Node.TYPE_FUNCTION);
        Node src = startAt.getSubNode(1, Node.TYPE_CLIST | Node.TYPE_FUNCTION);
        Node res = Node.createCList();
        Node expr = Node.createExpr();
        Interpreter interpreter = Interpreter.mySelf();
        boolean oldTailNode = interpreter.isTailNode();
        boolean oldTerminalNode = interpreter.isTerminalNode();
        Exception allExcep=null;
        try{
        if (src.getQType()==Node.TYPE_CLIST) {
            /**
             * la source est une liste...
             */
            for (int i = 0; i < src.size(); i++) {
                interpreter.setTailNode(false);
                interpreter.setTerminalNode(false);
                Node tmpn = expr.append(func).append(src.elementAt(i)).exec(true);
                if (tmpn != null)
                    res.append(tmpn.secure());
                expr.clearChilds();
            }
        }
        else {
            /**
             * la source est une fonction génératrice...
             */
            int n = 0;
            Node fxarg = new Node(n).letFinal(true);
            Node fxn = Node.createExpr().append(src).append(fxarg);
            Node tmpfxn = fxn; // juste pour qu'il ne soit pas null...
            while (tmpfxn != null) {
                interpreter.setTailNode(false);
                interpreter.setTerminalNode(false);
                fxarg.setNumber(n++);
                tmpfxn = fxn.exec(true);
                if (tmpfxn != null) {
                    interpreter.setTailNode(false);
                    interpreter.setTerminalNode(false);
                    Node tmpn = expr.append(func).append(tmpfxn).exec(true);
                    if (tmpn != null)
                        res.append(tmpn.secure());
                    expr.clearChilds();
                }
            }
        }
        }
        catch(Exception ex){
            allExcep=ex;
        }
        interpreter.setTailNode(oldTailNode);
        interpreter.setTerminalNode(oldTerminalNode);
        if(allExcep!=null){ throw allExcep; }
        return res;

    }
View Full Code Here

        /*
         * autres variables...
         */
        Node res = null;

        Interpreter myself = Interpreter.mySelf();

        StaticHeap global = myself.getGLOBAL();

        /*
         * Permet de repporter les exceptions
         */
        Exception reportExcep = null;

        /*
         * ouverture de la file d'attente
         */
       
        LinkedList<Node> old_queue = myself.pendingMsg_OPEN();
       
        /*
         * Nouveau contexte...
         */
        global.push();
       
        try {
            res = xnode.exec(true);
        }
        catch (Exception e) {
            reportExcep = e;
        }

        /*
         * restaurer le contexte
         */
        global.pull();
       
        /*
         * fermeture de la file d'attente dans tous les cas...
         */
        myself.pendingMsg_CLOSE(old_queue);

        /*
         * reporter l'exception s'il y en a une...
         */
        if (reportExcep != null) {
View Full Code Here

        /**
         * formes:
         *         (delegate fonction) : -> (!return (invoke fonction argv))
         */
        startAt.isGoodArgsCnt(2);
        Interpreter interpreter = Interpreter.mySelf();
       
              
       
        /*
         * wrapper->delegating/consulting en fonction de la forme syntaxique utilisée...
         */
        Node oldWrapper=interpreter.getWrapperFunction();
        interpreter.setWrapperFunction(interpreter.getThisFunction());
       
        Node rnode=invoker(startAt.getSubNode(1,Node.TYPE_FUNCTION));  
       
        interpreter.setWrapperFunction(oldWrapper);
      
        return rnode;
    }
View Full Code Here

        }   
        Product product = new Product(rings);
       
        Node btype = startAt.getSubNode(i++, Node.TYPE_PCODE);
        Node enode = startAt.getSubNode(i++, Node.TYPE_LAZY);
        Interpreter interpreter = Interpreter.mySelf();
        boolean oldCanLoop = interpreter.isCanLoop();
        boolean oldInLoop = interpreter.isInLoop();
        interpreter.setCanLoop(true);
        interpreter.setInLoop(true);

        try {
            if (btype.isPCode(PCoder.PC_DO)) {
                /**
                 * (foreach-product [l1] [l2]...[ln] do {...})
                 */
                Node argv;

                Heap.push(); // nouvel espace local pour argv (exclusivment)
                Heap argv_h = Heap.current(); // optimisation du 09/03/2012

                Heap.push(); // nouvel espace local
                Heap local = Heap.current();

                /*
                 * Correction du 10 mai 2011:
                 * =========================
                 *    Les boucles du type do{...} s'arrête dès qu'un résultat est retourné. Cela ne signifie
                 *    bien entendu pas que la condition qui permet l'itération n'est pas vérifiée. Toutefois,
                 *    comme les boucle du type do{...} ne peuvent retourner qu'un seul résultat, il est inutile
                 *    de relancer l'itération suivante ddès qu'un résultat est fourni. Ainsi, pour permettre
                 *    de continuer la boucle, il est possible de placer le résultat dans une variable et non de
                 *    la retourner directement comme résultat.
                 *   
                 */
                while (interpreter.isCanIterate() && product.hasNext() && xnode==null) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(product.getNext());
                    argv_h.put(PCoder.ARGV, argv);
                    xnode = enode.exec(true);
                }

                Heap.pull(); // supprimer l'espace local...
                Heap.pull(); // supprimer l'espace argv...

            }
            else if (btype.isPCode(PCoder.PC_LIST)) {
                /**
                 * (foreach-product [l1] [l2]...[ln] list{...})
                 */
                Node argv;
                xnode = Node.createCList();

                Heap.push(); // nouvel espace local pour argv (exclusivment)
                Heap argv_h = Heap.current(); // optimisation du 09/03/2012

                Heap.push(); // nouvel espace local
                Heap local = Heap.current();

                while (interpreter.isCanIterate() && product.hasNext()) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(product.getNext());
                    argv_h.put(PCoder.ARGV, argv);
                    rnode = enode.exec(true);
                    if (rnode != null)
                        xnode.addElement(rnode.secure());
               
                }

                Heap.pull(); // supprimer l'espace local...
                Heap.pull(); // supprimer l'espace argv...

            }
            else {
                // erreur de syntaxe.
                throw new InterpreterException(StdErrors.Syntax_error);
            }
        }
        catch (Exception ex) {
            interpreter.consumeBreakCode_onLoop();
            interpreter.setCanLoop(oldCanLoop);
            interpreter.setInLoop(oldInLoop);
            throw ex;
        }
        interpreter.consumeBreakCode_onLoop();
        interpreter.setCanLoop(oldCanLoop);
        interpreter.setInLoop(oldInLoop);
        return xnode;
    }
View Full Code Here

        startAt.isGoodArgsCnt(4);
        Node xnode = startAt.getSubNode(1, Node.TYPE_LAZY);
        startAt.requirePCode(2, PCoder.PC_CATCH);
        Node enode = startAt.getSubNode(3, Node.TYPE_LAZY);
        Node res = null;
        Interpreter interpreter = Interpreter.mySelf();
        BaseContextSnapshot contextSnapshot = new BaseContextSnapshot(interpreter);
        boolean isRetrying = true;

        while (isRetrying) {
            try {
View Full Code Here

TOP

Related Classes of abstrasy.Interpreter

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.