version 1.2, 1999/11/02 13:09:19 |
version 1.5, 1999/11/04 18:24:16 |
|
|
/** |
/** |
* $OpenXM$ |
* $OpenXM: OpenXM/src/OpenMath/OMproxy.java,v 1.4 1999/11/04 18:21:42 tam Exp $ |
*/ |
*/ |
|
|
import JP.ac.kobe_u.math.tam.OpenXM.*; |
import JP.ac.kobe_u.math.tam.OpenXM.*; |
|
|
class OMproxy implements Runnable{ |
class OMproxy implements Runnable{ |
private OpenXM ox; |
private OpenXM ox; |
private Stack stack = new Stack(); |
private Stack stack = new Stack(); |
|
private boolean debug = true; |
|
|
public OMproxy(String host,int ControlPort,int DataPort) throws IOException{ |
public OMproxy(String host,int ControlPort,int DataPort) throws IOException{ |
ox = new OpenXM(this,host,ControlPort,DataPort); |
ox = new OpenXM(this,host,ControlPort,DataPort); |
Line 29 class OMproxy implements Runnable{ |
|
Line 30 class OMproxy implements Runnable{ |
|
|
|
case OpenXM.OX_DATA: |
case OpenXM.OX_DATA: |
stack.push(ox.receiveCMO()); |
stack.push(ox.receiveCMO()); |
System.out.println("push: "+ stack.peek()); |
debug("push: "+ stack.peek()); |
break; |
break; |
} |
} |
} |
} |
Line 64 class OMproxy implements Runnable{ |
|
Line 65 class OMproxy implements Runnable{ |
|
private void SM_executeFunction() throws java.io.IOException{ |
private void SM_executeFunction() throws java.io.IOException{ |
String function_name; |
String function_name; |
CMO[] argv; |
CMO[] argv; |
int argc; |
int argc = 1; |
|
|
if(!(stack.peek() instanceof CMO_STRING)){ |
if(!(stack.peek() instanceof CMO_STRING)){ |
stack.push(new CMO_ERROR2()); |
stack.push(new CMO_ERROR2()); |
return; |
return; |
} |
} |
function_name = ((CMO_STRING)stack.pop()).getString(); |
function_name = ((CMO_STRING)stack.pop()).getString(); |
argc = ((CMO_INT32)stack.pop()).intValue(); |
//argc = ((CMO_INT32)stack.pop()).intValue(); |
argv = new CMO[argc]; |
argv = new CMO[argc]; |
for(int i=0;i<argc;i++){ |
for(int i=0;i<argc;i++){ |
argv[i] = (CMO)stack.pop(); |
argv[i] = (CMO)stack.pop(); |
Line 95 class OMproxy implements Runnable{ |
|
Line 96 class OMproxy implements Runnable{ |
|
} |
} |
|
|
private void StackMachine(SM mesg) throws java.io.IOException{ |
private void StackMachine(SM mesg) throws java.io.IOException{ |
|
debug("receive: "+mesg); |
|
|
switch(mesg.getCode()){ |
switch(mesg.getCode()){ |
case SM.SM_popCMO: |
case SM.SM_popCMO: |
SM_popCMO(); |
SM_popCMO(); |
Line 121 class OMproxy implements Runnable{ |
|
Line 124 class OMproxy implements Runnable{ |
|
ByteArrayInputStream stream; |
ByteArrayInputStream stream; |
CMO ret; |
CMO ret; |
|
|
|
debug("OMXML2CMO called: "+obj); |
|
|
if(obj instanceof CMO_STRING){ |
if(obj instanceof CMO_STRING){ |
return new CMO_ERROR2(); |
return new CMO_ERROR2(); |
} |
} |
Line 132 class OMproxy implements Runnable{ |
|
Line 137 class OMproxy implements Runnable{ |
|
return new CMO_ERROR2(new CMO_STRING(e.toString())); |
return new CMO_ERROR2(new CMO_STRING(e.toString())); |
} |
} |
|
|
|
debug("push: "+ret); |
return ret; |
return ret; |
|
} |
|
|
|
private void debug(String str){ |
|
if(debug){ |
|
System.out.println(str); |
|
} |
} |
} |
|
|
private static String usage(){ |
private static String usage(){ |