org.kiama.example.oberon0.L2

Desugarer

trait Desugarer extends L0.Desugarer

Desugaring transformation for L2.

Source
Desugarer.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Desugarer
  2. Desugarer
  3. NameAnalyser
  4. SymbolTable
  5. SymbolTable
  6. Environments
  7. Analyser
  8. Transformer
  9. AnyRef
  10. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Builtin extends Named

    Marker trait for all built-in entities.

  2. case class BuiltinType(ident: String) extends Type with Named with Builtin with Product with Serializable

    A built-in type with an implicit definition that the compiler must have special knowledge about.

  3. case class Constant(ident: String, decl: ConstDecl) extends Entity with NamedEntity with Product with Serializable

    A user-defined constant entity represented by a constant declaration.

  4. type Environment = List[Scope]

    Definition Classes
    Environments
  5. case class IntegerValue(ident: String, tipe: Type, value: Int) extends Entity with NamedEntity with Builtin with Product with Serializable

    A built-in value of some type that is represented by a particular integer value.

  6. case class Module(ident: String, decl: ModuleDecl) extends Entity with NamedEntity with Product with Serializable

    A user-defined module represented by a module declaration.

  7. trait Named extends AnyRef

    Definition Classes
    Environments
  8. trait NamedEntity extends Entity with Named

    Definition Classes
    Environments
  9. type Scope = Map[String, Entity]

    Definition Classes
    Environments
  10. abstract class Type extends Entity

    An entity representing by a user-provided type declaration.

  11. case class UserType(ident: String, tipe: TypeDecl) extends Type with Named with Product with Serializable

    A user-defined type.

  12. case class Variable(ident: String, tipe: TypeDef) extends Entity with NamedEntity with Product with Serializable

    A variable entity including a reference to its types' definition.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. lazy val booleanType: BuiltinType

    Built-in Boolean type.

    Built-in Boolean type.

    Definition Classes
    SymbolTable
  8. def casesToIf(ce: IdnExp, cases: Seq[Case], optelse: Option[Block]): IfStatement

    Return an IF cascade equivaleant to the given cases and optional else block.

    Return an IF cascade equivaleant to the given cases and optional else block. The variable ce holds the selection value. Specifically, these cases on ce CASE e1 : s1 CASE e2 .. e3 : s2 ELSE s3 are transformed into IF ce = e1 THEN s1 ELSEIF (ce >= e2) & (ce <= e3) THEN s2 ELSE 32 END If a case has more than one condition then they are combined with Or operators.

  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def defenv: Environment

    The default environment.

    The default environment.

    Definition Classes
    SymbolTable
  11. def defenvPairs: Seq[(String, Entity)]

    Definition Classes
    SymbolTable
  12. def define(env: Environment, i: String, e: Entity): Environment

    Definition Classes
    Environments
  13. lazy val desugarCase: Strategy

    Desugar CASE statements into equivalent blocks containing cascading IF statements.

    Desugar CASE statements into equivalent blocks containing cascading IF statements. A new variable called "casevar" is introduced in the block to hold the selection value so that it does not need to be re-evaluated. Specifically, CASE e OF cases END is transformed into VAR caseval : INTEGER; BEGIN caseval := e; IF caseval ... THEN ... END END

  14. lazy val desugarFor: Strategy

    Desugar FOR statements into equivalent blocks containing a WHILE loop.

    Desugar FOR statements into equivalent blocks containing a WHILE loop. A new variable called "limit" is introduced in the block to hold the upper limit of the FOR to protect against changes in the body. Specifically, FOR id := e1 TO e2 BY e3 DO body END is transformed into VAR limit : INTEGER; BEGIN id := e1; limit := e2; WHILE (id op limit) DO body id := id + e3 END END If e3 is negative, op is <=, otherwise it is >=.

  15. def enter(env: Environment): Environment

    Definition Classes
    Environments
  16. lazy val entity: (Identifier) ⇒ Entity

    The program entity referred to by an identifier definition or use.

    The program entity referred to by an identifier definition or use. In the case of a definition it's the thing being defined, so define it to be a reference to the declaration. If it's already defined, return a entity that indicates a multiple definition. In the case of a use, it's the thing defined elsewhere that is being referred to here, so look it up in the environment.

    Definition Classes
    NameAnalyser
  17. def entityFromDecl(n: IdnDef, i: String): Entity

    The entity for an identifier definition as given by its declaration context.

    The entity for an identifier definition as given by its declaration context.

    Definition Classes
    NameAnalyser
  18. lazy val env: Chain[SourceTree, Environment]

    The environment containing bindings for all identifiers visible at the given node.

    The environment containing bindings for all identifiers visible at the given node. It starts at the module declaration with the default environment. At blocks we enter a nested scope which is removed on exit from the block. At constant and type declarations the left-hand side binding is not in scope on the right-hand side. Each identifier definition just adds its binding to the chain. The envout cases for assignment and expression mean that we don't need to traverse into those constructs, since declarations can't occur there.

    Definition Classes
    NameAnalyser
  19. def envin(in: (SourceTree) ⇒ Environment): ==>[SourceTree, Environment]

    Definition Classes
    NameAnalyser
  20. def envout(out: (SourceTree) ⇒ Environment): ==>[SourceTree, Environment]

    Definition Classes
    NameAnalyser
  21. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  22. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  23. val errors: attribution.Attribution.CachedAttribute[Any, Seq[Message]]

    The semantic errors for a tree.

    The semantic errors for a tree.

    Definition Classes
    Analyser
  24. def errorsDef(n: SourceTree): Messages

    The error checking for this level.

    The error checking for this level.

    Definition Classes
    NameAnalyserAnalyser
  25. lazy val expconst: (Expression) ⇒ Boolean

    Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.

    Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.

    Definition Classes
    NameAnalyser
  26. lazy val falseConstant: IntegerValue

    Built-in false constant.

    Built-in false constant.

    Definition Classes
    SymbolTable
  27. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  29. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  30. lazy val integerType: BuiltinType

    Built-in integer type.

    Built-in integer type.

    Definition Classes
    SymbolTable
  31. def isBoolean(e: Type): Boolean

    Return true if the given type is Boolean or an unknown type.

    Return true if the given type is Boolean or an unknown type.

    Definition Classes
    SymbolTable
  32. def isConstant(e: Entity): Boolean

    Return true if the entity is erroneous or is a constant.

    Return true if the entity is erroneous or is a constant.

    Definition Classes
    SymbolTable
  33. def isDefinedInEnv(env: Environment, i: String): Boolean

    Definition Classes
    Environments
  34. def isDefinedInInner(env: Environment, i: String): Boolean

    Definition Classes
    Environments
  35. def isDefinedInOuter(env: Environment, i: String): Boolean

    Definition Classes
    Environments
  36. def isDefinedInScope(scope: Scope, i: String): Boolean

    Definition Classes
    Environments
  37. def isDefinedInScope(env: Environment, i: String): Boolean

    Definition Classes
    Environments
  38. def isError(e: Entity): Boolean

    Return true if the entity is an error, false otherwise.

    Return true if the entity is an error, false otherwise.

    Definition Classes
    SymbolTable
  39. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  40. def isInteger(e: Type): Boolean

    Return true if the given type is integer or an unknown type.

    Return true if the given type is integer or an unknown type.

    Definition Classes
    SymbolTable
  41. def isLvalue(l: Expression): Boolean

    Return true if the expression can legally appear on the left-hand side of an assignment statement.

    Return true if the expression can legally appear on the left-hand side of an assignment statement. At this level only allow identifiers of variables or things we don't know anything about. The true default is used so that this computation can be used in redefinitions.

    Definition Classes
    NameAnalyser
  42. def isModule(e: Entity): Boolean

    Return true if the entity is erroneous or is a module.

    Return true if the entity is erroneous or is a module.

    Definition Classes
    SymbolTable
  43. def isRvalue(r: IdnExp): Boolean

    Return true if the identifier is an r-value and hence its value can be used (ie.

    Return true if the identifier is an r-value and hence its value can be used (ie. it's erroneous or is a constant, value or variable).

    Definition Classes
    NameAnalyser
  44. def isType(e: Entity): Boolean

    Return true if the entity is erroneous or is a type.

    Return true if the entity is erroneous or is a type.

    Definition Classes
    SymbolTable
  45. def isVariable(e: Entity): Boolean

    Return true if the entity is erroneous or is a variable.

    Return true if the entity is erroneous or is a variable.

    Definition Classes
    SymbolTable
  46. lazy val isconst: (Expression) ⇒ Boolean

    Is an expression constant or not? Unknown entities are constant.

    Is an expression constant or not? Unknown entities are constant. Strictly speaking we only need to support integer expressions here, but we treat Boolean ones as constant in the same way so that we avoid spurious errors. Type analysis will reject Boolean constant expressions anyway.

    Definition Classes
    NameAnalyser
  47. def leave(env: Environment): Environment

    Definition Classes
    Environments
  48. def lookup(env: Environment, i: String, e: Entity, scope: Boolean): Entity

    Definition Classes
    Environments
  49. val nameCounter: Counter

    Definition Classes
    Environments
  50. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  51. final def notify(): Unit

    Definition Classes
    AnyRef
  52. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  53. def resetEnvironments(): Unit

    Definition Classes
    Environments
  54. lazy val rootconstexp: (Expression) ⇒ Boolean

    Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.

    Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.

    Definition Classes
    NameAnalyser
  55. def rootconstexpDef: (Expression) ⇒ Boolean

    Definition Classes
    NameAnalyser
  56. def rootenv(bindings: (String, Entity)*): Environment

    Definition Classes
    Environments
  57. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  58. def toString(): String

    Definition Classes
    AnyRef → Any
  59. def transform(m: ModuleDecl): ModuleDecl

    Desugar FOR and CASE statements into simpler constructs.

    Desugar FOR and CASE statements into simpler constructs. Then call the next level of transformation.

    Definition Classes
    DesugarerDesugarerTransformer
  60. lazy val trueConstant: IntegerValue

    Built-in true constant.

    Built-in true constant.

    Definition Classes
    SymbolTable
  61. def uniquifyNames(m: ModuleDecl): ModuleDecl

    Rename user-defined names to avoid clashes with outer declarations of the same name.

    Rename user-defined names to avoid clashes with outer declarations of the same name. This transformation is not idempotent.

    Definition Classes
    Desugarer
  62. lazy val unknownType: BuiltinType

    A type that is unknown, eg because the typed thing is erroneously defined.

    A type that is unknown, eg because the typed thing is erroneously defined.

    Definition Classes
    SymbolTable
  63. lazy val value: (Expression) ⇒ Int

    What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.

    What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.) Returns zero in all other cases. FIXME: Ignores issues of overflow.

    Definition Classes
    NameAnalyser
  64. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  65. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from L0.Desugarer

Inherited from L0.NameAnalyser

Inherited from SymbolTable

Inherited from SymbolTable

Inherited from Environments

Inherited from Analyser

Inherited from Transformer

Inherited from AnyRef

Inherited from Any

Ungrouped