@Override protected CallTarget parse(ParsingRequest request) throws Exception { Source code = request.getSource(); final RootNode root; final String txt = code.getCharacters().toString(); if (txt.startsWith("TCK42:")) { int nextColon = txt.indexOf(":", 6); String mimeType = txt.substring(6, nextColon); Source toParse = Source.newBuilder(txt.substring(nextColon + 1)).mimeType(mimeType).name("src.tck").build(); root = new MultiplyNode(this, toParse); } else { final double value = Double.parseDouble(txt); root = RootNode.createConstantNode(value); } return Truffle.getRuntime().createCallTarget(root); }
@Override @SuppressWarnings("deprecation") protected CallTarget parse(ParsingRequest request) throws Exception { Source code = request.getSource(); final RootNode root; final String txt = code.getCharacters().toString(); if (txt.startsWith("TCK42:")) { int nextColon = txt.indexOf(":", 6); String mimeType = txt.substring(6, nextColon); Source toParse = Source.newBuilder(txt.substring(nextColon + 1)).name("src.tck").mimeType(mimeType).build(); root = new MultiplyNode(this, toParse); } else { final double value = Double.parseDouble(txt); root = RootNode.createConstantNode(value); } return Truffle.getRuntime().createCallTarget(root); }
@Override public Object execute(VirtualFrame frame) { Env env = getLanguage(TckLanguage.class).getContextReference().get(); Object[] arguments = frame.getArguments(); return parseAndEval(env, arguments); }
@Override public Object execute(VirtualFrame frame) { Env env = getLanguage(TckLanguage.class).getContextReference().get(); Object[] arguments = frame.getArguments(); return parseAndEval(env, arguments); }