class compilerJava::JavaBridge
sys::Obj compiler::CompilerSupport compiler::CBridge compilerJava::JavaBridge
JavaBridge is the compiler plugin for bringing Java classes into the Fantom type system.
- areParamsSame
-
static Bool areParamsSame(CMethod a, CMethod b)
Do the two methods have the exact same parameter types.
- boolTypes
-
const static Str[] boolTypes := ...
- checkOverride
-
virtual override Void checkOverride(TypeDef t, CSlot base, SlotDef def)
Called during Inherit step when a Fantom slot overrides a FFI slot. Log and throw compiler error if there is a problem.
- checkType
-
virtual override Void checkType(TypeDef def)
Called during CheckErrors step for a type which extends a FFI class or implements any FFI mixins.
- classType
-
JavaType classType()
Get a CType representation for
java.lang.Class
- cleanup
-
virtual override Void cleanup()
- coerce
-
virtual override Expr coerce(Expr expr, CType expected, |->Void| onErr)
Coerce expression to expected type. If not a type match then run the onErr function.
- coerceFromArray
-
Expr coerceFromArray(Expr expr, CType expected, |->Void| onErr)
Coerce a Java array to a Fantom list.
- coerceFromPrimitive
-
Expr coerceFromPrimitive(Expr expr, CType expected, |->Void| onErr)
Coerce a Java primitive to a Fantom type.
- coerceFuncToInterface
-
Expr coerceFuncToInterface(Expr expr, JavaType expected, |->Void| onErr)
Attempt to coerce a parameterized sys::Func expr to a Java interface if the interface supports exactly one matching method.
- coerceToArray
-
Expr coerceToArray(Expr expr, CType expected, |->Void| onErr)
Coerce a Fantom list to Java array.
- coerceToPrimitive
-
Expr coerceToPrimitive(Expr expr, JavaType expected, |->Void| onErr)
Coerce a fan expression to a Java primitive (other than the ones we support natively)
- cp
-
ClassPath cp
- decimalTypes
-
const static Str[] decimalTypes := ...
- fits
-
Bool fits(CType actual, CType expected)
Return if we can make the actual type fit the expected type, potentially using a coercion.
- floatTypes
-
const static Str[] floatTypes := ...
- generateFuncToInterfaceWrapper
-
CMethod generateFuncToInterfaceWrapper(Loc 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.
- intTypes
-
const static Str[] intTypes := ...
- isFuncToInterfaceMatch
-
Bool isFuncToInterfaceMatch(FuncType funcType, CMethod method)
Return if the specified function type can be used to implement the specified interface method.
- listAsArray
-
CMethod listAsArray()
Get a CMethod representation for
Object[] List.asArray()
- listMakeFromArray
-
CMethod listMakeFromArray()
Get a CMethod representation for
List.make(Type, Object[])
- make
-
new make(Compiler c)
Construct a JavaBridge for current environment
- objectArrayType
-
JavaType objectArrayType()
Get a CType representation for
java.lang.Object[]
- primitives
-
JavaPrimitives primitives := JavaPrimitives.<ctor>(this)
- resolveCall
-
virtual override CallExpr resolveCall(CallExpr call)
Resolve a method call: try to find the best match and apply any coercions needed.
- resolveConstruction
-
virtual override Expr resolveConstruction(CallExpr call)
Resolve a construction call to a Java constructor.
- resolveConstructorChain
-
virtual override Expr resolveConstructorChain(CallExpr call)
Resolve a construction chain call where a Fantom constructor calls the super-class constructor. Type check the arguments and insert any conversions needed.
- resolvePod
-
virtual override CPod resolvePod(Str name, Loc? loc)
Map a FFI "podName" to a Java package.
- resolveSlotAccess
-
virtual override CSlot? resolveSlotAccess(CType base, Str name, Bool noParens)
Given a dot operator slot access on the given foreign base type, determine the appopriate slot to use based on whether parens were used
base.name => noParens = true base.name() => noParens = false
In Java a given name could be bound to both a field and a method. In this case we only resolve the field if no parens are used. We also handle the special case of Java annotations here because their element methods are also mapped as Fantom fields (instance based mixin field).
- strTypes
-
const static Str[] strTypes := ...