home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / fp1os2.arj / OS2 / DATA / 49 / C / 0 / F_26836 / JScriptMethod.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-05-15  |  4.3 KB  |  151 lines

  1. public class JScriptMethod extends JScriptConstructor {
  2.    private JScriptModule aParentModule;
  3.    private boolean bModuleCodeFunction;
  4.    private String aName;
  5.    private JScriptCodeBlock aCodeBlock;
  6.    private JScriptTokenPosition aSourceCodePos;
  7.    private String[] aParameterList;
  8.    private String[] aLocalVarList;
  9.    public JSbxValueProperty[] aLocalVarPropBuffer;
  10.    private JSbxVector aLocalVarVector;
  11.    public boolean bHasLengthAsParam;
  12.    public JScriptCallLevelInstance pPropUser;
  13.    public JSbxObjectProperty[] aObjectPropBuffer;
  14.    public JSbxValueProperty[] aValuePropBuffer;
  15.  
  16.    public JScriptModule GetModule() {
  17.       return this.aParentModule;
  18.    }
  19.  
  20.    public boolean IsModuleCodeFunction() {
  21.       return this.bModuleCodeFunction;
  22.    }
  23.  
  24.    public String GetName() {
  25.       return this.aName;
  26.    }
  27.  
  28.    public JScriptCodeBlock GetCodeBlock() {
  29.       return this.aCodeBlock;
  30.    }
  31.  
  32.    public void SetCodeBlock(JScriptCodeBlock var1) {
  33.       this.aCodeBlock = var1;
  34.    }
  35.  
  36.    public void SetSourceCodePos(JScriptTokenPosition var1) {
  37.       this.aSourceCodePos = var1;
  38.    }
  39.  
  40.    public String[] GetParameterList() {
  41.       return this.aParameterList;
  42.    }
  43.  
  44.    public String[] GetLocalVarList() {
  45.       return this.aLocalVarList;
  46.    }
  47.  
  48.    public JSbxVector GetLocalVarVector() {
  49.       if (this.aLocalVarVector == null) {
  50.          this.aLocalVarVector = new JSbxVector();
  51.       }
  52.  
  53.       return this.aLocalVarVector;
  54.    }
  55.  
  56.    public void LocalVarDefFinished() {
  57.       if (this.aLocalVarVector != null) {
  58.          int var1 = this.aLocalVarVector.GetSize();
  59.          if (var1 > 0) {
  60.             this.aLocalVarList = new String[var1];
  61.             this.aLocalVarPropBuffer = new JSbxValueProperty[var1];
  62.  
  63.             for(int var2 = 0; var2 < var1; ++var2) {
  64.                String var3 = (String)this.aLocalVarVector.Get(var2);
  65.                this.aLocalVarList[var2] = var3;
  66.                this.aLocalVarPropBuffer[var2] = new JSbxValueProperty(var3, this, (JSbxValue)null);
  67.             }
  68.          }
  69.  
  70.          this.aLocalVarVector = null;
  71.       }
  72.    }
  73.  
  74.    public void SetParameterList(String[] var1) {
  75.       this.aParameterList = var1;
  76.       this.bHasLengthAsParam = false;
  77.       this.pPropUser = null;
  78.       if (this.aParameterList != null) {
  79.          int var2 = this.aParameterList.length;
  80.          this.aObjectPropBuffer = new JSbxObjectProperty[var2];
  81.          this.aValuePropBuffer = new JSbxValueProperty[var2];
  82.  
  83.          for(int var3 = 0; var3 < var2; ++var3) {
  84.             if (this.aParameterList[var3].equals("length")) {
  85.                this.bHasLengthAsParam = true;
  86.             }
  87.  
  88.             this.aObjectPropBuffer[var3] = new JSbxObjectProperty(this.aParameterList[var3], this, (JSbxPropertyInterface)null, var3);
  89.             this.aValuePropBuffer[var3] = new JSbxValueProperty(this.aParameterList[var3], this, (JSbxValue)null);
  90.          }
  91.       }
  92.  
  93.    }
  94.  
  95.    protected JScriptMethod(JScriptModule var1, String var2, JScriptConstructor var3) {
  96.       this(var1, var2, new JScriptCodeBlock(), var3);
  97.       this.bModuleCodeFunction = false;
  98.    }
  99.  
  100.    public JScriptMethod(JScriptModule var1, String var2) {
  101.       this(var1, var2, new JScriptCodeBlock(), (JScriptConstructor)null);
  102.       this.bModuleCodeFunction = false;
  103.    }
  104.  
  105.    public JScriptMethod(JScriptModule var1, JScriptCodeBlock var2) {
  106.       this(var1, (String)null, var2, (JScriptConstructor)null);
  107.       this.bModuleCodeFunction = true;
  108.    }
  109.  
  110.    protected JScriptMethod(JScriptModule var1, String var2, JScriptCodeBlock var3, JScriptConstructor var4) {
  111.       super(var4);
  112.       this.aParentModule = var1;
  113.       this.aName = var2;
  114.       this.aCodeBlock = var3;
  115.       this.aParameterList = null;
  116.       this.aLocalVarList = null;
  117.    }
  118.  
  119.    public JSbxValue CallFunction(JScriptCallParam var1) throws JSbxExceptionBase {
  120.       var1.GetRuntimeParam().GetRuntimeInst().ExecuteFunction(this, var1);
  121.       return var1.GetRuntimeParam().GetReturnValue();
  122.    }
  123.  
  124.    public JSbxProperty Get(String var1, boolean var2) {
  125.       if (!var2) {
  126.          JScriptCallLevelInstance var3 = JScriptManager.GetMyActCallLevelInst();
  127.          JSbxProperty var4 = var3 != null ? var3.GetLocalVarObject().Get(var1, false) : null;
  128.          if (var4 != null) {
  129.             return var4;
  130.          }
  131.       }
  132.  
  133.       return super.Get(var1, var2);
  134.    }
  135.  
  136.    public JSbxProperty Get(int var1, boolean var2) {
  137.       JScriptCallLevelInstance var3 = JScriptManager.GetMyActCallLevelInst();
  138.       JScriptArgumentsObject var4 = var3.GetArgumentsObject();
  139.       return var4 != null && var1 < var4.GetParamCount() && var3.GetMethod() == this ? ((JSbxObject)var3).Get(var1, false) : super.Get(var1, var2);
  140.    }
  141.  
  142.    public String GetJScriptString(boolean var1) {
  143.       return this.GetSourceCode();
  144.    }
  145.  
  146.    private final String GetSourceCode() {
  147.       String var1 = this.GetModule().GetSource();
  148.       return var1.substring(this.aSourceCodePos.GetStartPos(), this.aSourceCodePos.GetEndPos());
  149.    }
  150. }
  151.