Package abstrasy

Examples of abstrasy.Interpreter


        }
        Combin combinaisons = new Combin(lNode.getArray(), kn);

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

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

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


        Node cnode = startAt.getSubNode(1, Node.TYPE_LAZY);
        Node enode = startAt.getSubNode(3, Node.TYPE_LAZY);
        startAt.isGoodArgsCnt(4);
        Node xnode = null;
        Node rnode = null;
        Interpreter interpreter = Interpreter.mySelf();
        StaticHeap global = interpreter.getGLOBAL();
        boolean oldCanLoop = interpreter.isCanLoop();
        boolean oldInLoop = interpreter.isInLoop();
        interpreter.setCanLoop(true);
        interpreter.setInLoop(true);

        try {


            if (tcode.isPCode(PCoder.PC_DO)) {
                //

                // closure pour le corps
                abstrasy.Heap myClosure = new Heap();
                global.push(myClosure);
               
                /*
                 * 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() && !xPC_ConditionX(myClosure, cnode)) {
                    _clear_closure_(myClosure);
                    xnode = enode.exec(true);
                }
                global.pull();

            }
            else if (tcode.isPCode(PCoder.PC_LIST)) {
                /**
                 * boucle génératrice de listes.
                 *
                 * respecte la protection des listes finale.
                 *
                 * -> résultat jamais final.
                 *
                 */
                xnode = Node.createCList();
                //

                // closure pour le corps
                abstrasy.Heap myClosure = new Heap();

                global.push(myClosure);
                while (interpreter.isCanIterate() && !xPC_ConditionX(myClosure, cnode)) {
                     _clear_closure_(myClosure);
                    rnode = enode.exec(true);
                    if (rnode != null) xnode.addElement(rnode.secure());
                }
                global.pull();

            }
            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

     */
        if (i < startAt.size()) {
            throw new InterpreterException(StdErrors.Syntax_error);
        }

        Interpreter interpreter = Interpreter.interpr_getNewThreadInterpreter((nameNode == null ? null: nameNode.getString()));

        /*
         * En clonant functionNode, on évite la nécessité de synchronoser les accès à functionNode...
         */

        Node exnode = Node.createClone(functionNode);
        exnode.setType(Node.TYPE_EXPR);

        interpreter.setNode(exnode);
        interpreter.setInterpreterArgs(argv);
        interpreter.setOutputTextArea(Interpreter.mySelf().getOutputTextArea());
        interpreter.setLogTextArea(Interpreter.mySelf().getLogTextArea());

        interpreter.start();

        Node id_node = new Node(interpreter.getName());

        if (symbole != null) {
            // il y a un symbole...
            Heap.defv(symbole.getSymbol(), id_node);
            // statique...
View Full Code Here

   * @throws Exception
   * @todo Implémenter cette méthode abstrasy.PCFx
   */
  public Node eval(Node startAt) throws Exception {
    startAt.isGoodArgsCnt(1,2);
    Interpreter interpreter = Interpreter.mySelf();
    //Node rnode=null;
      //
    //System.out.println("Return getCallerSignature :" + interpreter.getCallerSignature());
    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.Return_misplaced);
    }
   
    if (startAt.size() == 2) {
      // s'il y a un résultat à retourner
      Node rnode=startAt.getSubNode(1,Node.VTYPE_VALUABLE);
      try{
        Heap.setRETURN(rnode);
      }
      catch(Exception ex){
        throw new InterpreterException(StdErrors.Return_register_error);
      }
    }
      //

    if(interpreter.getBreakCode()!=Interpreter.BREAKCODE_TAIL){
      interpreter.setBreakCode(Interpreter.BREAKCODE_RETURN);
    }
    return null;
  }
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(Interpreter.SHARED_INTERPRETER);
            if(!vnodes[i].isLockedBy(Interpreter.SHARED_INTERPRETER)){ 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

       
        Permut permut = new Permut(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-perm [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 argv...

            }
            else if (btype.isPCode(PCoder.PC_LIST)) {
                /**
                 * (foreach-perm [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 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

        /*
         * récupérer le message...
         */
        Node msg = startAt.getSubNode(1, Node.VTYPE_VALUABLE);
       
        Interpreter myself = Interpreter.mySelf();
       
        /*
         * On doit être dans une section (pending{...})
         */
        if(!myself.pendingMsg_HASQUEUE()){
            throw new InterpreterException(StdErrors.Illegal_operation_outside_pending_section);
        }
       
        /*
         * si ok, alors on postpose le message...
         */
        myself.pendingMsg_POSTPONE(msg);
       
       
        return null;
    }
View Full Code Here

        Node xnode = startAt.getSubNode(1, Node.TYPE_LAZY);


        Node res = null;
        Interpreter myself = Interpreter.mySelf();
        StaticHeap global = myself.getGLOBAL();
        InterpreterSemaphore sema = Interpreter.getSemaphore();

        Exception reportExcep = null;


        /*
         * l'acteur est-il déjà verrouillé ?
         */
        boolean dejaLock = myself.actor_ISMUTEX();

        /*
         * Adapter en fonction du verrouillage...
         */
        if (dejaLock) {
            // sema déjà verrouillé
            myself.actor_LOCKMUTEX();
        }
        else {
            sema.lockMutex();
            // inclu actor_LOCK();
        }


        /*
         * Nouveau contexte...
         */
        global.push();
       
        try {
            res = xnode.exec(true);
        }
        catch (Exception e) {
            reportExcep = e;
        }

        /*
         * restaurer le contexte
         */
        global.pull();
       
       
        /*
         * adapter en fonction du verrouillage...
         */
        if (dejaLock) {
            // sema de doit pas encore être déverrouillé...
            myself.actor_UNLOCKMUTEX();
        }
        else {
            sema.unlockMutex();
            // inclu actor_UNLOCK();
        }
View Full Code Here

       
        Circ permut = new Circ(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-circ [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 exclusif pour argv...

            }
            else if (btype.isPCode(PCoder.PC_LIST)) {
                /**
                 * (foreach-circ [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 exclusif 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

   * @throws Exception
   * @todo Implémenter cette méthode abstrasy.PCFx
   */
  public Node eval(Node startAt) throws Exception {
    startAt.isGoodArgsLength(true, 1);
    Interpreter interpreter = Interpreter.mySelf();
    if(interpreter.isCanLoop()==false){
      throw new InterpreterException(StdErrors.Complete_loop_misplaced);
    }
    interpreter.setCanLoop(false);
    interpreter.setInLoop(false);
    return null;

  }
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.