class compilerJava::JavaBridge

sys::Obj
  compiler::CompilerSupport
    compiler::CBridge
      compilerJava::JavaBridge

Source

JavaBridge is the compiler plugin for bringing Java classes into the Fantom type system.

areParamsSame

static Bool areParamsSame(CMethod a, CMethod b)

Source

Do the two methods have the exact same parameter types.

boolTypes

const static Str[] boolTypes := ...

Source

checkOverride

virtual override Void checkOverride(TypeDef t, CSlot base, SlotDef def)

Source

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)

Source

Called during CheckErrors step for a type which extends a FFI class or implements any FFI mixins.

classType

JavaType classType()

Source

Get a CType representation for java.lang.Class

cleanup

virtual override Void cleanup()

Source

coerce

virtual override Expr coerce(Expr expr, CType expected, |->Void| onErr)

Source

Coerce expression to expected type. If not a type match then run the onErr function.

coerceFromArray

Expr coerceFromArray(Expr expr, CType expected, |->Void| onErr)

Source

Coerce a Java array to a Fantom list.

coerceFromPrimitive

Expr coerceFromPrimitive(Expr expr, CType expected, |->Void| onErr)

Source

Coerce a Java primitive to a Fantom type.

coerceFuncToInterface

Expr coerceFuncToInterface(Expr expr, JavaType expected, |->Void| onErr)

Source

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)

Source

Coerce a Fantom list to Java array.

coerceToPrimitive

Expr coerceToPrimitive(Expr expr, JavaType expected, |->Void| onErr)

Source

Coerce a fan expression to a Java primitive (other than the ones we support natively)

cp

ClassPath cp

Source

decimalTypes

const static Str[] decimalTypes := ...

Source

fits

Bool fits(CType actual, CType expected)

Source

Return if we can make the actual type fit the expected type, potentially using a coercion.

floatTypes

const static Str[] floatTypes := ...

Source

generateFuncToInterfaceWrapper

CMethod generateFuncToInterfaceWrapper(Loc loc, FuncType funcType, CType expected, CMethod method)

Source

Generate the wrapper which implements the specified expected interface and overrides the specified method which calls the function.

intTypes

const static Str[] intTypes := ...

Source

isFuncToInterfaceMatch

Bool isFuncToInterfaceMatch(FuncType funcType, CMethod method)

Source

Return if the specified function type can be used to implement the specified interface method.

listAsArray

CMethod listAsArray()

Source

Get a CMethod representation for Object[] List.asArray()

listMakeFromArray

CMethod listMakeFromArray()

Source

Get a CMethod representation for List.make(Type, Object[])

make

new make(Compiler c)

Source

Construct a JavaBridge for current environment

objectArrayType

JavaType objectArrayType()

Source

Get a CType representation for java.lang.Object[]

primitives

JavaPrimitives primitives := JavaPrimitives.<ctor>(this)

Source

resolveCall

virtual override CallExpr resolveCall(CallExpr call)

Source

Resolve a method call: try to find the best match and apply any coercions needed.

resolveConstruction

virtual override Expr resolveConstruction(CallExpr call)

Source

Resolve a construction call to a Java constructor.

resolveConstructorChain

virtual override Expr resolveConstructorChain(CallExpr call)

Source

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)

Source

Map a FFI "podName" to a Java package.

resolveSlotAccess

virtual override CSlot? resolveSlotAccess(CType base, Str name, Bool noParens)

Source

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 := ...

Source