Package abstrasy

Examples of abstrasy.Interpreter


            sortNodes_(vnodes);
        }
       
        Node res = null;

        Interpreter myself = Interpreter.mySelf();

        StaticHeap global = myself.getGLOBAL();
        InterpreterSemaphore sema = Interpreter.getSemaphore();

        Exception reportExcep = null;

        /*
         * Si les nodes sont déjà verrrouillés par moi-même, on ignore le verrouillage...
         */
        for(int i=0;i<vnodes.length;i++){
            vnodes[i].lockLock();
        }
       

       /*
        * Nouveau contexte...
        */
        global.push();
       
        // Entrée dans la section verrouillée réussie...
        myself.actor_LOCKSECTION();
       
        try {
            res = xnode.exec(true);
        }
        catch (Exception e) {
            reportExcep = e;
        }

        //Sortie de la section verroui
        myself.actor_UNLOCKSECTION();
       
        /*
         * restaurer le contexte
         */
        global.pull();
View Full Code Here


            sortNodes_(vnodes);
        }
       
        Node res = null;

        Interpreter myself = Interpreter.mySelf();

        StaticHeap global = myself.getGLOBAL();

        Exception reportExcep = null;

        /*
         * Si les nodes sont déjà verrrouillés par moi-même, on ignore le verrouillage...
         */
        for(int i=0;i<vnodes.length;i++){
            vnodes[i].acquirelock(myself);
            if(!vnodes[i].isLockedBy(myself)){ throw new InterpreterException(StdErrors.Critical_section_locking_fail); }
        }

        /*
         * Nouveau contexte...
         */
        global.push();

        // Entrée dans la section verrouillée réussie...
        myself.actor_LOCKSECTION();

        try {
            res = xnode.exec(true);
        }
        catch (Exception e) {
            reportExcep = e;
        }

        //Sortie de la section verrouillée...
        myself.actor_UNLOCKSECTION();
       
        /*
         * restaurer le contexte
         */
        global.pull();
View Full Code Here

    public PCFx_kill() {
    }

    private void kill_target(String target) throws Exception{

        Interpreter myself = Interpreter.mySelf();
        InterpreterSemaphore sema = Interpreter.getSemaphore();
        Interpreter amie = sema.getThread(target);

        if (amie == myself) {
            throw new InterpreterException(StdErrors.An_actor_can_not_kill_himself);
        }

        if (amie != null) {
            if (!amie.isInterThread()) {
                throw new InterpreterException(StdErrors.An_actor_can_not_kill_supervisor);
            }
            sema.kill(amie);
        }
        /*
 
View Full Code Here

        }   
        Row row = new Row(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-sum [l1]...[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() && row.hasNext()) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(row.getNext());
                    argv_h.put(PCoder.ARGV, argv); // optimisation du 09/03/2012
                    xnode = enode.exec(true);
                }

                Heap.pull(); // supprimer l'espace local...
                Heap.pull(); // supprimer l'espace pour argv...
            }
            else if (btype.isPCode(PCoder.PC_LIST)) {
                /**
                 * (foreach-sum [l1]...[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() && row.hasNext()) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(row.getNext());
                    argv_h.put(PCoder.ARGV, argv); // optimisation du 09/03/2012
                    rnode = enode.exec(true);
                    if (rnode != null)
                        xnode.addElement(rnode.secure());
                   
                }

                Heap.pull(); // supprimer l'espace local...
                Heap.pull(); // supprimer l'espace de noms pour 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

  public Node eval(Node startAt) throws Exception {
        /*
         * forme (break-loop)
         */
    startAt.isGoodArgsCnt(1);
    Interpreter interpreter = Interpreter.mySelf();
    if (!(interpreter.isCanLoop() && interpreter.isTailNode())) {
      throw new InterpreterException(StdErrors.Break_loop_misplaced);
    }
    interpreter.setBreakCode(Interpreter.BREAKCODE_LOOP);
    interpreter.setCanLoop(false);
        interpreter.setInLoop(false);
    return null;

  }
