class
compilerJava::JavaBridge
sys::Obj compiler::CompilerSupport compiler::CBridge compilerJava::JavaBridge
@compilerBridge = "java"
JavaBridge is the compiler plugin for bringing Java classes into the Fan type system.
Slots
- areParamsSameSource
-
static Bool areParamsSame(CMethod a, CMethod b)
Do the two methods have the exact same parameter types.
-
private Expr arrayToList(Expr expr, CType of)
Generate List.make(of, expr) where expr is Object[]
-
private Void checkMethodOverride(TypeDef t, JavaMethod base, MethodDef def)
Called on method/method overrides in the checkOverride callback.
- checkOverrideSource
-
override Void checkOverride(TypeDef t, CSlot base, SlotDef def)
Overrides compiler::CBridge.checkOverride
Called during Inherit step when a Fan slot overrides a FFI slot. Log and throw compiler error if there is a problem.
- checkTypeSource
-
override Void checkType(TypeDef def)
Overrides compiler::CBridge.checkType
Called during CheckErrors step for a type which extends a FFI class or implements any FFI mixins.
- classTypeSource
-
JavaType classType()
Get a CType representation for
java.lang.Class
- coerceSource
-
override Expr coerce(Expr expr, CType expected, |,| onErr)
Overrides compiler::CBridge.coerce
Coerce expression to expected type. If not a type match then run the onErr function.
- coerceFromArraySource
-
Expr coerceFromArray(Expr expr, CType expected, |,| onErr)
Coerce a Java array to a Fan list.
- coerceFromPrimitiveSource
-
Expr coerceFromPrimitive(Expr expr, CType expected, |,| onErr)
Coerce a Java primitive to a Fan type.
- coerceFuncToInterfaceSource
-
Expr coerceFuncToInterface(Expr expr, JavaType expected, |,| onErr)
Attempt to coerce a parameterized sys::Func expr to a Java interface if the interface supports exactly one matching method.
- coerceToArraySource
-
Expr coerceToArray(Expr expr, CType expected, |,| onErr)
Coerce a Fan list to Java array.
- coerceToPrimitiveSource
-
Expr coerceToPrimitive(Expr expr, JavaType expected, |,| onErr)
Coerce a fan expression to a Java primitive (other than the ones we support natively)
- cpSource
-
readonly ClassPath cp
- fitsSource
-
Bool fits(CType actual, CType expected)
Return if we can make the actual type fit the expected type, potentially using a coercion.
- generateFuncToInterfaceWrapperSource
-
CMethod generateFuncToInterfaceWrapper(Location loc, FuncType funcType, CType expected, CMethod method)
Generate the wrapper which implements the specified expected interface and overrides the specified method which calls the function.
- isFuncToInterfaceMatchSource
-
Bool isFuncToInterfaceMatch(FuncType funcType, CMethod method)
Return if the specified function type can be used to implement the specified interface method.
-
static internal Bool isMoreSpecific(CallMatch a, CallMatch b)
Is
a
more specific thanb
such thata
could be used passed tob
without a compile time error. -
static private Bool isOverrideInferredType(CType base, CType def)
When overriding a Java method check if the base type is is a Java primitive or array and the override definition is matches how the Java type is inferred in the Fan type system. If we have a match return true and we'll swizzle things in checkMethodOverride.
- listAsArraySource
-
CMethod listAsArray()
Get a CMethod representation for
Object[] List.asArray()
- listMakeFromArraySource
-
CMethod listMakeFromArray()
Get a CMethod representation for
List.make(Type, Object[])
- makeSource
-
new make(Compiler c)
Construct a JavaBridge for current environment
-
internal CallMatch? matchCall(CallExpr call, CMethod m)
Check if the call matches the specified overload method. If so return method and coerced args otherwise return null.
- objectArrayTypeSource
-
JavaType objectArrayType()
Get a CType representation for
java.lang.Object[]
- primitivesSource
-
readonly JavaPrimitives primitives := JavaPrimitives(this)
- resolveCallSource
-
override CallExpr resolveCall(CallExpr call)
Overrides compiler::CBridge.resolveCall
Resolve a method call: try to find the best match and apply any coercions needed.
- resolveConstructionSource
-
override Expr resolveConstruction(CallExpr call)
Overrides compiler::CBridge.resolveConstruction
Resolve a construction call to a Java constructor.
- resolveConstructorChainSource
-
override Expr resolveConstructorChain(CallExpr call)
Resolve a construction chain call where a Fan constructor calls the super-class constructor. Type check the arguments and insert any conversions needed.
-
static internal CallMatch? resolveMostSpecific(CallMatch[] matches)
Given a list of overloaed methods find the most specific method according to Java Language Specification 15.11.2.2. The "informal intuition" rule is that a method is more specific than another if the first could be could be passed onto the second one.
- resolvePodSource
-
override CPod resolvePod(Str name, Location? loc)
Overrides compiler::CBridge.resolvePod
Map a FFI "podName" to a Java package.