class RuntimeTypeCheck extends java.lang.Object implements CompilerPass
We add markers to user-defined interfaces and classes in order to check if an object conforms to that type.
For each function, we insert a run-time type assertion for each parameter and return value for which the compiler has a type.
The JavaScript code which implements the type assertions is in js/runtime-type-check.js.
Modifier and Type | Class and Description |
---|---|
private class |
RuntimeTypeCheck.AddChecks
Insert calls to the run-time type checking function
checkType , which
takes an expression to check and a list of checkers (one of which must
match). |
private static class |
RuntimeTypeCheck.AddMarkers
Inserts marker properties for user-defined interfaces and classes.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.Comparator<JSType> |
ALPHA |
private AbstractCompiler |
compiler |
private java.lang.String |
logFunction |
Constructor and Description |
---|
RuntimeTypeCheck(AbstractCompiler compiler,
java.lang.String logFunction) |
Modifier and Type | Method and Description |
---|---|
private void |
addBoilerplateCode() |
private Node |
jsCode(java.lang.String prop) |
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
private static final java.util.Comparator<JSType> ALPHA
private final AbstractCompiler compiler
private final java.lang.String logFunction
RuntimeTypeCheck(AbstractCompiler compiler, @Nullable java.lang.String logFunction)
public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treeprivate void addBoilerplateCode()
private Node jsCode(java.lang.String prop)