org.eclipse.xtext.xbase.compiler
Class AbstractXbaseCompiler

java.lang.Object
  extended by org.eclipse.xtext.xbase.compiler.AbstractXbaseCompiler
Direct Known Subclasses:
TypeConvertingCompiler

public abstract class AbstractXbaseCompiler
extends java.lang.Object

Author:
Sven Efftinge - Initial contribution and API

Constructor Summary
AbstractXbaseCompiler()
           
 
Method Summary
 void _toJavaExpression(java.lang.Void func, IAppendable b)
           
 void _toJavaExpression(XExpression func, IAppendable b)
           
 void _toJavaStatement(java.lang.Void func, IAppendable b, boolean isReferenced)
           
 void _toJavaStatement(XExpression func, IAppendable b, boolean isReferenced)
           
protected  boolean canCompileToJavaExpression(XExpression expression, IAppendable appendable)
           
 IAppendable compile(XBlockExpression expr, IAppendable b, JvmTypeReference expectedReturnType)
          this one trims the outer block
 IAppendable compile(XExpression obj, IAppendable appendable, JvmTypeReference expectedReturnType)
           
 IAppendable compile(XExpression obj, IAppendable appendable, JvmTypeReference expectedReturnType, java.util.Set<JvmTypeReference> declaredExceptions)
           
 IAppendable compileAsJavaExpression(XExpression obj, IAppendable appendable, JvmTypeReference expectedType)
           
protected  void declareSyntheticVariable(XExpression expr, IAppendable b)
           
protected  void declareSyntheticVariable(XExpression expr, IAppendable b, Later expression)
          TODO rename this method to 'declareFreshLocalVariable' after 2.1.x
protected  java.lang.String getDefaultValueLiteral(XExpression expr)
           
protected  java.lang.String getFavoriteVariableName(org.eclipse.emf.ecore.EObject ex)
           
protected  IdentifiableSimpleNameProvider getNameProvider()
           
protected  Primitives getPrimitives()
           
protected  TypeConformanceComputer getTypeConformanceComputer()
           
protected  ITypeProvider getTypeProvider()
           
protected  TypeReferences getTypeReferences()
           
protected  java.lang.String getVarName(java.lang.Object ex, IAppendable appendable)
           
protected abstract  void internalToConvertedExpression(XExpression obj, IAppendable appendable, JvmTypeReference toBeConvertedTo)
           
protected  void internalToJavaExpression(XExpression obj, IAppendable appendable)
           
protected  void internalToJavaStatement(XExpression obj, IAppendable builder, boolean isReferenced)
           
protected  boolean isPrimitiveVoid(XExpression xExpression)
           
protected  boolean isReferenceToForeignTypeParameter(JvmTypeReference reference, org.eclipse.emf.ecore.EObject context)
           
protected  boolean isVariableDeclarationRequired(XExpression expr, IAppendable b)
          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.String makeJavaIdentifier(java.lang.String name)
           
protected  boolean needsSneakyThrow(XExpression obj, java.util.Set<JvmTypeReference> declaredExceptions)
           
protected  JvmTypeReference resolveMultiType(JvmTypeReference typeRef)
           
protected  void serialize(JvmTypeReference type, org.eclipse.emf.ecore.EObject context, IAppendable appendable)
           
protected  void serialize(JvmTypeReference type, org.eclipse.emf.ecore.EObject context, IAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard)
           
protected  void serialize(JvmTypeReference type, org.eclipse.emf.ecore.EObject context, IAppendable appendable, boolean withoutConstraints, boolean paramsToWildcard, boolean paramsToObject, boolean allowPrimitives)
           
 void setNameProvider(IdentifiableSimpleNameProvider nameProvider)
           
 void setTypeReferences(TypeReferences typeReferences)
          Public for testing purpose.
 void toJavaExpression(XExpression obj, IAppendable appendable)
           
 void toJavaStatement(XExpression obj, IAppendable appendable, boolean isReferenced)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractXbaseCompiler

public AbstractXbaseCompiler()
Method Detail

getTypeReferences

protected TypeReferences getTypeReferences()

setTypeReferences

