org.eclipse.wst.jsdt.debug.rhino_1.0.101.v201201112313

16:49:10.604 INFO  jd.cli.Main - Decompiling org.eclipse.wst.jsdt.debug.rhino_1.0.101.v201201112313.jar
package org.eclipse.wst.jsdt.debug.internal.rhino;

public abstract interface Constants
{
  public static final String SPACE = " ";
  public static final String URI_FILE_SCHEME = "file";
  public static final String STD_IN = "stdin";
  public static final String STD_IN_URI = "<stdin>";
  public static final String SUSPEND_ON_STDIN_LOAD = "org.eclipse.wst.jsdt.debug.rhino.suspend_on_stdin_load";
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.Constants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino;

import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;

public class RhinoDebugPlugin
  extends Plugin
{
  public static final int INTERNAL_ERROR = 120;
  public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.debug.rhino";
  private static RhinoDebugPlugin plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static RhinoDebugPlugin getDefault()
  {
    return plugin;
  }
  
  public static void log(IStatus status)
  {
    if (plugin != null) {
      plugin.getLog().log(status);
    }
  }
  
  public static void log(Throwable t)
  {
    log(newErrorStatus("Error logged from Rhino Debug: ", t));
  }
  
  public static void logErrorMessage(String message)
  {
    log(newErrorStatus("Internal message logged from Rhino Debug: " + message, null));
  }
  
  public static IStatus newErrorStatus(String message, Throwable exception)
  {
    return new Status(4, "org.eclipse.wst.jsdt.debug.rhino", 120, message, exception);
  }
  
  public static URI fileURI(IPath path)
    throws URISyntaxException
  {
    return new URI("file", null, path.makeAbsolute().toString(), null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.RhinoDebugPlugin
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.osgi.service.prefs.BackingStoreException;

public class RhinoPreferenceInitializer
  extends AbstractPreferenceInitializer
{
  public void initializeDefaultPreferences()
  {
    IEclipsePreferences defaultscope = new DefaultScope().getNode("org.eclipse.wst.jsdt.debug.rhino");
    defaultscope.putBoolean("org.eclipse.wst.jsdt.debug.rhino.suspend_on_stdin_load", false);
    try
    {
      defaultscope.flush();
    }
    catch (BackingStoreException e)
    {
      RhinoDebugPlugin.log(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.RhinoPreferenceInitializer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;

public class RhinoPreferencesManager
  implements IEclipsePreferences.IPreferenceChangeListener
{
  public void start()
  {
    IEclipsePreferences node = new InstanceScope().getNode("org.eclipse.wst.jsdt.debug.rhino");
    if (node != null) {
      node.addPreferenceChangeListener(this);
    } else {
      RhinoDebugPlugin.logErrorMessage("The Rhino core preference node could not loaded");
    }
  }
  
  public void stop()
  {
    IEclipsePreferences node = new InstanceScope().getNode("org.eclipse.wst.jsdt.debug.rhino");
    if (node != null) {
      node.removePreferenceChangeListener(this);
    } else {
      RhinoDebugPlugin.logErrorMessage("The Rhino core preference node could not loaded");
    }
  }
  
  public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) {}
  
  public static boolean suspendOnStdinLoad()
  {
    return Platform.getPreferencesService().getBoolean("org.eclipse.wst.jsdt.debug.rhino", "org.eclipse.wst.jsdt.debug.rhino.suspend_on_stdin_load", false, null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.RhinoPreferencesManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.breakpoints;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpointParticipant;
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptPrimitiveValue;
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread;
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
import org.eclipse.wst.jsdt.debug.internal.rhino.RhinoPreferencesManager;

public class RhinoBreakpointParticipant
  implements IJavaScriptBreakpointParticipant
{
  public int breakpointHit(IJavaScriptThread thread, IJavaScriptBreakpoint breakpoint)
  {
    try
    {
      if ((breakpoint instanceof IJavaScriptLineBreakpoint))
      {
        IJavaScriptLineBreakpoint lbp = (IJavaScriptLineBreakpoint)breakpoint;
        String condition = lbp.getCondition();
        if (condition != null)
        {
          if (thread.getFrameCount() < 1) {
            return 2;
          }
          IJavaScriptValue value = thread.evaluate(condition);
          if ((lbp.isConditionSuspendOnTrue()) && 
            (suspendForValue(value))) {
            return 1;
          }
          if (!suspendForValue(value)) {
            return 1;
          }
        }
        return 1;
      }
    }
    catch (CoreException localCoreException) {}
    return 2;
  }
  
  public int scriptLoaded(IJavaScriptThread thread, ScriptReference script, IJavaScriptBreakpoint breakpoint)
  {
    String seg = URIUtil.lastSegment(script.sourceURI());
    if ((seg != null) && (seg.equals("stdin")) && (!RhinoPreferencesManager.suspendOnStdinLoad())) {
      return 2;
    }
    return 1;
  }
  
  private boolean suspendForValue(IJavaScriptValue value)
  {
    if ((value instanceof IJavaScriptPrimitiveValue)) {
      return ((IJavaScriptPrimitiveValue)value).booleanValue();
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.breakpoints.RhinoBreakpointParticipant
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.jsdt.debug.core.jsdi.ArrayReference;
import org.eclipse.wst.jsdt.debug.core.jsdi.Property;
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;

public class ArrayReferenceImpl
  extends ObjectReferenceImpl
  implements ArrayReference
{
  protected static final Value[] NO_VALUES = new Value[0];
  private ArrayList values = null;
  
  public ArrayReferenceImpl(VirtualMachineImpl vm, Map body, StackFrameImpl stackFrameImpl)
  {
    super(vm, body, stackFrameImpl);
  }
  
  public Value getValue(int index)
    throws IndexOutOfBoundsException
  {
    Value value = (Value)getValues().get(index);
    if (value == null) {
      return vm.mirrorOfNull();
    }
    return value;
  }
  
  public synchronized List getValues()
  {
    if (values == null)
    {
      Map members = new HashMap();
      int length = 0;
      for (Iterator iter = properties().iterator(); iter.hasNext();)
      {
        Property property = (Property)iter.next();
        if (Character.isDigit(property.name().charAt(0))) {
          members.put(Integer.valueOf(property.name()), property.value());
        } else if (property.name().equals("length")) {
          length = Integer.parseInt(property.value().valueString());
        }
      }
      values = new ArrayList(length);
      for (int i = 0; i < length; i++)
      {
        Object value = members.get(new Integer(i));
        if (value == null) {
          value = new UndefinedValueImpl(vm);
        }
        values.add(value);
      }
    }
    return values;
  }
  
  public int length()
  {
    return getValues().size();
  }
  
  public String valueString()
  {
    return "Array";
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append(NLS.bind(Messages.ArrayReferenceImpl_array_count_, new String[] { Integer.toString(length()) }));
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.ArrayReferenceImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;

public class BooleanValueImpl
  extends MirrorImpl
  implements BooleanValue
{
  private Boolean value;
  
  public BooleanValueImpl(VirtualMachineImpl vm, Map body)
  {
    this(vm, (Boolean)body.get("value"));
  }
  
  public BooleanValueImpl(VirtualMachineImpl vm, Boolean bool)
  {
    super(vm);
    value = bool;
  }
  
  public String valueString()
  {
    return value.toString();
  }
  
  public int intValue()
  {
    return value.booleanValue() ? 1 : 0;
  }
  
  public double doubleValue()
  {
    return intValue();
  }
  
  public boolean booleanValue()
  {
    return value.booleanValue();
  }
  
  public String stringValue()
  {
    return value.toString();
  }
  
  public String toString()
  {
    return stringValue();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.BooleanValueImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.FunctionReference;

public class FunctionReferenceImpl
  extends ObjectReferenceImpl
  implements FunctionReference
{
  private String functionName;
  
  public FunctionReferenceImpl(VirtualMachineImpl vm, Map body, StackFrameImpl stackFrameImpl)
  {
    super(vm, body, stackFrameImpl);
    functionName = ((String)body.get("name"));
  }
  
  public String functionName()
  {
    return functionName;
  }
  
  public String valueString()
  {
    return "Function";
  }
  
  public String functionBody()
  {
    return null;
  }
  
  public String toString()
  {
    return valueString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.FunctionReferenceImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Comparator;
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;

class LocationImpl$LocationComparator
  implements Comparator
{
  public int compare(Object o1, Object o2)
  {
    int value = -1;
    if (((o1 instanceof Location)) && ((o2 instanceof Location)))
    {
      int first = ((Location)o1).lineNumber();
      int second = ((Location)o2).lineNumber();
      if (first == second) {
        value = 0;
      } else if (first > second) {
        value = 1;
      }
    }
    return value;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.LocationImpl.LocationComparator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Comparator;
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;

public class LocationImpl
  extends MirrorImpl
  implements Location
{
  static class LocationComparator
    implements Comparator
  {
    public int compare(Object o1, Object o2)
    {
      int value = -1;
      if (((o1 instanceof Location)) && ((o2 instanceof Location)))
      {
        int first = ((Location)o1).lineNumber();
        int second = ((Location)o2).lineNumber();
        if (first == second) {
          value = 0;
        } else if (first > second) {
          value = 1;
        }
      }
      return value;
    }
  }
  
  private static LocationComparator comparator = new LocationComparator();
  private String functionName;
  private int lineNumber;
  private ScriptReferenceImpl scriptReference;
  
  public LocationImpl(VirtualMachineImpl vm, String functionName, int lineNumber, ScriptReferenceImpl scriptReference)
  {
    super(vm);
    this.functionName = functionName;
    this.lineNumber = lineNumber;
    this.scriptReference = scriptReference;
  }
  
  static LocationComparator getLocationComparator()
  {
    return comparator;
  }
  
  public String functionName()
  {
    return functionName;
  }
  
  public int lineNumber()
  {
    return lineNumber;
  }
  
  public ScriptReference scriptReference()
  {
    return scriptReference;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("LocationImpl: ");
    buffer.append("[script - ").append(scriptReference.sourceURI()).append("] ");
    buffer.append("[function - ").append(functionName).append("] ");
    buffer.append("[line - ").append(lineNumber).append("]");
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.LocationImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.messages";
  public static String ArrayReferenceImpl_array_count_;
  
  static
  {
    NLS.initializeMessages("org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.Messages
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.wst.jsdt.debug.core.jsdi.Mirror;
import org.eclipse.wst.jsdt.debug.core.jsdi.VirtualMachine;

public class MirrorImpl
  implements Mirror
{
  protected final VirtualMachineImpl vm;
  
  public MirrorImpl(VirtualMachineImpl vm)
  {
    this.vm = vm;
  }
  
  public MirrorImpl(String name)
  {
    vm = ((VirtualMachineImpl)this);
  }
  
  public VirtualMachine virtualMachine()
  {
    return vm;
  }
  
  protected void handleException(String message, Throwable t)
  {
    throw new RuntimeException(message, t);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.MirrorImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.wst.jsdt.debug.core.jsdi.NullValue;

public final class NullValueImpl
  extends MirrorImpl
  implements NullValue
{
  static final String NULL_VALUE = "Null";
  
  public NullValueImpl(VirtualMachineImpl vm)
  {
    super(vm);
  }
  
  public String valueString()
  {
    return "Null";
  }
  
  public String toString()
  {
    return valueString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.NullValueImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.NumberValue;
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;

public class NumberValueImpl
  extends MirrorImpl
  implements NumberValue
{
  private Number value;
  
  public NumberValueImpl(VirtualMachineImpl vm, Map body)
  {
    this(vm, (Number)body.get("value"));
  }
  
  public NumberValueImpl(VirtualMachineImpl vm, Number number)
  {
    super(vm);
    value = number;
  }
  
  public Number value()
  {
    return value;
  }
  
  public boolean isNaN()
  {
    return value == null;
  }
  
  public String valueString()
  {
    return JavaScriptDebugModel.numberToString(value);
  }
  
  public int intValue()
  {
    return value.intValue();
  }
  
  public double doubleValue()
  {
    return value.doubleValue();
  }
  
  public boolean booleanValue()
  {
    return value.intValue() > 0;
  }
  
  public String stringValue()
  {
    return JavaScriptDebugModel.numberToString(value);
  }
  
  public String toString()
  {
    return stringValue();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.NumberValueImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.ObjectReference;
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;

public class ObjectReferenceImpl
  extends MirrorImpl
  implements ObjectReference
{
  protected static final ArrayList NO_PROPERTIES = new ArrayList(0);
  private final String className;
  private final Number constructorRef;
  private final Number prototypeRef;
  private final Number id;
  protected StackFrameImpl frame;
  private Value constructor = null;
  private Value prototype = null;
  private List properties = null;
  
  public ObjectReferenceImpl(VirtualMachineImpl vm, Map body, StackFrameImpl frame)
  {
    super(vm);
    this.frame = frame;
    className = ((String)body.get("className"));
    id = ((Number)body.get("ref"));
    constructorRef = ((Number)body.get("constructorFunction"));
    prototypeRef = ((Number)body.get("prototypeObject"));
    List proplist = (List)body.get("properties");
    if (proplist != null)
    {
      properties = new ArrayList(proplist.size());
      Map props = null;
      for (Iterator iter = proplist.iterator(); iter.hasNext();)
      {
        props = (Map)iter.next();
        properties.add(new PropertyImpl(vm, frame, props.get("name").toString(), (Number)props.get("ref")));
      }
    }
    else
    {
      properties = NO_PROPERTIES;
    }
  }
  
  public String className()
  {
    return className;
  }
  
  public Value constructor()
  {
    synchronized (frame)
    {
      if (constructor == null)
      {
        constructor = frame.lookupValue(constructorRef);
        if (constructor == null) {
          constructor = vm.mirrorOfNull();
        }
      }
    }
    return constructor;
  }
  
  public Value prototype()
  {
    synchronized (frame)
    {
      if (prototype == null)
      {
        prototype = frame.lookupValue(prototypeRef);
        if (prototype == null) {
          prototype = vm.mirrorOfNull();
        }
      }
    }
    return prototype;
  }
  
  public List properties()
  {
    return properties;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("Object Reference\n");
    return buffer.toString();
  }
  
  public String valueString()
  {
    return "Object";
  }
  
  public Number id()
  {
    return id;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.ObjectReferenceImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.wst.jsdt.debug.core.jsdi.Property;
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;

public class PropertyImpl
  extends MirrorImpl
  implements Property
{
  private String name;
  private Number ref;
  private StackFrameImpl frame;
  private Value value;
  
  public PropertyImpl(VirtualMachineImpl vm, StackFrameImpl frame, String name, Number ref)
  {
    super(vm);
    this.frame = frame;
    this.name = name;
    this.ref = ref;
  }
  
  public String name()
  {
    return name;
  }
  
  public Number getRef()
  {
    return ref;
  }
  
  public Value value()
  {
    synchronized (frame)
    {
      if (value == null) {
        value = frame.lookupValue(ref);
      }
    }
    return value;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.PropertyImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
import org.eclipse.wst.jsdt.debug.internal.rhino.RhinoDebugPlugin;

public class ScriptReferenceImpl
  extends MirrorImpl
  implements ScriptReference
{
  private final Long scriptId;
  private String sourcePath = null;
  private URI sourceuri = null;
  private final String source;
  private final Boolean generated;
  private final List lineLocations = new ArrayList();
  private final List functionLocations = new ArrayList();
  private Map sourceProperties = null;
  
  public ScriptReferenceImpl(VirtualMachineImpl vm, Map jsonScript)
  {
    super(vm);
    scriptId = new Long(((Number)jsonScript.get("scriptId")).longValue());
    sourcePath = ((String)jsonScript.get("location"));
    sourceProperties = ((Map)jsonScript.get("properties"));
    source = ((String)jsonScript.get("source"));
    generated = ((Boolean)jsonScript.get("generated"));
    List lines = (List)jsonScript.get("lines");
    for (Iterator iterator = lines.iterator(); iterator.hasNext();)
    {
      Number lineNumber = (Number)iterator.next();
      Location location = new LocationImpl(vm, null, lineNumber.intValue(), this);
      lineLocations.add(location);
    }
    List functions = (List)jsonScript.get("functions");
    for (Iterator iterator = functions.iterator(); iterator.hasNext();)
    {
      String functionName = (String)iterator.next();
      Location location = new LocationImpl(vm, functionName, 0, this);
      functionLocations.add(location);
    }
  }
  
  public List allFunctionLocations()
  {
    return Collections.unmodifiableList(functionLocations);
  }
  
  public List allLineLocations()
  {
    return Collections.unmodifiableList(lineLocations);
  }
  
  public Location functionLocation(String functionName)
  {
    for (Iterator iterator = functionLocations.iterator(); iterator.hasNext();)
    {
      Location location = (Location)iterator.next();
      if (location.functionName().equals(functionName)) {
        return location;
      }
    }
    return null;
  }
  
  public Location lineLocation(int lineNumber)
  {
    for (Iterator iterator = lineLocations.iterator(); iterator.hasNext();)
    {
      Location location = (Location)iterator.next();
      if (location.lineNumber() == lineNumber) {
        return location;
      }
    }
    return null;
  }
  
  public String source()
  {
    return source;
  }
  
  public Long getScriptId()
  {
    return scriptId;
  }
  
  public boolean isGenerated()
  {
    return generated.booleanValue();
  }
  
  public synchronized URI sourceURI()
  {
    if (sourceuri == null) {
      try
      {
        if (sourceProperties != null)
        {
          IPath path = new Path((String)sourceProperties.get("Bundle-SymbolicName"));
          path = path.append((String)sourceProperties.get("path"));
          path = path.append((String)sourceProperties.get("name"));
          sourceuri = URIUtil.fromString(path.toString());
        }
        else if (sourcePath != null)
        {
          try
          {
            sourceuri = new URI(sourcePath);
          }
          catch (URISyntaxException localURISyntaxException1)
          {
            sourceuri = URIUtil.fromString(sourcePath);
          }
        }
        else
        {
          sourceuri = RhinoDebugPlugin.fileURI(new Path("script"));
        }
      }
      catch (URISyntaxException urise)
      {
        RhinoDebugPlugin.log(urise);
      }
    }
    return sourceuri;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("ScriptReferenceImpl: ");
    buffer.append("[sourceuri - ").append(sourceURI()).append("]\n");
    buffer.append("Line locations: \n");
    List list = new ArrayList(allLineLocations());
    Collections.sort(list, LocationImpl.getLocationComparator());
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
      Location loc = (Location)iter.next();
      buffer.append("\t").append(loc.toString()).append("\n");
    }
    buffer.append("Function locations: \n");
    list = new ArrayList(allFunctionLocations());
    Collections.sort(list, LocationImpl.getLocationComparator());
    for (Iterator iter = list.iterator(); iter.hasNext();)
    {
      Location loc = (Location)iter.next();
      buffer.append("\t").append(loc.toString()).append("\n");
    }
    buffer.append("\n");
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.ScriptReferenceImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.Location;
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
import org.eclipse.wst.jsdt.debug.core.jsdi.Value;
import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;
import org.eclipse.wst.jsdt.debug.internal.rhino.RhinoDebugPlugin;
import org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoRequest;
import org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoResponse;
import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;

public class StackFrameImpl
  extends MirrorImpl
  implements StackFrame
{
  private final Number frameId;
  private final Number threadId;
  private final Number contextId;
  private final Number ref;
  private final Location location;
  private List variables;
  private VariableImpl thisVariable;
  private HashMap cache = new HashMap();
  
  public StackFrameImpl(VirtualMachineImpl vm, Map jsonFrame)
  {
    super(vm);
    threadId = ((Number)jsonFrame.get("threadId"));
    frameId = ((Number)jsonFrame.get("frameId"));
    contextId = ((Number)jsonFrame.get("contextId"));
    ref = ((Number)jsonFrame.get("ref"));
    
    Long scriptId = new Long(((Number)jsonFrame.get("scriptId")).longValue());
    ScriptReferenceImpl script = vm.getScript(scriptId);
    
    String function = (String)jsonFrame.get("function");
    if (function != null)
    {
      location = script.functionLocation(function);
    }
    else
    {
      Number line = (Number)jsonFrame.get("line");
      Location lineLocation = script.lineLocation(line.intValue());
      location = (lineLocation != null ? lineLocation : new LocationImpl(vm, function, line.intValue(), script));
    }
  }
  
  public Value evaluate(String expression)
  {
    RhinoRequest request = new RhinoRequest("evaluate");
    request.getArguments().put("threadId", threadId);
    request.getArguments().put("frameId", frameId);
    request.getArguments().put("expression", expression);
    try
    {
      RhinoResponse response = vm.sendRequest(request, 30000);
      return createValue(response.getBody(), true);
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
    return null;
  }
  
  public Value lookupValue(Number ref)
  {
    Value value = (Value)cache.get(ref);
    if (value == null)
    {
      RhinoRequest request = new RhinoRequest("lookup");
      request.getArguments().put("threadId", threadId);
      request.getArguments().put("frameId", frameId);
      request.getArguments().put("ref", ref);
      try
      {
        RhinoResponse response = vm.sendRequest(request, 30000);
        value = createValue(response.getBody(), false);
        cache.put(ref, value);
        return value;
      }
      catch (DisconnectedException e)
      {
        handleException(e.getMessage(), e);
      }
      catch (TimeoutException e)
      {
        RhinoDebugPlugin.log(e);
      }
    }
    return value;
  }
  
  private Value createValue(Map body, boolean iseval)
    throws IllegalStateException
  {
    Map value = (Map)body.get(iseval ? "evaluate" : "lookup");
    if (value == null) {
      return vm.nullValue;
    }
    String type = (String)value.get("type");
    if (type == null) {
      return vm.nullValue;
    }
    if (type.equals("undefined")) {
      return vm.undefinedValue;
    }
    if (type.equals("null")) {
      return vm.nullValue;
    }
    if (type.equals("boolean")) {
      return new BooleanValueImpl(vm, value);
    }
    if (type.equals("number")) {
      return new NumberValueImpl(vm, value);
    }
    if (type.equals("string")) {
      return new StringValueImpl(vm, value);
    }
    if (type.equals("object")) {
      return new ObjectReferenceImpl(vm, value, this);
    }
    if (type.equals("function")) {
      return new FunctionReferenceImpl(vm, value, this);
    }
    if (type.equals("array")) {
      return new ArrayReferenceImpl(vm, value, this);
    }
    throw new IllegalStateException();
  }
  
  public Location location()
  {
    return location;
  }
  
  public synchronized Variable thisObject()
  {
    initializeVariables();
    return thisVariable;
  }
  
  public synchronized List variables()
  {
    initializeVariables();
    if (variables == null) {
      return Collections.EMPTY_LIST;
    }
    return variables;
  }
  
  private void initializeVariables()
  {
    if (variables != null) {
      return;
    }
    RhinoRequest request = new RhinoRequest("lookup");
    request.getArguments().put("threadId", threadId);
    request.getArguments().put("frameId", frameId);
    request.getArguments().put("ref", this.ref);
    try
    {
      RhinoResponse response = vm.sendRequest(request, 30000);
      if (response.isSuccess())
      {
        Map lookup = (Map)response.getBody().get("lookup");
        List properties = (List)lookup.get("properties");
        variables = new ArrayList();
        for (Iterator iterator = properties.iterator(); iterator.hasNext();)
        {
          Map property = (Map)iterator.next();
          String name = (String)property.get("name");
          Number ref = (Number)property.get("ref");
          VariableImpl variable = new VariableImpl(vm, this, name, ref);
          if (name.equals("this")) {
            thisVariable = variable;
          } else {
            variables.add(variable);
          }
        }
      }
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
  }
  
  public synchronized boolean isVisible(VariableImpl variable)
  {
    return (variables != null) && ((thisVariable == variable) || (variables.contains(variable)));
  }
  
  public Number getContextId()
  {
    return contextId;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.StackFrameImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.StringValue;

public class StringValueImpl
  extends MirrorImpl
  implements StringValue
{
  private String value;
  
  public StringValueImpl(VirtualMachineImpl vm, String value)
  {
    super(vm);
    this.value = value;
  }
  
  public StringValueImpl(VirtualMachineImpl vm, Map body)
  {
    this(vm, (String)body.get("value"));
  }
  
  public String value()
  {
    return value;
  }
  
  public String valueString()
  {
    return value;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.StringValueImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
import org.eclipse.wst.jsdt.debug.core.jsdi.ThreadReference;
import org.eclipse.wst.jsdt.debug.internal.rhino.RhinoDebugPlugin;
import org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoRequest;
import org.eclipse.wst.jsdt.debug.internal.rhino.transport.RhinoResponse;
import org.eclipse.wst.jsdt.debug.transport.exception.DisconnectedException;
import org.eclipse.wst.jsdt.debug.transport.exception.TimeoutException;

public class ThreadReferenceImpl
  extends MirrorImpl
  implements ThreadReference
{
  private Number threadId;
  private List frames;
  private int status = 1;
  private boolean suspended;
  private boolean atBreakpoint = false;
  private String name;
  private String step;
  
  public ThreadReferenceImpl(VirtualMachineImpl vm, Map jsonThread)
  {
    super(vm);
    threadId = ((Number)jsonThread.get("threadId"));
    name = ((String)jsonThread.get("name"));
    if (name == null) {
      name = ("Rhino - " + threadId);
    }
    suspended = "suspended".equals(jsonThread.get("state"));
  }
  
  public synchronized int frameCount()
  {
    frames();
    return frames == null ? 0 : frames.size();
  }
  
  public synchronized StackFrame frame(int index)
  {
    frames();
    return (StackFrame)frames.get(index);
  }
  
  public synchronized List frames()
  {
    if ((!suspended) || (status == 0)) {
      return Collections.EMPTY_LIST;
    }
    if (frames != null) {
      return frames;
    }
    RhinoRequest request = new RhinoRequest("frames");
    request.getArguments().put("threadId", threadId);
    try
    {
      RhinoResponse response = vm.sendRequest(request, 30000);
      List frameIds = (List)response.getBody().get("frames");
      if (frameIds.isEmpty()) {
        return Collections.EMPTY_LIST;
      }
      frames = new ArrayList();
      for (Iterator iterator = frameIds.iterator(); iterator.hasNext();)
      {
        Long frameId = new Long(((Number)iterator.next()).longValue());
        StackFrameImpl frame = createStackFrame(frameId);
        frames.add(frame);
      }
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
    if (frames != null) {
      return frames;
    }
    return Collections.EMPTY_LIST;
  }
  
  private StackFrameImpl createStackFrame(Long frameId)
  {
    RhinoRequest request = new RhinoRequest("frame");
    request.getArguments().put("threadId", threadId);
    request.getArguments().put("frameId", frameId);
    try
    {
      RhinoResponse response = vm.sendRequest(request);
      Map jsonFrame = (Map)response.getBody().get("frame");
      return new StackFrameImpl(vm, jsonFrame);
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
    return null;
  }
  
  public synchronized boolean isAtBreakpoint()
  {
    return (suspended) && (atBreakpoint);
  }
  
  public synchronized void markSuspended(boolean atBreakpoint)
  {
    suspended = true;
    this.atBreakpoint = atBreakpoint;
  }
  
  public synchronized boolean isSuspended()
  {
    return suspended;
  }
  
  public String name()
  {
    return name;
  }
  
  public synchronized void resume()
  {
    if (status == 0) {
      return;
    }
    RhinoRequest request = new RhinoRequest("continue");
    request.getArguments().put("threadId", threadId);
    if (step != null) {
      request.getArguments().put("step", step);
    }
    try
    {
      RhinoResponse response = vm.sendRequest(request);
      if (response.isSuccess())
      {
        step = null;
        frames = null;
        suspended = false;
        atBreakpoint = false;
      }
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
  }
  
  public synchronized void suspend()
  {
    if (status == 0) {
      return;
    }
    RhinoRequest request = new RhinoRequest("suspend");
    request.getArguments().put("threadId", threadId);
    try
    {
      RhinoResponse response = vm.sendRequest(request);
      if (response.isSuccess()) {
        markSuspended(false);
      }
    }
    catch (DisconnectedException e)
    {
      handleException(e.getMessage(), e);
    }
    catch (TimeoutException e)
    {
      RhinoDebugPlugin.log(e);
    }
  }
  
  public void interrupt()
  {
    throw new UnsupportedOperationException();
  }
  
  public synchronized int status()
  {
    return status;
  }
  
  public synchronized String getStep()
  {
    return step;
  }
  
  public synchronized void setStep(String step)
  {
    this.step = step;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.ThreadReferenceImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.wst.jsdt.debug.core.jsdi.UndefinedValue;

public class UndefinedValueImpl
  extends MirrorImpl
  implements UndefinedValue
{
  static final String UNDEFINED_VALUE = "Undefined";
  
  public UndefinedValueImpl(VirtualMachineImpl vm)
  {
    super(vm);
  }
  
  public String value()
  {
    return "undefined";
  }
  
  public String valueString()
  {
    return "Undefined";
  }
  
  public String toString()
  {
    return valueString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.UndefinedValueImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import org.eclipse.wst.jsdt.debug.core.jsdi.StackFrame;
import org.eclipse.wst.jsdt.debug.core.jsdi.Variable;

public class VariableImpl
  extends PropertyImpl
  implements Variable
{
  public VariableImpl(VirtualMachineImpl vm, StackFrameImpl frame, String name, Number ref)
  {
    super(vm, frame, name, ref);
  }
  
  public boolean isArgument()
  {
    return false;
  }
  
  public boolean isVisible(StackFrame frame)
  {
    StackFrameImpl frameImpl = (StackFrameImpl)frame;
    return frameImpl.isVisible(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.debug.internal.rhino.jsdi.VariableImpl
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.debug.internal.rhino.jsdi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.wst.jsdt.debug.core.jsdi.BooleanValue;
import org.eclipse.wst.jsdt.debug
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd