Package org.eclipse.xtext.xbase.compiler
Class AbstractXbaseCompiler
- java.lang.Object
-
- org.eclipse.xtext.xbase.compiler.AbstractXbaseCompiler
-
- Direct Known Subclasses:
TypeConvertingCompiler
public abstract class AbstractXbaseCompiler extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description AbstractXbaseCompiler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void_toJavaExpression(XExpression func, ITreeAppendable b)void_toJavaStatement(XExpression func, ITreeAppendable b, boolean isReferenced)protected voidappendDefaultLiteral(ITreeAppendable b, LightweightTypeReference type)protected booleancanCompileToJavaExpression(XExpression expression, ITreeAppendable appendable)ITreeAppendablecompile(XBlockExpression expr, ITreeAppendable b, LightweightTypeReference expectedReturnType)this one trims the outer blockITreeAppendablecompile(XExpression obj, ITreeAppendable parentAppendable, org.eclipse.xtext.common.types.JvmTypeReference expectedReturnType, java.util.Set<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)ITreeAppendablecompile(XExpression obj, ITreeAppendable appendable, LightweightTypeReference expectedReturnType)ITreeAppendablecompile(XExpression obj, ITreeAppendable parentAppendable, LightweightTypeReference expectedReturnType, java.util.Set<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)ITreeAppendablecompileAsJavaExpression(XExpression obj, ITreeAppendable parentAppendable, org.eclipse.xtext.common.types.JvmTypeReference expectedType)ITreeAppendablecompileAsJavaExpression(XExpression obj, ITreeAppendable parentAppendable, LightweightTypeReference expectedType)protected voidcompileWithJvmConstructorCall(XBlockExpression obj, ITreeAppendable apendable)protected voiddeclareFreshLocalVariable(XExpression expr, ITreeAppendable b, Later expression)protected voiddeclareSyntheticVariable(XExpression expr, ITreeAppendable b)protected voiddoInternalToJavaStatement(XExpression obj, ITreeAppendable builder, boolean isReferenced)protected org.eclipse.xtext.common.types.JvmTypefindKnownTopLevelType(java.lang.Class<?> rawType, org.eclipse.emf.common.notify.Notifier context)protected org.eclipse.xtext.common.types.JvmTypefindKnownType(java.lang.Class<?> rawType, org.eclipse.emf.common.notify.Notifier context)protected voidgenerateCheckedExceptionHandling(ITreeAppendable appendable)protected java.lang.StringgetDefaultValueLiteral(XExpression expr)protected org.eclipse.xtext.common.types.JvmTypeReferencegetExpectedType(XExpression expr)protected java.lang.StringgetFavoriteVariableName(org.eclipse.emf.ecore.EObject ex)protected LightweightTypeReferencegetLightweightExpectedType(XExpression expr)protected LightweightTypeReferencegetLightweightReturnType(XExpression expr)protected LightweightTypeReferencegetLightweightType(org.eclipse.xtext.common.types.JvmIdentifiableElement identifiable)protected LightweightTypeReferencegetLightweightType(XExpression expr)protected IdentifiableSimpleNameProvidergetNameProvider()protected java.lang.StringgetReferenceName(XExpression expr, ITreeAppendable b)protected IResolvedTypesgetResolvedTypes(org.eclipse.emf.ecore.EObject obj)protected org.eclipse.xtext.common.types.JvmTypeReferencegetType(org.eclipse.xtext.common.types.JvmIdentifiableElement identifiable)protected org.eclipse.xtext.common.types.JvmTypeReferencegetType(XExpression expr)protected CommonTypeComputationServicesgetTypeComputationServices()protected LightweightTypeReferencegetTypeForVariableDeclaration(XExpression expr)TypeReferenceSerializergetTypeReferenceSerializer()protected java.lang.StringgetVarName(java.lang.Object ex, ITreeAppendable appendable)protected booleanhasJvmConstructorCall(XExpression obj)protected booleanhasUnhandledException(java.util.List<LightweightTypeReference> thrownExceptions, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)protected booleaninternalCanCompileToJavaExpression(XExpression expression, ITreeAppendable appendable)protected abstract voidinternalToConvertedExpression(XExpression obj, ITreeAppendable appendable, LightweightTypeReference toBeConvertedTo)protected voidinternalToJavaExpression(XExpression obj, ITreeAppendable appendable)protected voidinternalToJavaStatement(XExpression obj, ITreeAppendable builder, boolean isReferenced)protected booleanisEarlyExit(XExpression expr)protected booleanisJavaConformant(LightweightTypeReference left, LightweightTypeReference right)protected booleanisPrimitiveVoid(org.eclipse.xtext.common.types.JvmTypeReference typeRef)protected booleanisPrimitiveVoid(XExpression xExpression)protected booleanisReferenceToForeignTypeParameter(org.eclipse.xtext.common.types.JvmTypeReference reference, org.eclipse.emf.ecore.EObject context)protected booleanisUnhandledException(LightweightTypeReference thrownException, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)protected booleanisVariableDeclarationRequired(XExpression expr, ITreeAppendable b)Deprecated.protected booleanisVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive)whether an expression needs to be declared in a statement If an expression has side effects this method must return true for it.protected java.lang.StringmakeJavaIdentifier(java.lang.String name)protected booleanneedsSneakyThrow(XExpression obj, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)protected ITypeReferenceOwnernewTypeReferenceOwner(org.eclipse.emf.ecore.EObject context)protected org.eclipse.xtext.common.types.JvmTypeReferenceresolveMultiType(org.eclipse.xtext.common.types.JvmTypeReference typeRef, org.eclipse.emf.ecore.EObject context)protected voidserialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable)protected voidserialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard)protected voidserialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard, boolean paramsToObject, boolean allowPrimitives)voidsetNameProvider(IdentifiableSimpleNameProvider nameProvider)voidtoJavaExpression(XExpression obj, ITreeAppendable appendable)voidtoJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced)protected LightweightTypeReferencetoLightweight(org.eclipse.xtext.common.types.JvmTypeReference reference, org.eclipse.emf.ecore.EObject context)
-
-
-
Method Detail
-
getTypeReferenceSerializer
public TypeReferenceSerializer getTypeReferenceSerializer()
-
findKnownTopLevelType
protected org.eclipse.xtext.common.types.JvmType findKnownTopLevelType(java.lang.Class<?> rawType, org.eclipse.emf.common.notify.Notifier context)
-
findKnownType
protected org.eclipse.xtext.common.types.JvmType findKnownType(java.lang.Class<?> rawType, org.eclipse.emf.common.notify.Notifier context)
-
getTypeComputationServices
protected CommonTypeComputationServices getTypeComputationServices()
-
newTypeReferenceOwner
protected ITypeReferenceOwner newTypeReferenceOwner(org.eclipse.emf.ecore.EObject context)
-
toLightweight
protected LightweightTypeReference toLightweight(org.eclipse.xtext.common.types.JvmTypeReference reference, org.eclipse.emf.ecore.EObject context)
-
compile
public ITreeAppendable compile(XExpression obj, ITreeAppendable appendable, LightweightTypeReference expectedReturnType)
-
compileAsJavaExpression
public ITreeAppendable compileAsJavaExpression(XExpression obj, ITreeAppendable parentAppendable, org.eclipse.xtext.common.types.JvmTypeReference expectedType)
-
compileAsJavaExpression
public ITreeAppendable compileAsJavaExpression(XExpression obj, ITreeAppendable parentAppendable, LightweightTypeReference expectedType)
-
appendDefaultLiteral
protected void appendDefaultLiteral(ITreeAppendable b, LightweightTypeReference type)
-
generateCheckedExceptionHandling
protected void generateCheckedExceptionHandling(ITreeAppendable appendable)
-
canCompileToJavaExpression
protected boolean canCompileToJavaExpression(XExpression expression, ITreeAppendable appendable)
-
internalCanCompileToJavaExpression
protected boolean internalCanCompileToJavaExpression(XExpression expression, ITreeAppendable appendable)
- Parameters:
expression- to be used by subtypesappendable- to be used by subtypes
-
compile
public ITreeAppendable compile(XExpression obj, ITreeAppendable parentAppendable, org.eclipse.xtext.common.types.JvmTypeReference expectedReturnType, java.util.Set<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)
-
compile
public ITreeAppendable compile(XExpression obj, ITreeAppendable parentAppendable, LightweightTypeReference expectedReturnType, java.util.Set<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)
-
compileWithJvmConstructorCall
protected void compileWithJvmConstructorCall(XBlockExpression obj, ITreeAppendable apendable)
-
hasJvmConstructorCall
protected boolean hasJvmConstructorCall(XExpression obj)
-
needsSneakyThrow
protected boolean needsSneakyThrow(XExpression obj, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)
-
hasUnhandledException
protected boolean hasUnhandledException(java.util.List<LightweightTypeReference> thrownExceptions, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)
-
isUnhandledException
protected boolean isUnhandledException(LightweightTypeReference thrownException, java.util.Collection<org.eclipse.xtext.common.types.JvmTypeReference> declaredExceptions)
-
compile
public ITreeAppendable compile(XBlockExpression expr, ITreeAppendable b, LightweightTypeReference expectedReturnType)
this one trims the outer block
-
isEarlyExit
protected boolean isEarlyExit(XExpression expr)
-
isPrimitiveVoid
protected boolean isPrimitiveVoid(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
-
getType
protected org.eclipse.xtext.common.types.JvmTypeReference getType(XExpression expr)
-
getType
protected org.eclipse.xtext.common.types.JvmTypeReference getType(org.eclipse.xtext.common.types.JvmIdentifiableElement identifiable)
-
getLightweightType
protected LightweightTypeReference getLightweightType(XExpression expr)
-
getLightweightType
protected LightweightTypeReference getLightweightType(org.eclipse.xtext.common.types.JvmIdentifiableElement identifiable)
-
getLightweightReturnType
protected LightweightTypeReference getLightweightReturnType(XExpression expr)
-
getResolvedTypes
protected IResolvedTypes getResolvedTypes(org.eclipse.emf.ecore.EObject obj)
-
getExpectedType
protected org.eclipse.xtext.common.types.JvmTypeReference getExpectedType(XExpression expr)
-
getLightweightExpectedType
protected LightweightTypeReference getLightweightExpectedType(XExpression expr)
-
internalToConvertedExpression
protected abstract void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable, LightweightTypeReference toBeConvertedTo)
-
isPrimitiveVoid
protected boolean isPrimitiveVoid(XExpression xExpression)
-
internalToJavaStatement
protected final void internalToJavaStatement(XExpression obj, ITreeAppendable builder, boolean isReferenced)
-
doInternalToJavaStatement
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable builder, boolean isReferenced)
-
toJavaExpression
public void toJavaExpression(XExpression obj, ITreeAppendable appendable)
-
toJavaStatement
public void toJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced)
-
internalToJavaExpression
protected void internalToJavaExpression(XExpression obj, ITreeAppendable appendable)
-
_toJavaStatement
public void _toJavaStatement(XExpression func, ITreeAppendable b, boolean isReferenced)
- Parameters:
b- the appendable, unused, but necessary for dispatching purposeisReferenced- unused, but necessary for dispatching purpose
-
_toJavaExpression
public void _toJavaExpression(XExpression func, ITreeAppendable b)
- Parameters:
b- the appendable, unused, but necessary for dispatching purpose
-
serialize
protected void serialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable)
-
serialize
protected void serialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard)
-
serialize
protected void serialize(org.eclipse.xtext.common.types.JvmTypeReference type, org.eclipse.emf.ecore.EObject context, ITreeAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard, boolean paramsToObject, boolean allowPrimitives)
-
isReferenceToForeignTypeParameter
protected boolean isReferenceToForeignTypeParameter(org.eclipse.xtext.common.types.JvmTypeReference reference, org.eclipse.emf.ecore.EObject context)
-
resolveMultiType
protected org.eclipse.xtext.common.types.JvmTypeReference resolveMultiType(org.eclipse.xtext.common.types.JvmTypeReference typeRef, org.eclipse.emf.ecore.EObject context)
-
getVarName
protected java.lang.String getVarName(java.lang.Object ex, ITreeAppendable appendable)
-
setNameProvider
public void setNameProvider(IdentifiableSimpleNameProvider nameProvider)
-
getNameProvider
protected IdentifiableSimpleNameProvider getNameProvider()
-
getFavoriteVariableName
protected java.lang.String getFavoriteVariableName(org.eclipse.emf.ecore.EObject ex)
-
makeJavaIdentifier
protected java.lang.String makeJavaIdentifier(java.lang.String name)
-
isJavaConformant
protected boolean isJavaConformant(LightweightTypeReference left, LightweightTypeReference right)
-
declareSyntheticVariable
protected void declareSyntheticVariable(XExpression expr, ITreeAppendable b)
-
getDefaultValueLiteral
protected java.lang.String getDefaultValueLiteral(XExpression expr)
-
declareFreshLocalVariable
protected void declareFreshLocalVariable(XExpression expr, ITreeAppendable b, Later expression)
-
getTypeForVariableDeclaration
protected LightweightTypeReference getTypeForVariableDeclaration(XExpression expr)
-
isVariableDeclarationRequired
@Deprecated protected final boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b)
Deprecated.whether an expression needs to be declared in a statement If an expression has side effects this method must return true for it.- Parameters:
expr- the checked expressionb- the appendable which represents the current compiler state
-
isVariableDeclarationRequired
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive)
whether an expression needs to be declared in a statement If an expression has side effects this method must return true for it.- Parameters:
expr- the checked expressionb- the appendable which represents the current compiler staterecursive- determines if the siblings of the expression shall be investigated too to determine the is variable declaration required status
-
getReferenceName
protected java.lang.String getReferenceName(XExpression expr, ITreeAppendable b)
- Returns:
- the variable name under which the result of the expression is stored. Returns
nullif the expression hasn't been assigned to a local variable before.
-
-