⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lisptask.java

📁 类似于Windows上的Excel
💻 JAVA
字号:
/*
 * MC2 -- j2me spreadsheet
 *
 * Copyright (c) 2004-2006 Michael Zemljanukha (mixaz@mail.ru)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package com.wapindustrial.calc;
import java.util.Vector;
import javax.microedition.lcdui.*;

/** Lisp code executor running in standalone thread. */
public class LispTask extends Thread {
    
    static LispTask LispMachine;
    
    public Displayable popMessage;
    
    LispTask() {}           // singleton, use LISP_MACHINE
    
    Vector commands = new Vector(5);        // of FunctorList - input commands
    boolean stop;                   		// true to stop
    
    public void putCommand( LispObject cmd ) {
        synchronized( commands ) {
            commands.addElement( cmd );
        }
    }
    
    public void run() {
    	stop = false;
        while( !stop ) {
            if( commands.size() > 0 ) {
                LispObject lo = (LispObject) commands.elementAt(0);
                synchronized( commands ) {
                    commands.removeElementAt( 0 );
                }
                try {
                    // debug
                    if( CanvasHandler1.debugLevel != 0 )
                        LispObject.debug( "Executing s-exp: " + lo.toString() );
//#ifndef NO_REGULAR_GC                    
                    System.gc();
//#endif                    
                    popMessage = null;
                    lo.interpret();
                    if(popMessage!=null) {
                        if(popMessage instanceof Alert)
                            CanvasHandler1.canvasHandler.display.setCurrent( (Alert)popMessage,CanvasHandler1.canvasHandler.canvas );
                        else 
                            CanvasHandler1.setDisplay( popMessage );
                    }
                }
                catch( Exception ee ) {
                    // This handles EvaluateException if occures when creating InputForm,
                	// or any other exception.
                	// EvaluateException after user input is handled in ExecuteAssigment(), inside InputForm
                    LispObject.debug( "Exception in LispTask:" );
                    LispObject.debug( ee.getMessage() );
                    ee.printStackTrace();
                    Alert al = new Alert( "Error", ee.getMessage(), null, AlertType.ERROR );
                    al.setTimeout( Alert.FOREVER );
                    CanvasHandler1.setDisplay(al);
                }
                yield();
            }
            else {
                try {
                    sleep( 100 );
                }
                catch( InterruptedException ee ) {
                }
            }
        }
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -