mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Add more methods and update the library name
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
// Autogenerated AST node
|
||||
package org.python.antlr.base;
|
||||
|
||||
public abstract class mod {
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) Corporation for National Research Initiatives
|
||||
package org.python.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility class for loading compiled Python modules and Java classes defined in Python modules.
|
||||
*/
|
||||
public class BytecodeLoader {
|
||||
|
||||
/**
|
||||
* Turn the Java class file data into a Java class.
|
||||
*
|
||||
* @param name fully-qualified binary name of the class
|
||||
* @param data a class file as a byte array
|
||||
* @param referents super-classes and interfaces that the new class will reference.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Class<?> makeClass(String name, byte[] data, Class<?>... referents) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the Java class file data into a Java class.
|
||||
*
|
||||
* @param name the name of the class
|
||||
* @param referents super-classes and interfaces that the new class will reference.
|
||||
* @param data a class file as a byte array
|
||||
*/
|
||||
public static Class<?> makeClass(String name, List<Class<?>> referents, byte[] data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the Java class file data for a compiled Python module into a {@code PyCode} object, by
|
||||
* constructing an instance of the named class and calling the instance's
|
||||
* {@link PyRunnable#getMain()}.
|
||||
*
|
||||
* @param name fully-qualified binary name of the class
|
||||
* @param data a class file as a byte array
|
||||
* @param filename to provide to the constructor of the named class
|
||||
* @return the {@code PyCode} object produced by the named class' {@code getMain}
|
||||
*/
|
||||
public static PyCode makeCode(String name, byte[] data, String filename) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.python.core;
|
||||
|
||||
public enum CompileMode {
|
||||
eval,
|
||||
single,
|
||||
exec;
|
||||
|
||||
public static CompileMode getMode(String mode) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// At some future point this will also be extended - in conjunction with
|
||||
// Py#compileFlags - to add
|
||||
// support for a compiler factory that user code can choose in place of the
|
||||
// normal compiler.
|
||||
// (Perhaps a better name might have been "CompilerOptions".)
|
||||
|
||||
package org.python.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CompilerFlags implements Serializable {
|
||||
public CompilerFlags() {
|
||||
}
|
||||
|
||||
public CompilerFlags(int co_flags) {
|
||||
}
|
||||
}
|
||||
134
java/ql/test/stubs/jython-2.7.2/org/python/core/Py.java
Normal file
134
java/ql/test/stubs/jython-2.7.2/org/python/core/Py.java
Normal file
@@ -0,0 +1,134 @@
|
||||
// Copyright (c) Corporation for National Research Initiatives
|
||||
package org.python.core;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.python.antlr.base.mod;
|
||||
|
||||
public final class Py {
|
||||
/**
|
||||
Convert a given <code>PyObject</code> to an instance of a Java class.
|
||||
Identical to <code>o.__tojava__(c)</code> except that it will
|
||||
raise a <code>TypeError</code> if the conversion fails.
|
||||
@param o the <code>PyObject</code> to convert.
|
||||
@param c the class to convert it to.
|
||||
**/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T tojava(PyObject o, Class<T> c) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ??pending: was @deprecated but is actually used by proxie code.
|
||||
// Can get rid of it?
|
||||
public static Object tojava(PyObject o, String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the PyObjectAdapter passed to {@link PySystemState#initialize} to turn o into a PyObject.
|
||||
*
|
||||
* @see ClassicPyObjectAdapter - default PyObjectAdapter type
|
||||
*/
|
||||
public static PyObject java2py(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the PyObjectAdapter passed to {@link PySystemState#initialize} to turn
|
||||
* <code>objects</code> into an array of PyObjects.
|
||||
*
|
||||
* @see ClassicPyObjectAdapter - default PyObjectAdapter type
|
||||
*/
|
||||
public static PyObject[] javas2pys(Object... objects) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PyObject makeClass(String name, PyObject[] bases, PyCode code,
|
||||
PyObject[] closure_cells) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PyObject makeClass(String name, PyObject base, PyObject dict) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Python class.
|
||||
*
|
||||
* @param name the String name of the class
|
||||
* @param bases an array of PyObject base classes
|
||||
* @param dict the class's namespace, containing the class body
|
||||
* definition
|
||||
* @return a new Python Class PyObject
|
||||
*/
|
||||
public static PyObject makeClass(String name, PyObject[] bases, PyObject dict) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CompilerFlags getCompilerFlags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CompilerFlags getCompilerFlags(int flags, boolean dont_inherit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CompilerFlags getCompilerFlags(CompilerFlags flags, boolean dont_inherit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// w/o compiler-flags
|
||||
public static PyCode compile(InputStream istream, String filename, CompileMode kind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for compiling modules.
|
||||
*
|
||||
* @param node Module node, coming from the parsing process
|
||||
* @param name Internal name for the compiled code. Typically generated by
|
||||
* calling {@link #getName()}.
|
||||
* @param filename Source file name
|
||||
* @param linenumbers True to track source line numbers on the generated
|
||||
* code
|
||||
* @param printResults True to call the sys.displayhook on the result of
|
||||
* the code
|
||||
* @param cflags Compiler flags
|
||||
* @return Code object for the compiled module
|
||||
*/
|
||||
public static PyCode compile_flags(mod node, String name, String filename,
|
||||
boolean linenumbers, boolean printResults,
|
||||
CompilerFlags cflags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PyCode compile_flags(mod node, String filename,
|
||||
CompileMode kind, CompilerFlags cflags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles python source code coming from a file or another external stream
|
||||
*/
|
||||
public static PyCode compile_flags(InputStream istream, String filename,
|
||||
CompileMode kind, CompilerFlags cflags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles python source code coming from String (raw bytes) data.
|
||||
*
|
||||
* If the String is properly decoded (from PyUnicode) the PyCF_SOURCE_IS_UTF8 flag
|
||||
* should be specified.
|
||||
*/
|
||||
public static PyCode compile_flags(String data, String filename,
|
||||
CompileMode kind, CompilerFlags cflags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PyObject compile_command_flags(String string, String filename,
|
||||
CompileMode kind, CompilerFlags cflags, boolean stdprompt) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// Copyright (c) Corporation for National Research Initiatives
|
||||
package org.python.util;
|
||||
|
||||
import org.python.core.*;
|
||||
|
||||
/**
|
||||
* This class provides the interface for compiling and running code that supports an interactive
|
||||
* interpreter.
|
||||
*/
|
||||
// Based on CPython-1.5.2's code module
|
||||
public class InteractiveInterpreter extends PythonInterpreter {
|
||||
|
||||
/**
|
||||
* Construct an InteractiveInterpreter with all default characteristics: default state (from
|
||||
* {@link Py#getSystemState()}), and a new empty dictionary of local variables.
|
||||
* */
|
||||
public InteractiveInterpreter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an InteractiveInterpreter with state (from {@link Py#getSystemState()}), and the
|
||||
* specified dictionary of local variables.
|
||||
*
|
||||
* @param locals dictionary to use, or if <code>null</code>, a new empty one will be created
|
||||
*/
|
||||
public InteractiveInterpreter(PyObject locals) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an InteractiveInterpreter with, and system state the specified dictionary of local
|
||||
* variables.
|
||||
*
|
||||
* @param locals dictionary to use, or if <code>null</code>, a new empty one will be created
|
||||
* @param systemState interpreter state, or if <code>null</code> use {@link Py#getSystemState()}
|
||||
*/
|
||||
public InteractiveInterpreter(PyObject locals, PySystemState systemState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile and run some source in the interpreter, in the mode {@link CompileMode#single} which
|
||||
* is used for incremental compilation at the interactive console, known as {@code <input>}.
|
||||
*
|
||||
* @param source Python code
|
||||
* @return <code>true</code> to indicate a partial statement was entered
|
||||
*/
|
||||
public boolean runsource(String source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile and run some source in the interpreter, in the mode {@link CompileMode#single} which
|
||||
* is used for incremental compilation at the interactive console.
|
||||
*
|
||||
* @param source Python code
|
||||
* @param filename name with which to label this console input (e.g. in error messages).
|
||||
* @return <code>true</code> to indicate a partial statement was entered
|
||||
*/
|
||||
public boolean runsource(String source, String filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile and run some source in the interpreter, according to the {@link CompileMode} given.
|
||||
* This method supports incremental compilation and interpretation through the return value,
|
||||
* where {@code true} signifies that more input is expected in order to complete the Python
|
||||
* statement. An interpreter can use this to decide whether to use {@code sys.ps1}
|
||||
* ("{@code >>> }") or {@code sys.ps2} ("{@code ... }") to prompt the next line. The arguments
|
||||
* are the same as the mandatory ones in the Python {@code compile()} command.
|
||||
* <p>
|
||||
* One the following can happen:
|
||||
* <ol>
|
||||
* <li>The input is incorrect; compilation raised an exception (SyntaxError or OverflowError). A
|
||||
* syntax traceback will be printed by calling {@link #showexception(PyException)}. Return is
|
||||
* {@code false}.</li>
|
||||
*
|
||||
* <li>The input is incomplete, and more input is required; compilation returned no code.
|
||||
* Nothing happens. Return is {@code true}.</li>
|
||||
*
|
||||
* <li>The input is complete; compilation returned a code object. The code is executed by
|
||||
* calling {@link #runcode(PyObject)} (which also handles run-time exceptions, except for
|
||||
* SystemExit). Return is {@code false}.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param source Python code
|
||||
* @param filename name with which to label this console input (e.g. in error messages).
|
||||
* @param kind of compilation required: {@link CompileMode#eval}, {@link CompileMode#exec} or
|
||||
* {@link CompileMode#single}
|
||||
* @return {@code true} to indicate a partial statement was provided
|
||||
*/
|
||||
public boolean runsource(String source, String filename, CompileMode kind) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a code object. When an exception occurs, {@link #showexception(PyException)} is
|
||||
* called to display a stack trace, except in the case of SystemExit, which is re-raised.
|
||||
* <p>
|
||||
* A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not
|
||||
* always be caught. The caller should be prepared to deal with it.
|
||||
**/
|
||||
|
||||
// Make this run in another thread somehow????
|
||||
public void runcode(PyObject code) {
|
||||
}
|
||||
|
||||
public void showexception(PyException exc) {
|
||||
}
|
||||
|
||||
public void write(String data) {
|
||||
}
|
||||
|
||||
public void resetbuffer() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user