comparison graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java @ 13563:fb846424299f

Truffle/Ruby: extend Instrumentation framework with language-agnostic interfaces for access to AST printing utilities and a Ruby implementation
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 07 Jan 2014 18:09:42 -0800
parents 0fbee3eb71f0
children 497fada09efb
comparison
equal deleted inserted replaced
13562:58ca96949f2e 13563:fb846424299f
1 /* 1 /*
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This 2 * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
3 * code is released under a tri EPL/GPL/LGPL license. You can use it, 3 * code is released under a tri EPL/GPL/LGPL license. You can use it,
4 * redistribute it and/or modify it under the terms of the: 4 * redistribute it and/or modify it under the terms of the:
5 * 5 *
6 * Eclipse Public License version 1.0 6 * Eclipse Public License version 1.0
7 * GNU General Public License version 2 7 * GNU General Public License version 2
40 private final ThreadManager threadManager; 40 private final ThreadManager threadManager;
41 private final FiberManager fiberManager; 41 private final FiberManager fiberManager;
42 private final AtExitManager atExitManager; 42 private final AtExitManager atExitManager;
43 private final RubyDebugManager debugManager; 43 private final RubyDebugManager debugManager;
44 private final SourceManager sourceManager; 44 private final SourceManager sourceManager;
45 private final ASTPrinter astPrinter;
45 46
46 private AtomicLong nextObjectID = new AtomicLong(0); 47 private AtomicLong nextObjectID = new AtomicLong(0);
47 48
48 private String currentDirectory = System.getProperty("user.dir"); 49 private String currentDirectory = System.getProperty("user.dir");
49 50
50 private POSIX posix = POSIXFactory.getPOSIX(); 51 private POSIX posix = POSIXFactory.getPOSIX();
51 52
52 public RubyContext(RubyParser parser) { 53 public RubyContext(RubyParser parser) {
53 this(new Configuration(new ConfigurationBuilder()), parser); 54 this(new Configuration(new ConfigurationBuilder()), parser, null);
54 } 55 }
55 56
56 public RubyContext(Configuration configuration, RubyParser parser) { 57 public RubyContext(Configuration configuration, RubyParser parser) {
58 this(configuration, parser, null);
59 }
60
61 public RubyContext(Configuration configuration, RubyParser parser, ASTPrinter astPrinter) {
57 assert configuration != null; 62 assert configuration != null;
58 63
59 this.configuration = configuration; 64 this.configuration = configuration;
60 this.parser = parser; 65 this.parser = parser;
66 this.astPrinter = astPrinter;
61 67
62 objectSpaceManager = new ObjectSpaceManager(this); 68 objectSpaceManager = new ObjectSpaceManager(this);
63 traceManager = new TraceManager(this); 69 traceManager = new TraceManager(this);
64 70
65 // See note in CoreLibrary#initialize to see why we need to break this into two statements 71 // See note in CoreLibrary#initialize to see why we need to break this into two statements
87 return configuration.getRubyVersion().getShortName(); 93 return configuration.getRubyVersion().getShortName();
88 } 94 }
89 95
90 public RubyDebugManager getDebugManager() { 96 public RubyDebugManager getDebugManager() {
91 return debugManager; 97 return debugManager;
98 }
99
100 public ASTPrinter getASTPrinter() {
101 return astPrinter;
92 } 102 }
93 103
94 public void implementationMessage(String format, Object... arguments) { 104 public void implementationMessage(String format, Object... arguments) {
95 System.err.println("rubytruffle: " + String.format(format, arguments)); 105 System.err.println("rubytruffle: " + String.format(format, arguments));
96 } 106 }