kiama.example.picojava

object TypeAnalysis

[source: kiama/example/picojava/TypeAnalysis.scala]

object TypeAnalysis
extends AnyRef
This file is derived from a JastAdd implementation of PicoJava, created in the Department of Computer Science at Lund University. See the following web site for details: http://jastadd.cs.lth.se/examples/PicoJava/index.shtml
Value Summary
val hasCycleOnSuperclassChain : scala.PartialFunction[ClassDecl, Boolean]
True if there is a cycle somewhere on the superclass chain, false otherwise. syn lazy boolean ClassDecl.hasCycleOnSuperclassChain() circular [true]; eq ClassDecl.hasCycleOnSuperclassChain() { if (hasSuperclass() && getSuperclass().decl() instanceof ClassDecl) //First, check if there is a superclass return ((ClassDecl) getSuperclass().decl()).hasCycleOnSuperclassChain(); else return false;
val isSubtypeOf : (TypeDecl) => scala.PartialFunction[TypeDecl, Boolean]
Is this declaration for a type that is a subtype of the provided type. The unknown type is a subtype of all types. syn lazy boolean TypeDecl.isSubtypeOf(TypeDecl typeDecl); eq TypeDecl.isSubtypeOf(TypeDecl typeDecl) = typeDecl.isSuperTypeOf(this); eq ClassDecl.isSubtypeOf(TypeDecl typeDecl) = typeDecl.isSuperTypeOfClassDecl(this); eq UnknownDecl.isSubtypeOf(TypeDecl typeDecl) = true;
val isUnknown : scala.PartialFunction[Decl, Boolean]
Is this declaration unknown? syn boolean Decl.isUnknown() = false; eq UnknownDecl.isUnknown() = true;
val isValue : scala.PartialFunction[Exp, Boolean]
Is this expression a value or not? syn boolean Exp.isValue(); eq Exp.isValue() = true; eq Dot.isValue() = getIdUse().isValue(); eq TypeUse.isValue() = false; Note! If we did not have the rewrites below, the above equation would have to instead be written as: eq IdUse.isValue() = !(decl() instanceof TypeDecl) FIXME: currently using the "without rewrites" version
val superClass : scala.PartialFunction[ClassDecl, ClassDecl]
Return the superclass of a class (or null if none). syn lazy ClassDecl ClassDecl.superClass(); eq ClassDecl.superClass() { if (hasSuperclass() && getSuperclass().decl() instanceof ClassDecl && !hasCycleOnSuperclassChain()) return (ClassDecl) getSuperclass().decl(); else return null; }
val tipe : scala.PartialFunction[Attributable, TypeDecl]
Return the type of a construct or unknownDecl if none. syn lazy TypeDecl Decl.type(); syn lazy TypeDecl Exp.type(); eq TypeDecl.type() = this; eq VarDecl.type() = getType().decl().type(); eq IdUse.type() = decl().type(); eq Dot.type() = getIdUse().type(); eq BooleanLiteral.type() = booleanType();
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
val isUnknown : scala.PartialFunction[Decl, Boolean]
Is this declaration unknown? syn boolean Decl.isUnknown() = false; eq UnknownDecl.isUnknown() = true;

val tipe : scala.PartialFunction[Attributable, TypeDecl]
Return the type of a construct or unknownDecl if none. syn lazy TypeDecl Decl.type(); syn lazy TypeDecl Exp.type(); eq TypeDecl.type() = this; eq VarDecl.type() = getType().decl().type(); eq IdUse.type() = decl().type(); eq Dot.type() = getIdUse().type(); eq BooleanLiteral.type() = booleanType();

val isSubtypeOf : (TypeDecl) => scala.PartialFunction[TypeDecl, Boolean]
Is this declaration for a type that is a subtype of the provided type. The unknown type is a subtype of all types. syn lazy boolean TypeDecl.isSubtypeOf(TypeDecl typeDecl); eq TypeDecl.isSubtypeOf(TypeDecl typeDecl) = typeDecl.isSuperTypeOf(this); eq ClassDecl.isSubtypeOf(TypeDecl typeDecl) = typeDecl.isSuperTypeOfClassDecl(this); eq UnknownDecl.isSubtypeOf(TypeDecl typeDecl) = true;

val superClass : scala.PartialFunction[ClassDecl, ClassDecl]
Return the superclass of a class (or null if none). syn lazy ClassDecl ClassDecl.superClass(); eq ClassDecl.superClass() { if (hasSuperclass() && getSuperclass().decl() instanceof ClassDecl && !hasCycleOnSuperclassChain()) return (ClassDecl) getSuperclass().decl(); else return null; }

val hasCycleOnSuperclassChain : scala.PartialFunction[ClassDecl, Boolean]
True if there is a cycle somewhere on the superclass chain, false otherwise. syn lazy boolean ClassDecl.hasCycleOnSuperclassChain() circular [true]; eq ClassDecl.hasCycleOnSuperclassChain() { if (hasSuperclass() && getSuperclass().decl() instanceof ClassDecl) //First, check if there is a superclass return ((ClassDecl) getSuperclass().decl()).hasCycleOnSuperclassChain(); else return false;

val isValue : scala.PartialFunction[Exp, Boolean]
Is this expression a value or not? syn boolean Exp.isValue(); eq Exp.isValue() = true; eq Dot.isValue() = getIdUse().isValue(); eq TypeUse.isValue() = false; Note! If we did not have the rewrites below, the above equation would have to instead be written as: eq IdUse.isValue() = !(decl() instanceof TypeDecl) FIXME: currently using the "without rewrites" version