View Full Code Here

   
    public Node eval(Node startAt) throws Exception {
        //System.out.println("FOREVER: "+startAt.toString());
        startAt.isGoodArgsCnt(2);
        Node enode = startAt.getSubNode(1, Node.TYPE_LAZY);
        Interpreter interpreter = Interpreter.mySelf();
        StaticHeap global = interpreter.getGLOBAL();
        boolean oldCanLoop = interpreter.isCanLoop();
        boolean oldInLoop = interpreter.isInLoop();
        interpreter.setCanLoop(true);
        interpreter.setInLoop(true);
        Node xnode = null;

        try {

            /*
             * 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.
             *   
             */
            global.push();
            Heap local = global.current();
           
            while (interpreter.isCanIterate() && xnode==null) {
                xnode = enode.exec(true);
                _clear_closure_(local);
            }
            global.pull();

        }
        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

        }
        if (in != null) {
            try {
                in.load();
                msrc = in.getSource();
                Interpreter interpreter = Interpreter.interpr_getNewChildInterpreter();
                //Register continue dans le même thread...
                Heap.push(); // mais en créant une closure
                interpreter.setSource(msrc);
                interpreter.compile();
                Heap.DynamicConstants.setMAIN_FALSE();
                if ((rnode = interpreter.getNode().exec(false)) != null) {
                    Interpreter.Log("Retour Import ??? " + rnode);
                }
                Heap.pull();

                // enregistrer le module
View Full Code Here

        Part permut = new Part(lNode.getArray());

        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-part [liste] 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() && permut.hasNext() && xnode==null) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(permut.getNext());
                    argv_h.put(PCoder.ARGV, argv);
                    xnode = enode.exec(true);
                }

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

            }
            else if (btype.isPCode(PCoder.PC_LIST)) {
                /**
                 * (foreach-part [liste] 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() && permut.hasNext()) {
                    _clear_closure_(local);
                    argv = Node.createCList();
                    argv.setArray(permut.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 de noms pour 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

         * formes: (forward)          : -> (return (invoke (select-first argv) (select-rest argv)) )
         *         (forward 'Methode) : -> (return (invoke 'Methode argv))
         *         (forward fonction) : -> (return (invoke fonction argv))
         */
        startAt.isGoodArgsCnt(1,2);
        Interpreter interpreter = Interpreter.mySelf();
       
        if ((!interpreter.isTerminalNode()) || interpreter.getCallerSignature() == 0) {
            // il ne devrait pas y avoir de signature GUID = 0...
            // si c'est le cas, c'est que qu'aucune fonction n'a été appelée...
            throw new InterpreterException(StdErrors.Delegate_misplaced);
        }
       
       
        /*
         * wrapper->forwarding en fonction de la forme syntaxique utilisée...
         */
        Node oldWrapper=interpreter.getWrapperFunction();
        interpreter.setWrapperFunction(interpreter.getThisFunction());
       
        Node rnode = null;
        if(startAt.size()==2){
            rnode=invoker(startAt.getSubNode(1,Node.TYPE_FUNCTION|Node.TYPE_QSYMBOL));  
        }
        else{
            rnode=invoker();
        }
      
        interpreter.setWrapperFunction(oldWrapper);
      
        /*
         * s'il y a un résultat... Return...
         */
        if (rnode != null) {
            try {
                Heap.setRETURN(rnode);
            }
            catch (Exception ex) {
                throw new InterpreterException(StdErrors.Delegate_return_register_error);
            }
        }
       
        /*
         * terminer comme !return...
         */
        if (interpreter.getBreakCode() != Interpreter.BREAKCODE_TAIL) {
            interpreter.setBreakCode(Interpreter.BREAKCODE_RETURN);
        }
        return null;
    }
View Full Code Here

                throw new InterpreterException(StdErrors.Syntax_error);
            }
            boolean untilLoop = modenode.isPCode(PCoder.PC_UNTIL);
            Node enode = startAt.getSubNode(1, Node.TYPE_LAZY);

            Interpreter interpreter = Interpreter.mySelf();
            StaticHeap global = interpreter.getGLOBAL();
            boolean oldCanLoop = interpreter.isCanLoop();
            boolean oldInLoop = interpreter.isInLoop();
            interpreter.setCanLoop(true);
            interpreter.setInLoop(true);
            //
            int href = global.size();
            int slock = global.getOffset();
           
            Heap local=new Heap();
            global.push(local);
            //
           
            /*
             * 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.
             *   
             */
            boolean loop = true;
            while (loop) {
                _clear_closure_(local);
                xnode = enode.exec(true);
                loop = xnode==null && interpreter.isCanIterate() && (untilLoop ? !xPC_Condition(local, cnode): xPC_Condition(local, cnode));
            }
            //
            global.pull();

            if (global.size() != href) {
                global.setOffset(slock);
                global.setSize(href); // restaurer le heap à la bonne taille
            }
            //
            interpreter.consumeBreakCode_onLoop();
            interpreter.setCanLoop(oldCanLoop);
            interpreter.setInLoop(oldInLoop);
            return xnode;

        }
        else {
            // forme (do {...} forever)
            modenode = startAt.getSubNode(2, Node.TYPE_PCODE);
            if (!modenode.isPCode(PCoder.PC_FOREVER)) {
                throw new InterpreterException(StdErrors.Syntax_error);
            }
        }
        Node enode = startAt.getSubNode(1, Node.TYPE_LAZY);
        Interpreter interpreter = Interpreter.mySelf();
        StaticHeap global = interpreter.getGLOBAL();
        boolean oldCanLoop = interpreter.isCanLoop();
        boolean oldInLoop = interpreter.isInLoop();
        interpreter.setCanLoop(true);
        interpreter.setInLoop(true);

        //
        int href = global.size();
        int slock = global.getOffset();
        //int tlock = global.getTailStack().getLock();


        // FERMETURE NECESSAIRE...
        //System.out.println("FOREVER: push...");
        global.push();
        Heap local=global.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 (xnode==null && interpreter.isCanIterate()) {
            _clear_closure_(local);
            xnode = enode.exec(true);
        }
        global.pull();


        //global.getTailStack().setLock(tlock); // restore la tail recursive Stack...
        if (global.size() != href) {
            global.setOffset(slock);
            global.setSize(href); // restaurer le heap à la bonne taille
        }
        //
        interpreter.consumeBreakCode_onLoop();
        interpreter.setCanLoop(oldCanLoop);
        interpreter.setInLoop(oldInLoop);
        return xnode;
    }
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.