FunctionTypeSpec

public final class FunctionTypeSpec extends TypeSpec

A type for functions and procedures, for instance (arg1T, arg2T…)→returnT.

Fields

argumentsTypes

public WrapperTypeSpec[] argumentsTypes

The array of arguments types of this function type.

returnType

public WrapperTypeSpec returnType

The return type of this function type.

variableArgList

public boolean variableArgList

True if this the type of a function with a variable number of arguments.

Constructors

FunctionTypeSpec

public FunctionTypeSpec()

Create a new function type, empty.

FunctionTypeSpec

public FunctionTypeSpec(WrapperTypeSpec returnType)

Create a new function type, with the given return type.

FunctionTypeSpec

public FunctionTypeSpec(WrapperTypeSpec returnType, WrapperTypeSpec[] argumentsTypes)

Create a new function type, with the given arguments types and return type.

FunctionTypeSpec

public FunctionTypeSpec(WrapperTypeSpec returnType, WrapperTypeSpec[] argumentsTypes, boolean varArgList)

Create a new function type of variable arguments length, with the given arguments types and return type.

FunctionTypeSpec

public FunctionTypeSpec(WrapperTypeSpec returnType, TapList<WrapperTypeSpec> paramsTypes)

Create a new function type, with the given arguments types and return type.

Methods

baseTypeName

protected String baseTypeName()

baseTypeSpec

public WrapperTypeSpec baseTypeSpec(boolean stopOnPointer)

checkTypeSpecValidity

protected boolean checkTypeSpecValidity(TapList<TypeSpec> dejaVu)

complexAbsAmbiguous

public static boolean complexAbsAmbiguous(String unitName, TypeSpec[] formalArgsTypes, TypeSpec[] actualArgsTypes)

Returns true when this unitName, called with actualArgsTypes that possibly match its formalArgsTypes, and therefore that seems to match the call site, actually does NOT match because it is an “abs” (absolute value) actually called on floats whereas this Unit is about “abs” called on complex. The fact that we need this test may be seen as a weakness or a bug in the actual type-checking process

computeSize

protected int computeSize()

containsMetaType

protected boolean containsMetaType(TapList<TypeSpec> dejaVu)

containsUnknownDimension

public boolean containsUnknownDimension()

copy

public TypeSpec copy()

Shallow copy of this function type.

copyStopOnComposite

public TypeSpec copyStopOnComposite(Unit publishedUnit)

differentiateTypeSpec

public WrapperTypeSpec differentiateTypeSpec(SymbolTable symbolTable, SymbolTable srcSymbolTable, int diffUnitSort, String fSuffix, boolean localDecl, boolean multiDirMode, ArrayDim multiDirDimensionMax, String hintArrayNameInText, String hintArrayNameInIdent, Tree hintArrayNameTree, Tree nameTree)

doUpdateAfterImports

public void doUpdateAfterImports(SymbolTable symbolTable, TapList<TypeSpec> dejaVu)

dump

public void dump()

finishLastMetaTypes

protected static void finishLastMetaTypes(TapList<TapTriplet<TypeSpec, TypeSpec, Boolean>> toAlreadySolved, SymbolTable symbolTable)

Replace remaining unsolved meta types with primitive types deduced from the name of the meta type e.g. “float…” → PrimitiveTypeSpec(“float”).

generateTree

public Tree generateTree(SymbolTable symbolTable, TapList<SymbolDecl> dependsOn, TapList<SymbolDecl> shortNames, boolean useShortNames, TapList<TypeSpec> dejaVu)

isAFunction

public boolean isAFunction()
Returns

true when this has a non-void return type.

isFunction

public boolean isFunction()

localize

public TypeSpec localize(TapList<TapTriplet<TypeSpec, TypeSpec, Boolean>> toAlreadyCopied, ToBool containsMeta)

matchArgumentsTypes

protected void matchArgumentsTypes(WrapperTypeSpec[] actualArgsTypes, Unit ctxtUnit, Unit calledUnit)

Instantiate this formal type of a function with the actual types “actualArgsTypes” of a particular call. This function formal type must be localized i.e. it is a copy that will not influence by unification the true, central, formal type of the function.

matchesCall

public boolean matchesCall(TypeSpec callResultType, TypeSpec[] callArgTypes)

Tests that this function type can be called with the given actual types, i.e. the arguments number matches and each arg formal type is larger than (i.e. is more general than, or “contains”, or could receive) the actual arg type.

Parameters
  • callResultType – The expected result type at call site. May be null. (not used at present)

  • callArgTypes – The array of the actual arguments types at call site. May be null if unknown.

Returns

true if this function type matches the actual call, or may be made to match it by instantiating its “meta” types..

matchesCallExactly

public boolean matchesCallExactly(TypeSpec callResultType, TypeSpec[] callArgTypes)

sameTypes

public boolean sameTypes(WrapperTypeSpec otherReturnType, WrapperTypeSpec[] otherArgumentsTypes)

setReturnTypeSpec

public void setReturnTypeSpec(WrapperTypeSpec typeSpec, Tree declaratorI)

setWrappedType

public void setWrappedType(TypeSpec type)

showType

public String showType()

testComparesWith

protected boolean testComparesWith(TypeSpec other, int comparison, TypeSpec toThis, TypeSpec toOther, TapList<TapPair<TypeSpec, TypeSpec>> dejaVu)

toString

public String toString()

wrappedType

public TypeSpec wrappedType()