public void setTypeReferences(TypeReferences typeReferences)
Public for testing purpose.

This method is not intended to be referenced by clients.
This method is not intended to be referenced by clients.

getTypeProvider

protected ITypeProvider getTypeProvider()

getPrimitives

protected Primitives getPrimitives()

compile

public IAppendable compile(XExpression obj,
                           IAppendable appendable,
                           JvmTypeReference expectedReturnType)

compileAsJavaExpression

public IAppendable compileAsJavaExpression(XExpression obj,
                                           IAppendable appendable,
                                           JvmTypeReference expectedType)

canCompileToJavaExpression

protected boolean canCompileToJavaExpression(XExpression expression,
                                             IAppendable appendable)

compile

public IAppendable compile(XExpression obj,
                           IAppendable appendable,
                           JvmTypeReference expectedReturnType,
                           java.util.Set<JvmTypeReference> declaredExceptions)

needsSneakyThrow

protected boolean needsSneakyThrow(XExpression obj,
                                   java.util.Set<JvmTypeReference> declaredExceptions)

compile

public IAppendable compile(XBlockExpression expr,
                           IAppendable b,
                           JvmTypeReference expectedReturnType)
this one trims the outer block


internalToConvertedExpression

protected abstract void internalToConvertedExpression(XExpression obj,
                                                      IAppendable appendable,
                                                      JvmTypeReference toBeConvertedTo)

isPrimitiveVoid

protected boolean isPrimitiveVoid(XExpression xExpression)

internalToJavaStatement

protected void internalToJavaStatement(XExpression obj,
                                       IAppendable builder,
                                       boolean isReferenced)

toJavaExpression

public void toJavaExpression(XExpression obj,
                             IAppendable appendable)

toJavaStatement

public void toJavaStatement(XExpression obj,
                            IAppendable appendable,
                            boolean isReferenced)

internalToJavaExpression

protected void internalToJavaExpression(XExpression obj,
                                        IAppendable appendable)

_toJavaStatement

public void _toJavaStatement(XExpression func,
                             IAppendable b,
                             boolean isReferenced)

_toJavaExpression

public void _toJavaExpression(XExpression func,
                              IAppendable b)

_toJavaStatement

public void _toJavaStatement(java.lang.Void func,
                             IAppendable b,
                             boolean isReferenced)

_toJavaExpression

public void _toJavaExpression(java.lang.Void func,
                              IAppendable b)

serialize

protected void serialize(JvmTypeReference type,
                         org.eclipse.emf.ecore.EObject context,
                         IAppendable appendable)

serialize

protected void serialize(JvmTypeReference type,
                         org.eclipse.emf.ecore.EObject context,
                         IAppendable appendable,
                         boolean withoutConstraints,
                         boolean paramsToWildcard)

serialize

protected void serialize(JvmTypeReference type,
                         org.eclipse.emf.ecore.EObject context,
                         IAppendable appendable,
                         boolean withoutConstraints,
                         boolean paramsToWildcard,
                         boolean paramsToObject,
                         boolean allowPrimitives)

isReferenceToForeignTypeParameter

protected boolean isReferenceToForeignTypeParameter(JvmTypeReference reference,
                                                    org.eclipse.emf.ecore.EObject context)

resolveMultiType

protected JvmTypeReference resolveMultiType(JvmTypeReference typeRef)

getVarName

protected java.lang.String getVarName(java.lang.Object ex,
                                      IAppendable 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)

declareSyntheticVariable

protected void declareSyntheticVariable(XExpression expr,
                                        IAppendable b)

getDefaultValueLiteral

protected java.lang.String getDefaultValueLiteral(XExpression expr)

declareSyntheticVariable

protected void declareSyntheticVariable(XExpression expr,
                                        IAppendable b,
                                        Later expression)
TODO rename this method to 'declareFreshLocalVariable' after 2.1.x


isVariableDeclarationRequired

protected boolean isVariableDeclarationRequired(XExpression expr,
                                                IAppendable b)
whether an expression needs to be declared in a statement If an expression has side effects this method must return true for it.


getTypeConformanceComputer

protected TypeConformanceComputer getTypeConformanceComputer()