Thu, 24 Nov 2011 13:36:20 +0000
7115046: Add AST node for lambda expressions
Summary: Add tree nodes for representing lambda expressions and update relevant visitors interfaces
Reviewed-by: jjg
jjg@416 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
jjg@416 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@416 | 4 | * |
jjg@416 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@416 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
jjg@416 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
jjg@416 | 10 | * |
jjg@416 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@416 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@416 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@416 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@416 | 15 | * accompanied this code). |
jjg@416 | 16 | * |
jjg@416 | 17 | * You should have received a copy of the GNU General Public License version |
jjg@416 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@416 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@416 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
jjg@416 | 24 | */ |
jjg@416 | 25 | |
jjg@416 | 26 | package com.sun.tools.javah; |
jjg@416 | 27 | |
jjg@416 | 28 | import java.io.InputStream; |
jjg@416 | 29 | import java.io.OutputStream; |
jjg@416 | 30 | import java.io.Writer; |
jjg@416 | 31 | import java.nio.charset.Charset; |
jjg@416 | 32 | import java.util.Arrays; |
jjg@416 | 33 | import java.util.EnumSet; |
jjg@416 | 34 | import java.util.Locale; |
jjg@416 | 35 | import java.util.Set; |
jjg@416 | 36 | import javax.lang.model.SourceVersion; |
jjg@416 | 37 | import javax.tools.DiagnosticListener; |
jjg@416 | 38 | import javax.tools.JavaFileManager; |
jjg@416 | 39 | import javax.tools.JavaFileObject; |
jjg@416 | 40 | import javax.tools.StandardJavaFileManager; |
jjg@416 | 41 | |
jjg@416 | 42 | /* |
jjg@581 | 43 | * <p><b>This is NOT part of any supported API. |
jjg@416 | 44 | * If you write code that depends on this, you do so at your own |
jjg@416 | 45 | * risk. This code and its internal interfaces are subject to change |
jjg@416 | 46 | * or deletion without notice.</b></p> |
jjg@416 | 47 | */ |
jjg@416 | 48 | public class JavahTool implements NativeHeaderTool { |
jjg@416 | 49 | |
jjg@416 | 50 | public NativeHeaderTask getTask(Writer out, |
jjg@416 | 51 | JavaFileManager fileManager, |
jjg@416 | 52 | DiagnosticListener<? super JavaFileObject> diagnosticListener, |
jjg@416 | 53 | Iterable<String> options, |
jjg@416 | 54 | Iterable<String> classes) { |
jjg@416 | 55 | return new JavahTask(out, fileManager, diagnosticListener, options, classes); |
jjg@416 | 56 | } |
jjg@416 | 57 | |
jjg@416 | 58 | public StandardJavaFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) { |
jjg@416 | 59 | return JavahTask.getDefaultFileManager(diagnosticListener, null); |
jjg@416 | 60 | } |
jjg@416 | 61 | |
jjg@416 | 62 | public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { |
jjg@416 | 63 | JavahTask t = new JavahTask( |
jjg@416 | 64 | JavahTask.getPrintWriterForStream(out), |
jjg@416 | 65 | null, |
jjg@416 | 66 | null, |
jjg@416 | 67 | Arrays.asList(arguments), |
jjg@416 | 68 | null); |
jjg@416 | 69 | return (t.run() ? 0 : 1); |
jjg@416 | 70 | } |
jjg@416 | 71 | |
jjg@416 | 72 | public Set<SourceVersion> getSourceVersions() { |
jjg@416 | 73 | return EnumSet.allOf(SourceVersion.class); |
jjg@416 | 74 | } |
jjg@416 | 75 | |
jjg@416 | 76 | public int isSupportedOption(String option) { |
jjg@416 | 77 | JavahTask.Option[] options = JavahTask.recognizedOptions; |
jjg@416 | 78 | for (int i = 0; i < options.length; i++) { |
jjg@416 | 79 | if (options[i].matches(option)) |
jjg@416 | 80 | return (options[i].hasArg ? 1 : 0); |
jjg@416 | 81 | } |
jjg@416 | 82 | return -1; |
jjg@416 | 83 | } |
jjg@416 | 84 | } |