public static MethodList getMethods( ITypeInfo beanInfo, IType whosaskin ) { if( beanInfo instanceof IRelativeTypeInfo && whosaskin != null ) { return ((IRelativeTypeInfo)beanInfo).getMethods( whosaskin ); } else { return beanInfo.getMethods(); } }
public static MethodList getMethods( ITypeInfo beanInfo, IType whosaskin ) { if( beanInfo instanceof IRelativeTypeInfo && whosaskin != null ) { return ((IRelativeTypeInfo)beanInfo).getMethods( whosaskin ); } else { return beanInfo.getMethods(); } }
private List<? extends IMethodInfo> getMethods(ITypeInfo typeInfo) { if (typeInfo instanceof IRelativeTypeInfo) { return ((IRelativeTypeInfo)typeInfo).getMethods(typeInfo.getOwnersType()); } else { return typeInfo.getMethods(); } }
private List<? extends IMethodInfo> getMethods(ITypeInfo typeInfo) { if (typeInfo instanceof IRelativeTypeInfo) { return ((IRelativeTypeInfo)typeInfo).getMethods(typeInfo.getOwnersType()); } else { return typeInfo.getMethods(); } }
private IMethodInfo getSingleMethodWithName( String methodName, IType typeToResolveAgainst, ITypeInfo typeInfo ) { MethodList methods; if( typeInfo instanceof IRelativeTypeInfo ) { methods = ((IRelativeTypeInfo)typeInfo).getMethods( typeToResolveAgainst ); } else { methods = typeInfo.getMethods(); } IMethodInfo match = null; for( IMethodInfo possibleMatch : methods ) { if( possibleMatch.getDisplayName().equals( methodName ) ) { if( match != null ) { return null; // more than one, bail } else { match = possibleMatch; } } } return match; }
public static IMethodInfo findCallableMethod( String methodName, IType[] runtimeTypes, IType type ) { ITypeInfo typeInfo = type.getTypeInfo(); MethodList methodInfos = typeInfo instanceof IRelativeTypeInfo ? ((IRelativeTypeInfo)typeInfo).getMethods( type ) : typeInfo.getMethods(); return ITypeInfo.FIND.callableMethod( methodInfos, methodName, runtimeTypes ); }
public static IMethodInfo findCallableMethod( String methodName, IType[] runtimeTypes, IType type ) { ITypeInfo typeInfo = type.getTypeInfo(); MethodList methodInfos = typeInfo instanceof IRelativeTypeInfo ? ((IRelativeTypeInfo)typeInfo).getMethods( type ) : typeInfo.getMethods(); return ITypeInfo.FIND.callableMethod( methodInfos, methodName, runtimeTypes ); }
private List<? extends IInvocableType> getMethodTypes( String name ) { ArrayList<IInvocableType> functionTypes = new ArrayList<>(); IType rootType = getRootTypeToResolveFeaturesAgainst(); ITypeInfo typeInfo = rootType.getTypeInfo(); List<? extends IMethodInfo> methods; if( typeInfo instanceof IRelativeTypeInfo ) { methods = ((IRelativeTypeInfo)typeInfo).getMethods( rootType ); } else { methods = typeInfo.getMethods(); } for( IMethodInfo mi : methods ) { if( mi.getDisplayName().equals( name ) ) { functionTypes.add( new FunctionType( mi ) ); } } return functionTypes; }
private static IMethodInfo findMethod( IJavaType genType, IJavaClassMethod method ) { MethodList methods = ((IRelativeTypeInfo)genType.getTypeInfo()).getMethods( genType ); for( IMethodInfo mi: methods.getMethods( method.getName() ) ) { if( mi instanceof IJavaMethodInfo && ((IJavaMethodInfo)mi).getMethod() == method ) { return mi; } } return null; }
? ((IRelativeTypeInfo)beanInfo).getMethods( _whosaskin ) : beanInfo.getMethods(); Set<String> signatures = new CaseInsensitiveSet<String>();
? ((IRelativeTypeInfo)beanInfo).getMethods( _whosaskin ) : beanInfo.getMethods(); Set<String> signatures = new CaseInsensitiveSet<String>();
protected void mergeMethods(List<IMethodInfo> methods, IType type, boolean replace) { List<? extends IMethodInfo> methodInfos; if (type != null && !TypeSystem.isDeleted(type)) { if (type.getTypeInfo() instanceof IRelativeTypeInfo) { methodInfos = ((IRelativeTypeInfo) type.getTypeInfo()).getMethods( _typeInfo.getOwnersType()); } else { methodInfos = type.getTypeInfo().getMethods(); } for (IMethodInfo methodInfo : methodInfos) { mergeMethod(methods, methodInfo, replace); } } }
private int makeMethodNameId() { if( getEnclosingType() instanceof FunctionType ) { IFeatureInfo mi = ((FunctionType)getEnclosingType()).getMethodOrConstructorInfo(); if( mi != null ) { IType cls = getEnclosingType().getEnclosingType(); if( cls instanceof IGosuClass && ((IGosuClass)cls).isDeclarationsCompiled() ) { MethodList methods = ((IRelativeTypeInfo)cls.getTypeInfo()).getMethods( cls ); int miIndex = methods.indexOf( mi ); if( miIndex >= 0 ) { return miIndex; } } } } // Declaring class not yet finished decl compiling, use identity hash for the interim... // or not a gosu class and don't java function context... return System.identityHashCode( this ); }
private IRStatement compileProgramExecute() { List<IType> paramTypes = new ArrayList<IType>(); IMethodInfo evaluateMethod = null; for( IMethodInfo mi : getGosuClass().getTypeInfo().getMethods() ) { if( mi.getName().startsWith( "evaluate(" ) ) { evaluateMethod = mi; for( IParameterInfo param : mi.getParameters() ) { IType paramType = param.getFeatureType(); paramTypes.add( paramType ); } break; } } boolean bArgs = _dfs.getArgTypes().length > 0; IRExpression newProgram = buildNewExpression( IRTypeResolver.getDescriptor( getGosuClass() ), Collections.<IRType>emptyList(), Collections.<IRExpression>emptyList() ); IRMethod evaluateIRMethod = IRMethodFactory.createIRMethod( getGosuClass(), "evaluate", evaluateMethod.getReturnType(), paramTypes.toArray( new IType[paramTypes.size()] ), IRelativeTypeInfo.Accessibility.PUBLIC, false ); IRExpression callEvaluate = callMethod( evaluateIRMethod, newProgram, Collections.singletonList( nullLiteral() ) ); IRExpression setRawArgs = callStaticMethod( Gosu.class, "setRawArgs", new Class[]{String[].class}, exprList( bArgs ? identifier( _cc().getSymbol( _dfs.getArgs().get( 0 ).getName() ) ) : pushNull() ) ); return new IRStatementList( true, buildMethodCall( setRawArgs ), new IRReturnStatement( null, callEvaluate ) ); }
public boolean resolveMethod( String methodName, List<IType> typesList ) { IType[] argTypes = typesList.toArray( new IType[typesList.size()] ); IType typeToResolveAgainst = getRootTypeToResolveFeaturesAgainst(); ITypeInfo typeInfo = typeToResolveAgainst.getTypeInfo(); IMethodInfo methodInfo; if( typeInfo instanceof IRelativeTypeInfo ) { methodInfo = ITypeInfo.FIND.callableMethod(((IRelativeTypeInfo)typeInfo).getMethods( typeToResolveAgainst), methodName, argTypes ); } else { methodInfo = ITypeInfo.FIND.callableMethod( typeInfo.getMethods(), methodName, argTypes ); } methodInfo = ensureExactMatch( methodInfo, argTypes ); if( methodInfo == null && argTypes.length == 0 ) { methodInfo = getSingleMethodWithName( methodName, typeToResolveAgainst, typeInfo ); } boolean foundMethod = methodInfo != null; methodInfo = foundMethod ? methodInfo : ErrorType.getInstance().getTypeInfo().getMethod( methodName, argTypes ); setFeature( methodInfo, null ); return foundMethod; }
private boolean overridesMethodWithDefaultParams(FunctionStatement func, ITypeInfo typeInfo) { if( !(typeInfo instanceof IRelativeTypeInfo) ) { return false; } IRelativeTypeInfo rti = (IRelativeTypeInfo) typeInfo; for( IMethodInfo mi : rti.getMethods( func.getGosuClass() ) ) { if( mi.getDisplayName().equals( func.getFunctionName() ) && mi instanceof GosuMethodInfo && !featureIsOwnedByEnhancement( func.getGosuClass(), mi ) ) { final ReducedDynamicFunctionSymbol dfs0 = ((GosuMethodInfo) mi).getDfs(); final DynamicFunctionSymbol dfs1 = func.getDynamicFunctionSymbol(); return dfs0 != null && dfs1 != null && (((IInvocableType) dfs0.getType()).hasOptionalParams() || dfs1.hasOptionalParameters()); } } return false; }
private boolean overridesMethodWithDefaultParams(FunctionStatement func, ITypeInfo typeInfo) { if( !(typeInfo instanceof IRelativeTypeInfo) ) { return false; } IRelativeTypeInfo rti = (IRelativeTypeInfo) typeInfo; for( IMethodInfo mi : rti.getMethods( func.getGosuClass() ) ) { if( mi.getDisplayName().equals( func.getFunctionName() ) && mi instanceof GosuMethodInfo && !featureIsOwnedByEnhancement( func.getGosuClass(), mi ) ) { final ReducedDynamicFunctionSymbol dfs0 = ((GosuMethodInfo) mi).getDfs(); final DynamicFunctionSymbol dfs1 = func.getDynamicFunctionSymbol(); return dfs0 != null && dfs1 != null && (((IInvocableType) dfs0.getType()).hasOptionalParams() || dfs1.hasOptionalParameters()); } } return false; }
protected void mergeMethods(MethodList methods, IType type, boolean replace) { List<? extends IMethodInfo> methodInfos; if (type != null && !TypeSystem.isDeleted(type)) { if (type.getTypeInfo() instanceof IRelativeTypeInfo) { methodInfos = ((IRelativeTypeInfo) type.getTypeInfo()).getMethods( _typeInfo.getOwnersType()); } else { methodInfos = type.getTypeInfo().getMethods(); } for (IMethodInfo methodInfo : methodInfos) { if( !type.isInterface() || !methodInfo.isStatic() ) { // static interface methods are not inherited mergeMethod(methods, methodInfo, replace); } } } }
methodInfo = findSingleMethodMatchingName( methodName, ((IRelativeTypeInfo)typeInfo).getMethods( typeToResolveAgainst ) );
if( ti instanceof IRelativeTypeInfo ) methods = ((IRelativeTypeInfo)ti).getMethods( type );