org.kiama.example.oberon0.L0

CCodeGenerator

trait CCodeGenerator extends CCodeGenerator with TypeAnalyser

C Code generator for the L0 language.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. CCodeGenerator
  2. TypeAnalyser
  3. NameAnalyser
  4. SymbolTable
  5. SymbolTable
  6. Environments
  7. Analyser
  8. CCodeGenerator
  9. Translator
  10. AnyRef
  11. Any
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. abstract class Entity extends AnyRef

    An entity that represents some program object.

  5. type Environment = Stack[Scope]

    An environment is a stack of scopes with the innermost scope on the top.

    An environment is a stack of scopes with the innermost scope on the top.

    Definition Classes
    Environments
  6. trait ErrorEntity extends Entity

    An entity that represents an error situation.

  7. 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.

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

    A user-defined module represented by a module declaration.

  9. trait Named extends AnyRef

    Support for unique ids for named things.

  10. trait NamedEntity extends Entity with Named

    A named entity.

  11. type Scope = Map[String, Entity]

    A scope maps identifiers to entities.

    A scope maps identifiers to entities.

    Definition Classes
    Environments
  12. abstract class Type extends Entity

    An entity representing by a user-provided type declaration.

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

    A user-defined type.

  14. 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. object MultipleEntity extends Entity with ErrorEntity with Product with Serializable

    A entity represented by names for whom we have seen more than one declaration so we are unsure what is being represented.

  7. object Named extends AnyRef

    Static support for entity names.

  8. object UnknownEntity extends Entity with ErrorEntity with Product with Serializable

    An unknown entity, represented by names whose declarations are missing.

  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. lazy val basetype: (Expression) ⇒ Type

    The actual type of an expression following type aliases.

    The actual type of an expression following type aliases.

    Definition Classes
    TypeAnalyser
  11. lazy val booleanType: BuiltinType

    Built-in Boolean type.

    Built-in Boolean type.

    Definition Classes
    SymbolTable
  12. def check(n: SourceASTNode): Unit

    Check an AST node for semantic errors.

    Check an AST node for semantic errors. Report any errors using the messaging module. This default implementation just ask the node's children to check themselves.

    Definition Classes
    TypeAnalyserNameAnalyserAnalyser
  13. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. lazy val decltype: (TypeDecl) ⇒ Type

    The built-in type associated with a type declaration.

    The built-in type associated with a type declaration.

    Definition Classes
    TypeAnalyser
  15. def defenv: Environment

    The default environment.

    The default environment.

    Definition Classes
    SymbolTable
  16. def defenvPairs: List[(String, Entity)]

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

    Define i to be e in the current scope of env, raising an error if the environment is empty.

    Define i to be e in the current scope of env, raising an error if the environment is empty.

    Definition Classes
    Environments
  18. lazy val deftype: (TypeDef) ⇒ Type

    The type given by a type definition.

    The type given by a type definition.

    Definition Classes
    TypeAnalyser
  19. def deftypeDef: (TypeDef) ⇒ Type

    Definition Classes
    TypeAnalyser
  20. def enter(env: Environment): Environment

    Enter a new empty scope nested within the given environment.

    Enter a new empty scope nested within the given environment.

    Definition Classes
    Environments
  21. 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
  22. 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
  23. lazy val env: Chain[SourceASTNode, 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
  24. def envin(in: (SourceASTNode) ⇒ Environment): ==>[SourceASTNode, Environment]

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

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

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

    Definition Classes
    AnyRef → Any
  28. 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
  29. lazy val exptype: (Expression) ⇒ Type

    The type expected of an expression as defined by its context.

    The type expected of an expression as defined by its context.

    Definition Classes
    TypeAnalyser
  30. def exptypeDef: (Expression) ⇒ Type

    Definition Classes
    TypeAnalyser
  31. lazy val falseConstant: IntegerValue

    Built-in false constant.

    Built-in false constant.

    Definition Classes
    SymbolTable
  32. def finalize(): Unit

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

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

    Definition Classes
    AnyRef → Any
  35. lazy val idntype: (IdnUse) ⇒ Type

    The type of the entity denoted by an identifier use.

    The type of the entity denoted by an identifier use.

    Definition Classes
    TypeAnalyser
  36. def idntypeDef: (IdnUse) ⇒ Type

    Definition Classes
    TypeAnalyser
  37. lazy val integerType: BuiltinType

    Built-in integer type.

    Built-in integer type.

    Definition Classes
    SymbolTable
  38. 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
  39. def isCompatible(tipe: Type, exptype: Type): Boolean

    Compatibility of types.

    Compatibility of types. Return true if the type is compatible with the expected type. Unknown types are compatible with any other type. Otherwise, use look up the base types of what we have and compare them.

    Definition Classes
    TypeAnalyser
  40. 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
  41. def isDefinedInEnv(env: Environment, i: String): Boolean

    Say whether i is defined in any scope of env.

    Say whether i is defined in any scope of env.

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

    Say whether i is defined in an innermost scope of env (i.

    Say whether i is defined in an innermost scope of env (i.e., in the current scope).

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

    Say whether i is defined in an outer scope of env (i.

    Say whether i is defined in an outer scope of env (i.e., not in the current scope).

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

    Say whether i is defined in the given scope.

    Say whether i is defined in the given scope.

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

    Say whether i is defined in the current scope of env.

    Say whether i is defined in the current scope of env.

    Definition Classes
    Environments
  46. 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
  47. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  48. 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
  49. 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
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. def leave(env: Environment): Environment

    Leave the outermost scope of the given environment, raising an error if the environment is empty.

    Leave the outermost scope of the given environment, raising an error if the environment is empty.

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

    Look up i in env, returning the mapped Entity if there is one, otherwise return e.

    Look up i in env, returning the mapped Entity if there is one, otherwise return e. If scope is true, just search the innermost scope, otherwise search outwards in all scopes, returning the first Entity found, if any.

    Definition Classes
    Environments
  57. def mangle(s: String): String

    Mangle an Oberon name so it is safe to be used at the C level.

    Mangle an Oberon name so it is safe to be used at the C level. We assume that there are no C names with "ob_" prefix.

  58. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  61. def resetEnvironments: Unit

    Reset the environment module.

    Reset the environment module.

    Definition Classes
    Environments
  62. 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
  63. def rootconstexpDef: (Expression) ⇒ Boolean

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

    Create a root environment, i.

    Create a root environment, i.e., one that has a single scope containing the given bindings.

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

    Definition Classes
    AnyRef
  66. lazy val tipe: (Expression) ⇒ Type

    The type of an expression.

    The type of an expression.

    Definition Classes
    TypeAnalyser
  67. def tipeDef: (Expression) ⇒ Type

    Definition Classes
    TypeAnalyser
  68. def toString(): String

    Definition Classes
    AnyRef → Any
  69. def translate(e: Expression): CExpression

    Generate C equivalents of expressions.

  70. def translate(s: Statement): CStatement

    Add translation of assignment statements.

    Add translation of assignment statements.

    Definition Classes
    CCodeGeneratorCCodeGeneratorTranslator
  71. def translate(d: Declaration): List[CDeclaration]

    Generate C equivalent of a declaration.

    Generate C equivalent of a declaration.

    Definition Classes
    CCodeGeneratorCCodeGeneratorTranslator
  72. def translate(t: Type): CType

    Generate C equivalent of a type.

  73. def translate(m: ModuleDecl): CProgram

    Generate C equivalent of a module.

    Generate C equivalent of a module.

    Definition Classes
    CCodeGeneratorTranslator
  74. lazy val trueConstant: IntegerValue

    Built-in true constant.

    Built-in true constant.

    Definition Classes
    SymbolTable
  75. lazy val typebasetype: (Type) ⇒ Type

    The actual type that a user type denotes.

    The actual type that a user type denotes.

    Definition Classes
    TypeAnalyser
  76. 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
  77. 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
  78. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from TypeAnalyser

Inherited from NameAnalyser

Inherited from SymbolTable

Inherited from SymbolTable

Inherited from Environments

Inherited from Analyser

Inherited from CCodeGenerator

Inherited from Translator

Inherited from AnyRef

Inherited from Any