public IBlockType getBlockType() { return (IBlockType) _root.getType(); }
private static boolean findAnnotation(List<IGosuAnnotation> annotations, IType annotationType) { for (IGosuAnnotation annotation : annotations) { if (annotation.getExpression().getType().equals(annotationType)) { return true; } } return false; }
private IType getType( IParsedElement pe ) { if( pe instanceof IExpression ) { return ((IExpression) pe).getType(); } else { return ((IVarStatement)pe).getType(); } }
private IType getType( IParsedElement pe ) { if( pe instanceof IExpression ) { return ((IExpression) pe).getType(); } else { return ((IVarStatement)pe).getType(); } }
protected void assignStructuralTypeOwner( IExpression rootExpr, IRExpression irMethodCall ) { if( rootExpr != null && rootExpr.getType() instanceof IGosuClass && ((IGosuClass)rootExpr.getType()).isStructure() ) { IRExpression mc = irMethodCall; while( mc instanceof IRCompositeExpression ) { List<IRElement> elements = ((IRCompositeExpression)mc).getElements(); mc = (IRExpression)elements.get( elements.size() -1 ); } ((IRMethodCallExpression)mc).setStructuralTypeOwner( GosuClassIRType.get( TypeLord.getPureGenericType( rootExpr.getType() ) ) ); } }
protected void assignStructuralTypeOwner( IExpression rootExpr, IRExpression irMethodCall ) { if( rootExpr != null && rootExpr.getType() instanceof IGosuClass && ((IGosuClass)rootExpr.getType()).isStructure() ) { IRExpression mc = irMethodCall; while( mc instanceof IRCompositeExpression ) { List<IRElement> elements = ((IRCompositeExpression)mc).getElements(); mc = (IRExpression)elements.get( elements.size() -1 ); } ((IRMethodCallExpression)mc).setStructuralTypeOwner( GosuClassIRType.get( TypeLord.getPureGenericType( rootExpr.getType() ) ) ); } } }
public MethodScoreKey putCachedMethodScore( MethodScore score ) { score.setScore( 0 ); List<IExpression> argExpressions = score.getArguments(); List<IType> argTypes = new ArrayList<>( argExpressions.size() ); for( IExpression argExpression : argExpressions ) { argTypes.add( argExpression.getType() ); } MethodScoreKey key = new MethodScoreKey( argTypes, score ); _methodScoreCache.put( key, score.getRawFunctionType() ); return key; } public void removeCachedMethodScore( MethodScoreKey key )
protected IRExpression compile_impl() { IExpression rhs = _expr().getExpression(); return pushType( rhs.getType() ); } }
protected IRExpression compile_impl() { IExpression rhs = _expr().getExpression(); return pushType( rhs.getType() ); } }
private List<IRExpression> boxArgs() { List<IRExpression> irArgs = new ArrayList<>(); for( IExpression arg : _expr().getArgs() ) { IRExpression irArg = ExpressionTransformer.compile( arg, _cc() ); irArgs.add( boxValue( arg.getType(), irArg ) ); } return irArgs; } }
private List<IRExpression> boxArgs() { List<IRExpression> irArgs = new ArrayList<IRExpression>(); for( IExpression arg : _expr().getArgs() ) { IRExpression irArg = ExpressionTransformer.compile( arg, _cc() ); irArgs.add( boxValue( arg.getType(), irArg ) ); } return irArgs; } }
public IType getFinalRootType() { if( _root instanceof TypeLiteral ) { return ((TypeLiteral)_root).getType().getType(); } else if( _root instanceof FeatureLiteral ) { return ((FeatureLiteral)_root).getFinalRootType(); } else { return _root.getType(); } }
public IType getFinalRootType() { if( _root instanceof TypeLiteral ) { return ((TypeLiteral)_root).getType().getType(); } else if( _root instanceof FeatureLiteral ) { return ((FeatureLiteral)_root).getFinalRootType(); } else { return _root.getType(); } }
private IType getRootTypeToResolveFeaturesAgainst() { if( _root instanceof FeatureLiteral ) { return ((FeatureLiteral)_root).getFeatureReturnType(); } else if( _root instanceof TypeLiteral ) { return ((TypeLiteral)_root).getType().getType(); } else { return _root.getType(); } }
protected IRExpression pushString( IExpression expr ) { if( expr.getType() != JavaTypes.STRING() ) { return callMethod( ICoercionManager.class, "makeStringFrom", new Class[]{Object.class}, callStaticMethod( CommonServices.class, "getCoercionManager", new Class[0], Collections.<IRExpression>emptyList() ), Collections.singletonList(ExpressionTransformer.compile( expr, _cc() ))); } else { return ExpressionTransformer.compile( expr, _cc() ); } }
protected IRExpression pushString( IExpression expr ) { if( expr.getType() != JavaTypes.STRING() ) { return callMethod( ICoercionManager.class, "makeStringFrom", new Class[]{Object.class}, callStaticMethod( CommonServices.class, "getCoercionManager", new Class[0], Collections.<IRExpression>emptyList() ), Collections.singletonList(ExpressionTransformer.compile( expr, _cc() ))); } else { return ExpressionTransformer.compile( expr, _cc() ); } }
protected IRStatement setScopedSymbolValue( ISymbol symbol, IExpression rhsValue ) { IRExpression methodCall = callMethod( IAttributeSource.class, "setAttribute", new Class[]{String.class, Object.class}, pushAttributeSource( (ScopedDynamicSymbol)symbol ), exprList( pushConstant( ((ScopedDynamicSymbol)symbol).getAttributeName() ), boxValue( rhsValue.getType(), ExpressionTransformer.compile( rhsValue, _cc() ) ) ) ); return new IRMethodCallStatement( methodCall ); }
protected IRStatement setScopedSymbolValue( IGosuVarPropertyInfo pi, IExpression rhsValue ) { IRExpression methodCall = callMethod( IAttributeSource.class, "setAttribute", new Class[]{String.class, Object.class}, pushAttributeSource( pi ), exprList( pushConstant( pi.getSymbolAttributeName() ), boxValue( rhsValue.getType(), ExpressionTransformer.compile( rhsValue, _cc() ) ) ) ); return new IRMethodCallStatement( methodCall ); }