public CoreClass(TypeName name, TypeName superName, IClassLoader loader, CAstSourcePositionMap.Position sourcePosition) { super(sourcePosition, name, loader, (short) 0, Collections.emptyMap(), CAstAbstractModuleLoader.this.getLanguage().getRootType()); types.put(name, this); this.superName = superName; }
public CoreClass(TypeName name, TypeName superName, IClassLoader loader, CAstSourcePositionMap.Position sourcePosition) { super(sourcePosition, name, loader, (short) 0, Collections.emptyMap(), CAstAbstractModuleLoader.this.getLanguage().getRootType()); types.put(name, this); this.superName = superName; }
private void computeSuperclass() { superclassComputed = true; if (superName == null) { if (!getReference().equals(loader.getLanguage().getRootType())) { superClass = loader.lookupClass(loader.getLanguage().getRootType().getName()); } return; } superClass = loader.lookupClass(TypeName.findOrCreate(superName)); }
private void computeSuperclass() { superclassComputed = true; if (superName == null) { if (!getReference().equals(loader.getLanguage().getRootType())) { superClass = loader.lookupClass(loader.getLanguage().getRootType().getName()); } return; } superClass = loader.lookupClass(TypeName.findOrCreate(superName)); }
@Override public IMethod getMethod(Selector sig) { return cha.lookupClass(getClassLoader().getLanguage().getRootType()).getMethod(sig); }
@Override public IMethod getMethod(Selector sig) { return cha.lookupClass(getClassLoader().getLanguage().getRootType()).getMethod(sig); }
@Override public Collection<? extends IMethod> getAllMethods() { return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()).getAllMethods(); }
@Override public SSANewInstruction addAllocation(TypeReference T) { if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(declaringClass.getClassLoader().getLanguage().getRootType()))) { int instance = nextLocal++; NewSiteReference ref = NewSiteReference.make(statements.size(), T); SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref); statements.add(result); return result; } else { return super.addAllocation(T); } }
@Override public SSANewInstruction addAllocation(TypeReference T) { if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(declaringClass.getClassLoader().getLanguage().getRootType()))) { int instance = nextLocal++; NewSiteReference ref = NewSiteReference.make(statements.size(), T); SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref); statements.add(result); return result; } else { return super.addAllocation(T); } }
@Override public TypeReference getParameterType(int i) { if (i == 0) { return getDeclaringClass().getReference(); } else { return getDeclaringClass().getClassLoader().getLanguage().getRootType(); } } }
@Override public TypeReference getParameterType(int i) { if (i == 0) { return getDeclaringClass().getReference(); } else { return getDeclaringClass().getClassLoader().getLanguage().getRootType(); } } }
@Override public Collection<? extends IMethod> getAllMethods() { return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()).getAllMethods(); }
@Override public TypeReference getLeastCommonSuperclass(TypeReference a, TypeReference b) { if (a == null) { throw new IllegalArgumentException("a is null"); } if (a.equals(b)) return a; IClass aClass = lookupClass(a); IClass bClass = lookupClass(b); if (aClass == null || bClass == null) { // One of the classes is not in scope. Give up. if (aClass != null) { return aClass.getClassLoader().getLanguage().getRootType(); } else if (bClass != null) { return bClass.getClassLoader().getLanguage().getRootType(); } else { return getRootClass().getReference(); } } return getLeastCommonSuperclass(aClass, bClass).getReference(); }
@Override public TypeReference getLeastCommonSuperclass(TypeReference a, TypeReference b) { if (a == null) { throw new IllegalArgumentException("a is null"); } if (a.equals(b)) return a; IClass aClass = lookupClass(a); IClass bClass = lookupClass(b); if (aClass == null || bClass == null) { // One of the classes is not in scope. Give up. if (aClass != null) { return aClass.getClassLoader().getLanguage().getRootType(); } else if (bClass != null) { return bClass.getClassLoader().getLanguage().getRootType(); } else { return getRootClass().getReference(); } } return getLeastCommonSuperclass(aClass, bClass).getReference(); }
@Override public IClass getSuperclass() { boolean excludedSupertype=false; for (TypeName name : superTypeNames) { IClass domoType = lookupClass(name); if (domoType != null && !domoType.isInterface()) { return domoType; } if (domoType == null && getClassHierarchy().getScope().getExclusions().contains(name.toString().substring(1))){ excludedSupertype = true; } } // The following test allows the root class to reside in source; without // it, the assertion requires all classes represented by a JavaClass to // have a superclass. /** BEGIN Custom change: Common superclass is optional */ // Is no longer true in new X10 - no common object super class if (existsCommonSuperclass && !getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) { /** END Custom change: Common superclass is optional */ Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames); } if (excludedSupertype){ System.err.println("Not tracking calls through excluded superclass of " + getName() + " extends " + superTypeNames); } return null; }
@Override public IClass getSuperclass() { IClass elt = getElementClass(); assert getReference().getArrayElementType().isPrimitiveType() || elt != null; // super is Ljava/lang/Object in two cases: // 1) [Ljava/lang/Object // 2) [? for primitive arrays (null from getElementClass) if (elt == null || elt.getReference() == getClassLoader().getLanguage().getRootType()) { return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()); } // else it is array of super of element type (yuck) else { TypeReference eltSuperRef = elt.getSuperclass().getReference(); TypeReference superRef = TypeReference.findOrCreateArrayOf(eltSuperRef); return elt.getSuperclass().getClassLoader().lookupClass(superRef.getName()); } }
@Override public IClass getSuperclass() { boolean excludedSupertype=false; for (TypeName name : superTypeNames) { IClass domoType = lookupClass(name); if (domoType != null && !domoType.isInterface()) { return domoType; } if (domoType == null && getClassHierarchy().getScope().getExclusions().contains(name.toString().substring(1))){ excludedSupertype = true; } } // The following test allows the root class to reside in source; without // it, the assertion requires all classes represented by a JavaClass to // have a superclass. /** BEGIN Custom change: Common superclass is optional */ // Is no longer true in new X10 - no common object super class if (existsCommonSuperclass && !getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) { /** END Custom change: Common superclass is optional */ Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames); } if (excludedSupertype){ System.err.println("Not tracking calls through excluded superclass of " + getName() + " extends " + superTypeNames); } return null; }
@Override public IClass getSuperclass() { if (!superclassComputed) { computeSuperclass(); } if (superClass == null && !getReference().equals(TypeReference.JavaLangObject)) { // TODO MissingSuperClassHandling.Phantom needs to be implemented if (cha instanceof ClassHierarchy && ((ClassHierarchy) cha).getSuperClassHandling().equals(ClassHierarchy.MissingSuperClassHandling.ROOT)) { superClass = loader.lookupClass(loader.getLanguage().getRootType().getName()); } else throw new NoSuperclassFoundException("No superclass found for " + this + " Superclass name " + superName); } return superClass; }
@Override public IClass getSuperclass() { if (!superclassComputed) { computeSuperclass(); } if (superClass == null && !getReference().equals(TypeReference.JavaLangObject)) { // TODO MissingSuperClassHandling.Phantom needs to be implemented if (cha instanceof ClassHierarchy && ((ClassHierarchy) cha).getSuperClassHandling().equals(ClassHierarchy.MissingSuperClassHandling.ROOT)) { superClass = loader.lookupClass(loader.getLanguage().getRootType().getName()); } else throw new NoSuperclassFoundException("No superclass found for " + this + " Superclass name " + superName); } return superClass; }
@Override public IClass getSuperclass() { IClass elt = getElementClass(); assert getReference().getArrayElementType().isPrimitiveType() || elt != null; // super is Ljava/lang/Object in two cases: // 1) [Ljava/lang/Object // 2) [? for primitive arrays (null from getElementClass) if (elt == null || elt.getReference() == getClassLoader().getLanguage().getRootType()) { return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()); } // else it is array of super of element type (yuck) else { TypeReference eltSuperRef = elt.getSuperclass().getReference(); TypeReference superRef = TypeReference.findOrCreateArrayOf(eltSuperRef); return elt.getSuperclass().getClassLoader().lookupClass(superRef.getName()); } }