Created
July 18, 2016 19:24
-
-
Save piotrMocz/11614c103743429de76ffd512abe0110 to your computer and use it in GitHub Desktop.
New type hierarchy for scalajs_java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package scalajs_java.trees | |
sealed trait Type | |
// Type of statements | |
case object NoType extends Type | |
// Primitive types | |
trait PrimitiveType extends Type | |
case object BoolType extends PrimitiveType | |
case object CharType extends PrimitiveType | |
case object IntType extends PrimitiveType | |
case object LongType extends PrimitiveType | |
case object DoubleType extends PrimitiveType | |
case object FloatType extends PrimitiveType | |
// Reference types | |
trait ReferenceType { | |
val className: String | |
} | |
case object NullType extends ReferenceType { | |
override val className: String = "null" | |
} | |
case class ClassType(className: String) extends ReferenceType | |
case object StringType extends ReferenceType { | |
override val className: String = "java.lang.String" | |
} | |
case class ArrayType(elemType: Type, dims: Int) extends ReferenceType { | |
override val className: String = "array" | |
} | |
// Method/function type | |
case class FunctionType(className: String, argTypes: List[Type], | |
retType: Type) extends Type | |
// Generic type | |
case class GenericType(baseType: Type, | |
typeParams: List[Type]) extends Type | |
case class GenericTypeApp(genericType: GenericType, | |
appArgs: List[Type]) extends Type | |
// Wrappers for the AST | |
trait TypedTree { | |
def tp: Type | |
} | |
trait StatementTree extends TypedTree { | |
override def tp: Type = NoType | |
} | |
trait ExpressionTree extends TypedTree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment