comparison graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/instrument/SLInstrumentTestRunner.java @ 19247:128586040207

Truffle/Instrumentation: TruffleEventReceiver renamed to TruffleEventListener
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 10 Feb 2015 16:44:11 -0800
parents e3c95cbbb50c
children 907128d02b31
comparison
equal deleted inserted replaced
19246:d3e835fa6bbf 19247:128586040207
1 /* 1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
216 final Source source = Source.fromText(readAllLines(testCase.path), testCase.sourceName); 216 final Source source = Source.fromText(readAllLines(testCase.path), testCase.sourceName);
217 Parser.parseSL(slContext, source); 217 Parser.parseSL(slContext, source);
218 218
219 // Attach an instrument to every probe tagged as an assignment 219 // Attach an instrument to every probe tagged as an assignment
220 for (Probe probe : Probe.findProbesTaggedAs(StandardSyntaxTag.ASSIGNMENT)) { 220 for (Probe probe : Probe.findProbesTaggedAs(StandardSyntaxTag.ASSIGNMENT)) {
221 SLPrintAssigmentValueReciever slPrintAssigmentValueReceiver = new SLPrintAssigmentValueReciever(printer); 221 SLPrintAssigmentValueListener slPrintAssigmentValueListener = new SLPrintAssigmentValueListener(printer);
222 probe.attach(Instrument.create(slPrintAssigmentValueReceiver, "SL print assignment value")); 222 probe.attach(Instrument.create(slPrintAssigmentValueListener, "SL print assignment value"));
223 } 223 }
224 224
225 SLFunction main = slContext.getFunctionRegistry().lookup("main"); 225 SLFunction main = slContext.getFunctionRegistry().lookup("main");
226 main.getCallTarget().call(); 226 main.getCallTarget().call();
227 } else { 227 } else {
269 return "Filter contains " + pattern; 269 return "Filter contains " + pattern;
270 } 270 }
271 } 271 }
272 272
273 /** 273 /**
274 * This sample instrument receiver provides prints the value of an assignment (after the 274 * This sample instrument listener provides prints the value of an assignment (after the
275 * assignment is complete) to the {@link PrintStream} specified in the constructor. This 275 * assignment is complete) to the {@link PrintStream} specified in the constructor. This
276 * instrument can only be attached to a wrapped {@link SLWriteLocalVariableNode}, but provides 276 * instrument can only be attached to a wrapped {@link SLWriteLocalVariableNode}, but provides
277 * no guards to protect it from being attached elsewhere. 277 * no guards to protect it from being attached elsewhere.
278 */ 278 */
279 public final class SLPrintAssigmentValueReciever extends DefaultEventReceiver { 279 public final class SLPrintAssigmentValueListener extends DefaultEventListener {
280 280
281 private PrintStream output; 281 private PrintStream output;
282 282
283 public SLPrintAssigmentValueReciever(PrintStream output) { 283 public SLPrintAssigmentValueListener(PrintStream output) {
284 this.output = output; 284 this.output = output;
285 } 285 }
286 286
287 @Override 287 @Override
288 public void returnValue(Node node, VirtualFrame frame, Object result) { 288 public void returnValue(Node node, VirtualFrame frame, Object result) {