comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLScript.java @ 14094:3f27e57439ed

Truffle/Instrumentation: significant rearrangement (including moved class) and extension of the Truffle Instrumentation Framework. New interfaces include DebugContext (which can be attached to the ExecutionContext), through which access is provided to possibly language-specific (a) node instrumentation, (b) debug services manager, (c) notification when programs halt, (d) display of language values, and (e) display of variable identifiers.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Mon, 03 Feb 2014 20:58:23 -0800
parents 69d2e4baa215
children
comparison
equal deleted inserted replaced
13736:64fa70319890 14094:3f27e57439ed
1 /* 1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2014, 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.
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.truffle.sl; 23 package com.oracle.truffle.sl;
24
25 import java.io.*;
24 26
25 import javax.script.*; 27 import javax.script.*;
26 28
27 import com.oracle.truffle.api.*; 29 import com.oracle.truffle.api.*;
28 import com.oracle.truffle.sl.parser.*; 30 import com.oracle.truffle.sl.parser.*;
69 if (main == null) { 71 if (main == null) {
70 throw new ScriptException("No main function found."); 72 throw new ScriptException("No main function found.");
71 } 73 }
72 return new SLScript(context, main); 74 return new SLScript(context, main);
73 } 75 }
76
77 public static SLScript create(SLContext context, InputStream input) throws ScriptException {
78 SLNodeFactory factory = new SLNodeFactory(context);
79 Parser parser = new Parser(new Scanner(input), factory);
80 factory.setParser(parser);
81 factory.setSource(new Source() {
82 public String getName() {
83 return "Unknown";
84 }
85
86 public String getCode() {
87 return null;
88 }
89
90 @Override
91 public String getPath() {
92 // TODO Auto-generated method stub
93 return null;
94 }
95
96 @Override
97 public Reader getReader() {
98 // TODO Auto-generated method stub
99 return null;
100 }
101
102 @Override
103 public InputStream getInputStream() {
104 // TODO Auto-generated method stub
105 return null;
106 }
107
108 @Override
109 public String getCode(int lineNumber) {
110 // TODO Auto-generated method stub
111 return null;
112 }
113
114 @Override
115 public int getLineCount() {
116 // TODO Auto-generated method stub
117 return 0;
118 }
119
120 @Override
121 public int getLineNumber(int offset) {
122 // TODO Auto-generated method stub
123 return 0;
124 }
125
126 @Override
127 public int getLineStartOffset(int lineNumber) {
128 // TODO Auto-generated method stub
129 return 0;
130 }
131
132 @Override
133 public int getLineLength(int lineNumber) {
134 // TODO Auto-generated method stub
135 return 0;
136 }
137 });
138 String error = parser.ParseErrors();
139 if (!error.isEmpty()) {
140 throw new ScriptException(String.format("Error(s) parsing script: %s", error));
141 }
142
143 CallTarget main = context.getFunctionRegistry().lookup("main");
144 if (main == null) {
145 throw new ScriptException("No main function found.");
146 }
147 return new SLScript(context, main);
148 }
74 } 149 }