changeset 15944:eedf6c293639

Truffle: additional methods on ExecutionContext
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 27 May 2014 21:18:45 -0700
parents 14ac87c56a27
children 57303ce74a21
files graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java
diffstat 2 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java	Tue May 27 21:18:16 2014 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java	Tue May 27 21:18:45 2014 -0700
@@ -71,6 +71,18 @@
     }
 
     /**
+     * Unregisters a tool interested in being notified about the loading of {@link Source}s.
+     */
+    public final void removeSourceListener(SourceListener removeListener) {
+        final List<SourceListener> listeners = new ArrayList<>(sourceListeners);
+        for (SourceListener listener : listeners) {
+            if (listener == removeListener) {
+                sourceListeners.remove(listener);
+            }
+        }
+    }
+
+    /**
      * Registers a tool interested in being notified about the insertion of a newly created
      * {@link Probe} into a Truffle AST.
      */
@@ -79,6 +91,14 @@
     }
 
     /**
+     * Unregisters a tool interested in being notified about the insertion of a newly created
+     * {@link Probe} into a Truffle AST.
+     */
+    public final void removeProbeListener(ProbeListener listener) {
+        probeManager.removeProbeListener(listener);
+    }
+
+    /**
      * Return the (possibly newly created) {@link Probe} uniquely associated with a particular
      * source code location. A newly created probe carries no tags.
      *
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java	Tue May 27 21:18:16 2014 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/ProbeManager.java	Tue May 27 21:18:45 2014 -0700
@@ -80,6 +80,15 @@
         probeListeners.add(listener);
     }
 
+    public void removeProbeListener(ProbeListener removeListener) {
+        final List<ProbeListener> listeners = new ArrayList<>(probeListeners);
+        for (ProbeListener listener : listeners) {
+            if (listener == removeListener) {
+                probeListeners.remove(listener);
+            }
+        }
+    }
+
     public Probe getProbe(SourceSection sourceSection) {
         assert sourceSection != null;