home *** CD-ROM | disk | FTP | other *** search
- import java.io.PrintStream;
- import stardiv.tools.HoldJavaEnvironment;
-
- class JScriptRuntimeInstance extends JSbxObject implements Runnable {
- private JScriptScheduler aMyTask;
- public JScriptRunParam aRP;
- private int nError;
- private boolean bDbgFlag;
- private boolean bPushExtThisObjs;
- private boolean bDoUpdateBrowser;
- private int nStatementCount;
- private String aActDebugSource;
- private int nLastPC;
- private String aLastMethodName;
- private JSbxObject aThisObj;
- private boolean bWatchdogBreak;
- private boolean bSuspendExecution;
- private boolean bSpecialFlag;
- private boolean bDebuggingActive;
- private boolean bBreak;
- private boolean bStepOver;
- private int nStepOverCallLevel;
- private boolean bStepOut;
- private int nStepOutCallLevel;
- private boolean bSingleSourceStep;
- private boolean bSinglePCodeStep;
- public boolean bThreadRunning;
- private Thread aRTIThread;
- private boolean bDbgContinue;
- private JScriptTokenPosition aSourceCodePosition;
- private JScriptModule aRunModule;
- private JScriptCodeBlock aActCodeBlock;
- private SJMessage aMessageToAck;
- private boolean bRunAsThread;
- private JScriptManager aJScriptManager;
- private JScriptExpressionStack aExpressionStack;
- private JSbxValue aReturnValue;
- private JSbxValue aLastExpression;
- private JScriptCallStack aCallStack;
- private int nCallLevel;
- private JScriptCallLevelInstance aActualCallLevelInst;
- private JScriptRuntimeParam aActualRuntimeParam;
- private JScriptDebugInterface aDebugInterface;
- private SJMessageHandlerInterface aMessageInterface;
- PrintStream aDebugOutStream;
- private JScriptBreakHandler aBreakHandler;
-
- public final int GetErrorCode() {
- return this.nError;
- }
-
- public final int GetStatementCount() {
- return this.nStatementCount;
- }
-
- public final void IncStatementCount() {
- ++this.nStatementCount;
- }
-
- public final void SetActDebugSource(String var1) {
- this.aActDebugSource = var1;
- }
-
- public final String GetActDebugSource() {
- return this.aActDebugSource;
- }
-
- public final int GetLastPC() {
- return this.nLastPC;
- }
-
- public final void SetLastPC(int var1) {
- this.nLastPC = var1;
- }
-
- public final String GetLastMethodName() {
- return this.aLastMethodName;
- }
-
- public final void SetLastMethodName(String var1) {
- this.aLastMethodName = var1;
- }
-
- public void SetThisObj(JSbxObject var1) {
- this.aThisObj = var1;
- }
-
- public JSbxObject GetThisObj() {
- return this.aThisObj;
- }
-
- public final void SetDebugFlag() {
- this.bDebuggingActive = true;
- this.bSpecialFlag = true;
- }
-
- public final void ClearDebugFlag() {
- this.bDebuggingActive = false;
- this.bSpecialFlag = false;
- }
-
- public final boolean IsDebuggingActive() {
- return this.bDebuggingActive;
- }
-
- public final void SetBreakFlag() {
- this.bBreak = true;
- }
-
- public final void ClearBreakFlag() {
- this.bBreak = false;
- }
-
- public final boolean IsBreak() {
- return this.bBreak;
- }
-
- public final void SetStepOverFlag() {
- this.bStepOver = true;
- this.nStepOverCallLevel = this.nCallLevel;
- if (this.nStepOverCallLevel == 0) {
- this.nStepOverCallLevel = 1;
- }
-
- }
-
- public final void ClearStepOverFlag() {
- this.bStepOver = false;
- this.nStepOverCallLevel = 0;
- }
-
- public final boolean IsStepOver() {
- return this.bStepOver;
- }
-
- public final int GetStepOverCallLevel() {
- return this.nStepOverCallLevel;
- }
-
- public final void SetStepOutFlag() {
- this.bStepOut = true;
- this.nStepOutCallLevel = this.nCallLevel - 1;
- if (this.nStepOutCallLevel < 1) {
- this.nStepOutCallLevel = 1;
- }
-
- }
-
- public final void ClearStepOutFlag() {
- this.bStepOut = false;
- this.nStepOutCallLevel = 0;
- }
-
- public final boolean IsStepOut() {
- return this.bStepOut;
- }
-
- public final int GetStepOutCallLevel() {
- return this.nStepOutCallLevel;
- }
-
- public final void SetSingleSourceStepFlag() {
- this.bSingleSourceStep = true;
- }
-
- public final void ClearSingleSourceStepFlag() {
- this.bSingleSourceStep = false;
- }
-
- public final boolean IsSingleSourceStep() {
- return this.bSingleSourceStep;
- }
-
- public final void SetSinglePCodeStepFlag() {
- this.bSinglePCodeStep = true;
- }
-
- public final void ClearSinglePCodeStepFlag() {
- this.bSinglePCodeStep = false;
- }
-
- public final boolean IsSinglePCodeStep() {
- return this.bSinglePCodeStep;
- }
-
- private final boolean IsCallInPCodeStepOver(JScriptPCode var1) {
- return this.IsSinglePCodeStep() && this.IsStepOver() && var1 instanceof JSP_Call;
- }
-
- public final synchronized boolean IsThreadRunning() {
- return this.bThreadRunning;
- }
-
- public final synchronized void WaitForThreadReady() {
- try {
- while(!this.bThreadRunning) {
- this.wait();
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- public final synchronized void WaitForThreadEnd() {
- if (!this.bThreadRunning) {
- this.WaitForThreadReady();
- }
-
- try {
- while(this.bThreadRunning) {
- this.wait();
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- private final synchronized void ClearThreadRunningFlag() {
- this.bThreadRunning = false;
- this.notifyAll();
- }
-
- private final synchronized void SetThreadRunningFlag() {
- this.bThreadRunning = true;
- this.notifyAll();
- }
-
- public final Thread GetThread() {
- return this.aRTIThread;
- }
-
- public final synchronized void SetDebugContinueFlag() {
- this.bDbgContinue = true;
- this.notifyAll();
- }
-
- public final synchronized void ClearDebugContinueFlag() {
- this.bDbgContinue = false;
- this.notifyAll();
- }
-
- public final boolean IsSleeping() {
- return !this.bDbgContinue;
- }
-
- public final JScriptTokenPosition GetSourceCodePosition() {
- return this.aSourceCodePosition;
- }
-
- public final void SetSourceCodePosition(JScriptTokenPosition var1) {
- this.aSourceCodePosition = var1;
- }
-
- public final void SetModule(JScriptModule var1) {
- this.aRunModule = var1;
- }
-
- public final JScriptModule GetModule() {
- return this.aRunModule;
- }
-
- public final void SetCodeBlock(JScriptCodeBlock var1) {
- this.aActCodeBlock = var1;
- }
-
- public final void SetCodeBlock(JScriptCodeBlock var1, String var2) {
- this.aActCodeBlock = var1;
- this.aActCodeBlock.SetIDString(var2);
- }
-
- public final JScriptCodeBlock GetCodeBlock() {
- return this.aActCodeBlock;
- }
-
- public final void SetMessageToAcknowledge(SJMessage var1) {
- this.aMessageToAck = var1;
- }
-
- public final void SetRTIAsThread() {
- this.bRunAsThread = true;
- }
-
- public final void SetRTIAsProcess() {
- this.bRunAsThread = false;
- }
-
- public final boolean IsRTIaThread() {
- return this.bRunAsThread;
- }
-
- public final JScriptManager GetJSManager() {
- return this.aJScriptManager;
- }
-
- public JScriptExpressionStack GetExpressionStack() {
- return this.aExpressionStack;
- }
-
- public JSbxValue GetReturnValue() {
- return this.aReturnValue;
- }
-
- public void SetReturnValue(JSbxValue var1) {
- this.aReturnValue = var1;
- }
-
- public JSbxValue GetLastExpression() {
- return this.aLastExpression;
- }
-
- public void SetLastExpression(JSbxValue var1) {
- this.aLastExpression = var1;
- }
-
- public final int DEBUG_GetCallLevel() {
- return this.nCallLevel;
- }
-
- public JScriptCallLevelInstance GetActualCallLevelInst() {
- return this.aActualCallLevelInst;
- }
-
- public final JScriptRuntimeParam GetActualRuntimeParam() {
- return this.aActualRuntimeParam;
- }
-
- public JScriptDebugInterface GetDebugInterface() {
- return this.aDebugInterface;
- }
-
- public void SetDebugInterface(JScriptDebugInterface var1) {
- this.aDebugInterface = var1;
- }
-
- public SJMessageHandlerInterface GetMessageHandlerInterface() {
- return this.aMessageInterface;
- }
-
- public void SetMessageHandlerInterface(SJMessageHandlerInterface var1) {
- this.aMessageInterface = var1;
- }
-
- public void SetDebugStream(PrintStream var1) {
- this.aDebugOutStream = var1;
- }
-
- public void SetBreakHandler(JScriptBreakHandler var1) {
- this.aBreakHandler = this.aBreakHandler;
- }
-
- public JScriptRuntimeInstance(JScriptManager var1, boolean var2, boolean var3, JScriptScheduler var4, JScriptRunParam var5) {
- this.Init();
- this.aMyTask = var4;
- this.aRP = var5;
- this.bWatchdogBreak = this.aRP != null ? this.aRP.bStoped : false;
- this.bSuspendExecution = this.aRP != null ? this.aRP.bStoped : false;
- this.bSpecialFlag = false;
- this.bDbgFlag = var2;
- this.bPushExtThisObjs = var3;
- this.aThisObj = null;
- this.aJScriptManager = var1;
- }
-
- private void Init() {
- this.aExpressionStack = new JScriptExpressionStack();
- this.aCallStack = new JScriptCallStack();
- this.nCallLevel = 0;
- this.nStepOverCallLevel = 0;
- this.nStepOutCallLevel = 0;
- this.aActualRuntimeParam = new JScriptRuntimeParam(this);
- this.aMyTask = null;
- this.aDebugInterface = null;
- this.aMessageInterface = null;
- this.aBreakHandler = null;
- this.aRunModule = null;
- this.aActCodeBlock = null;
- this.aSourceCodePosition = null;
- this.aRTIThread = null;
- this.aMessageToAck = null;
- this.aReturnValue = null;
- this.nError = 0;
- this.nStatementCount = 0;
- this.SetLastPC(-1);
- this.SetRTIAsProcess();
- }
-
- private int RunModule(JScriptModule var1) {
- this.InitRunData();
-
- try {
- JSbxObject var2 = this.aJScriptManager.GetRootObject();
- String[] var10 = var1.GetGlobalVarList();
- if (var10 != null) {
- int var4 = var10.length;
-
- for(int var5 = 0; var5 < var4; ++var5) {
- JSbxValueProperty var6 = new JSbxValueProperty(var10[var5], var2);
- ((JSbxBase)var6).SetFlag(4);
-
- try {
- var2.Put(var6);
- } catch (JSbxException var8) {
- if (((JSbxExceptionBase)var8).GetError() != 4714) {
- throw var8;
- }
- }
- }
- }
-
- JScriptMethod var11 = new JScriptMethod(var1, var1.GetCodeBlock());
- this.ExecuteFunction(var11, new JScriptCallParam((JScriptRuntimeParam)null, (JSbxVector)null, this.GetThisObj()));
- return 0;
- } catch (Throwable var9) {
- String var3 = "Runtime-Error: " + var9.getMessage();
- if (this.aDebugOutStream != null) {
- this.aDebugOutStream.println(var3);
- } else {
- System.out.println(var3);
- }
-
- HoldJavaEnvironment.AddToProtocol(var3 + " #dbg-stmt=" + this.GetStatementCount());
- HoldJavaEnvironment.AddToProtocol("source: " + this.GetActDebugSource());
- HoldJavaEnvironment.AddToProtocol("--> #PC=" + this.GetLastPC() + " method=" + this.GetLastMethodName());
- HoldJavaEnvironment.ShowExceptionStack(var9);
- if (this.aJScriptManager != null) {
- this.aJScriptManager.SetLastError("" + var9 + "\n" + "Error in source: " + this.GetActDebugSource());
- }
-
- return -1;
- }
- }
-
- public void ExecuteFunction(JScriptMethod var1, JScriptCallParam var2) throws JSbxExceptionBase {
- String var3 = this.GetLastMethodName();
- this.SetLastMethodName(var1.GetName());
- if (this.nCallLevel < this.aCallStack.GetSize()) {
- this.aActualCallLevelInst = (JScriptCallLevelInstance)this.aCallStack.Get(this.nCallLevel);
- } else {
- this.aActualCallLevelInst = new JScriptCallLevelInstance(this, this.nCallLevel + 1);
- this.aCallStack.Push(this.aActualCallLevelInst);
- }
-
- this.aActualCallLevelInst.InitCall(var1, var2, this.bPushExtThisObjs);
- this.bPushExtThisObjs = false;
- ++this.nCallLevel;
- JScriptModule var4 = this.GetModule();
- JScriptModule var5 = var1.GetModule();
- this.SetModule(var5);
- JScriptCodeBlock var6 = this.GetCodeBlock();
- this.SetCodeBlock(var1.GetCodeBlock(), var1.GetName());
- this.ExecuteCodeBlock(this.aActCodeBlock);
- this.aActualCallLevelInst.DeInitCall();
- this.SetModule(var4);
- this.SetCodeBlock(var6);
- --this.nCallLevel;
- if (this.nCallLevel > 0) {
- this.aActualCallLevelInst = (JScriptCallLevelInstance)this.aCallStack.Get(this.nCallLevel - 1);
- }
-
- this.SetLastMethodName(var3);
- }
-
- public void ExecuteRuntimeCreatedModule(JScriptModule var1, boolean var2) throws JSbxExceptionBase {
- if (var2) {
- this.ExecuteRuntimeCreatedModule(var1);
- } else {
- this.ExecuteCodeBlock(var1.GetCodeBlock(), false);
- }
- }
-
- public void ExecuteRuntimeCreatedModule(JScriptModule var1) throws JSbxExceptionBase {
- JScriptModule var2 = this.GetModule();
- this.SetModule(var1);
- JScriptCodeBlock var3 = this.GetCodeBlock();
- if (this.IsDebuggingActive()) {
- this.PCodeChangedCallback(var1.GetCodeBlock());
- }
-
- this.SetCodeBlock(var1.GetCodeBlock(), var1.GetName());
- this.ExecuteCodeBlock(this.aActCodeBlock);
- this.SetModule(var2);
- this.SetCodeBlock(var3);
- if (this.IsDebuggingActive()) {
- this.PCodeChangedCallback(var3);
- }
-
- }
-
- public void ExecuteCodeBlock(JScriptCodeBlock var1) throws JSbxExceptionBase {
- this.ExecuteCodeBlock(var1, true);
- }
-
- public final void StopExecution() {
- HoldJavaEnvironment.SetNoCallThreadId(JScriptScheduler.getJScriptThreadId());
- this.bSpecialFlag = true;
- this.bWatchdogBreak = true;
- }
-
- public final synchronized void SuspendExecution() {
- this.bSpecialFlag = true;
- this.bSuspendExecution = true;
- }
-
- private final void ProcessPendingTasks() {
- JScriptScheduler.DoExecute((JScriptScheduler)null);
- this.bSpecialFlag = false;
- this.bSuspendExecution = false;
- }
-
- public void ExecuteCodeBlock(JScriptCodeBlock var1, boolean var2) throws JSbxExceptionBase {
- boolean var3 = true;
- int var4 = 0;
- int var5 = -1;
- Object[] var6 = var1.getPCodeArray();
-
- try {
- do {
- JScriptPCode var7 = (JScriptPCode)var6[var4];
- if (this.bSpecialFlag) {
- if (this.bWatchdogBreak) {
- throw new JSbxException(-99, "user break");
- }
-
- if (this.bSuspendExecution) {
- this.ProcessPendingTasks();
- if (this.bWatchdogBreak) {
- throw new JSbxException(-99, "user break");
- }
-
- var5 = var7.Execute(this.aActualRuntimeParam);
- } else if (this.bDebuggingActive) {
- boolean var8 = this.IsCallInPCodeStepOver(var7);
- if (var2 && this.IsSinglePCodeStep() && !var8 && this.aDebugInterface != null) {
- this.CreateCallback(var4, var7);
- }
-
- if (var8) {
- this.ClearSinglePCodeStepFlag();
- }
-
- if (this.IsBreak()) {
- break;
- }
-
- var5 = var7.Execute(this.aActualRuntimeParam);
- if (var5 == -3) {
- ++var4;
- if (var2 && this.IsDebuggingActive() && this.aDebugInterface != null) {
- this.CreateCallback(var4, var7);
- }
- }
-
- if (var8) {
- this.SetSinglePCodeStepFlag();
- }
- }
- } else {
- var5 = var7.Execute(this.aActualRuntimeParam);
- }
-
- if (var5 == -1) {
- ++var4;
- } else if (var5 > 0) {
- var4 = var5;
- } else if (var5 == -2) {
- var3 = false;
- }
- } while(var3);
-
- } catch (ArrayIndexOutOfBoundsException var9) {
- this.SetLastPC(var4);
- throw new JSbxException(-42, "invalid P-Code (null)");
- } catch (NullPointerException var10) {
- this.SetLastPC(var4);
- throw new JSbxException(-42, "invalid P-Code (null)");
- } catch (JSbxExceptionBase var11) {
- this.SetLastPC(var4);
- throw var11;
- }
- }
-
- private final void CreateCallback(int var1, JScriptPCode var2) {
- JScriptAction var3 = new JScriptAction(5000, 6);
- var3.SetSourceObject(this);
- var3.SetInteger(var1);
- ((SJMessage)var3).SetObject(0, var2);
- ((SJMessage)var3).SetObject(1, this.aActualRuntimeParam.GetStack().DEBUG_GetInfoString());
- ((SJMessage)var3).SetObject(2, this.aActualRuntimeParam.GetRuntimeInst().aCallStack.DEBUG_GetInfoString(this.nCallLevel));
- ((SJMessage)var3).SetObject(3, this.GetSourceCodePosition());
- ((SJMessage)var3).SetObject(4, this.GetModule());
- ((SJMessage)var3).SetObject(5, this.GetCodeBlock());
- this.aJScriptManager.Browser_DirectShowInfos();
- this.aDebugInterface.HandleMessage(var3);
- this.WaitForDebugger();
- }
-
- private final void PCodeChangedCallback(JScriptCodeBlock var1) {
- JScriptAction var2 = new JScriptAction(213, 1);
- var2.SetSourceObject(this);
- ((SJMessage)var2).SetObject(0, var1);
- this.aDebugInterface.HandleMessage(var2);
- }
-
- public void run() {
- Object var1 = null;
- Object var2 = JScriptScheduler.aInUse;
- synchronized(var2){}
-
- try {
- if (JScriptScheduler.pWaitForRTI != this.aMyTask) {
- return;
- }
-
- var15 = JScriptScheduler.SetActRTI(this);
- } catch (Throwable var14) {
- throw var14;
- }
-
- if (this.bDbgFlag) {
- try {
- HoldJavaEnvironment.StartChangeThread_Monitor();
- } catch (UnsatisfiedLinkError var13) {
- }
- }
-
- this.nError = 0;
- this.aRTIThread = Thread.currentThread();
- this.SetThreadRunningFlag();
- boolean var3 = this.aRP != null ? this.aRP.aMethodProp != null : false;
- if (this.aRunModule != null && !var3) {
- if (this.aDebugInterface != null) {
- short var16;
- if (this.IsRTIaThread()) {
- var16 = 1014;
- } else {
- var16 = 1008;
- }
-
- JScriptAction var20 = new JScriptAction(var16, this, (Object)null);
- this.aDebugInterface.HandleMessage(var20);
- } else if (this.aMessageInterface != null) {
- short var17;
- if (this.IsRTIaThread()) {
- var17 = 217;
- } else {
- var17 = 202;
- }
-
- JScriptAction var21 = new JScriptAction(var17, this, (Object)null);
- this.aMessageInterface.HandleMessage(var21);
- }
-
- this.nError = this.RunModule(this.aRunModule);
- } else if (this.aRP != null) {
- JSbxValue var4 = null;
- JScriptCallParam var5 = new JScriptCallParam(this.GetActualRuntimeParam(), this.aRP.aParamVector, this.aRP.aThisObj);
-
- try {
- if (this.aRP.aMethodProp != null) {
- var4 = this.aRP.aMethodProp.CallFunction(var5);
- }
- } catch (Throwable var12) {
- HoldJavaEnvironment.AddToProtocol("RTI call() LiveConnect Exception=" + var12);
- }
-
- this.SetLastExpression(var4);
- this.nError = 0;
- } else {
- this.nError = -11;
- }
-
- if (this.aDebugInterface != null) {
- short var18;
- if (this.IsRTIaThread()) {
- var18 = 1013;
- } else {
- var18 = 1007;
- }
-
- JScriptAction var22 = new JScriptAction(var18, this, this);
- this.aDebugInterface.HandleMessage(var22);
- } else if (this.aMessageInterface != null) {
- short var19;
- if (this.IsRTIaThread()) {
- var19 = 218;
- } else {
- var19 = 203;
- }
-
- JScriptAction var23 = new JScriptAction(var19, this, this);
- this.aMessageInterface.HandleMessage(var23);
- }
-
- if (this.aMessageToAck != null) {
- this.aMessageToAck.Acknowledge();
- }
-
- this.ClearThreadRunningFlag();
- if (this.bDbgFlag) {
- try {
- HoldJavaEnvironment.EndChangeThread_Monitor();
- if (this.aMessageInterface != null) {
- this.aMessageInterface.HandleMessage(new JScriptAction(220, this, this));
- }
- } catch (UnsatisfiedLinkError var11) {
- }
- }
-
- JScriptRuntimeInstance var24 = JScriptScheduler.SetActRTI(var15);
- if (var24 != this) {
- HoldJavaEnvironment.AddToProtocol("@@@@ ERROR in RTI - Verwaltung " + this + " != " + var24);
- }
-
- }
-
- public synchronized void YieldBrowser() {
- this.bDoUpdateBrowser = true;
- this.notifyAll();
- }
-
- private synchronized void WaitForDebugger() {
- this.ClearDebugContinueFlag();
- this.bDoUpdateBrowser = false;
-
- try {
- while(!this.bDbgContinue) {
- this.wait();
- if (this.bDoUpdateBrowser) {
- this.bDoUpdateBrowser = false;
- this.aJScriptManager.Browser_DirectShowInfos();
- JScriptAction var1 = new JScriptAction(221, this, this);
- if (this.aDebugInterface != null) {
- this.aDebugInterface.HandleMessage(var1);
- } else if (this.aMessageInterface != null) {
- this.aMessageInterface.HandleMessage(var1);
- }
- }
- }
-
- } catch (InterruptedException var2) {
- }
- }
-
- private void InitRunData() {
- this.aSourceCodePosition = null;
- }
- }
-