Skip to content

Commit

Permalink
Added some utility methods for native handling (#500 and #1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
quintesse committed May 5, 2015
1 parent 3d90418 commit 2cb9009
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/com/redhat/ceylon/compiler/typechecker/model/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,14 @@ public static boolean hasNativeImplementation(Declaration decl) {
return false;
}

public static boolean isInNativeContainer(Declaration decl) {
Scope container = decl.getContainer();
if (container instanceof Declaration) {
return ((Declaration) container).isNative();
}
return false;
}

public static Declaration getNativeAbstraction(Declaration decl) {
Declaration abstraction = null;
Overloadable f = (Overloadable)decl;
Expand Down
14 changes: 11 additions & 3 deletions src/com/redhat/ceylon/compiler/typechecker/tree/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,24 @@ public static boolean isForBackend(Tree.AnnotationList al, Backend forBackend, U
}

public static boolean isForBackend(Tree.AnnotationList al, BackendSupport backendSupport, Unit unit) {
Annotation a = getAnnotation(al, "native", unit);
if (a != null) {
Backend backend = Backend.fromAnnotation(getAnnotationArgument(a, ""));
String be = getNativeBackend(al, unit);
if (be != null) {
Backend backend = Backend.fromAnnotation(be);
if (backend == null || !backendSupport.supportsBackend(backend)) {
return false;
}
}
return true;
}

public static String getNativeBackend(Tree.AnnotationList al, Unit unit) {
Annotation a = getAnnotation(al, "native", unit);
if (a != null) {
return getAnnotationArgument(a, "");
}
return null;
}

public static boolean hasUncheckedNulls(Tree.Term term) {
return hasUncheckedNulls(term, false);
}
Expand Down

0 comments on commit 2cb9009

Please sign in to comment.