IntermediateCodeUtils

de.uni_luebeck.isp.tessla.tessla_compiler.IntermediateCodeUtils
See theIntermediateCodeUtils companion class

Class containing a DSL for easy creation of ImpLanStmt-Blocks and other useful static methods for dealing ImpLan and the translation from TeSSLa

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

sealed trait DeclarationType

Represents the types of declared variables

Represents the types of declared variables

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object FinalDeclaration.type
object FinalLazyDeclaration.type
object VariableDeclaration.type
case object FinalDeclaration extends DeclarationType

Variable can be assigned and evaluated at declaration and is never changed again

Variable can be assigned and evaluated at declaration and is never changed again

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type

Variable can be assigned at declaration and is never changed again, the evaluation has to be lazy

Variable can be assigned at declaration and is never changed again, the evaluation has to be lazy

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
case object VariableDeclaration extends DeclarationType

The variable is reassigned in the generated code

The variable is reassigned in the generated code

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type

Value members

Concrete methods

Generates an addition expression

Generates an addition expression

Value parameters

op1

First parameter sub-expression, must be of IntermediateCode.LongType

op2

Second parameter sub-expression, must be of IntermediateCode.LongType

Attributes

Returns

Addition expression

def And(ops: Seq[ImpLanExpr]): ImpLanExpr

Generates an and (&&) expression

Generates an and (&&) expression

Value parameters

ops

parameter sub-expressions, must be of type IntermediateCode.BoolType

Attributes

Returns

And expression

def BitwiseOr(ops: Seq[ImpLanExpr]): ImpLanExpr

Generates an bitor (|) expression

Generates an bitor (|) expression

Value parameters

ops

parameter sub-expressions, must be of type IntermediateCode.LongType

Attributes

Returns

Or expression

def GetStruct(struct: ImpLanExpr, fieldName: String, structType: ImpLanType): ImpLanExpr

Produces an expression for accessing a structure field

Produces an expression for accessing a structure field

Value parameters

fieldName

The accessed field name

struct

Expression which evaluates to a struct

structType

The type of the struct

Attributes

Returns

Expression accessing the struct

Generates a greater expression

Generates a greater expression

Value parameters

a

First parameter sub-expression, must be of IntermediateCode.LongType

b

Second parameter sub-expression, must be of IntermediateCode.LongType

Attributes

Returns

Greater expression

Generates a greater equal expression

Generates a greater equal expression

Value parameters

a

First parameter sub-expression, must be of IntermediateCode.LongType

b

Second parameter sub-expression, must be of IntermediateCode.LongType

Attributes

Returns

Greater equal expression

def MkStruct(content: Seq[(String, ImpLanExpr)], targetType: ImpLanType): ImpLanExpr

Produces an expression building a struct

Produces an expression building a struct

Value parameters

content

Sub expressions with field names

targetType

The type of the struct to be generated

Attributes

Returns

Expression building a struct

Generates a negate expression

Generates a negate expression

Value parameters

a

Sub-expression to be negated

Attributes

Returns

Negate expression

Generates a not equal expression

Generates a not equal expression

Value parameters

a

First parameter sub-expression

b

Second parameter sub-expression

Attributes

Returns

Not equal expression

def Or(ops: Seq[ImpLanExpr]): ImpLanExpr

Generates an or (||) expression

Generates an or (||) expression

Value parameters

ops

parameter sub-expressions, must be of type IntermediateCode.BoolType

Attributes

Returns

Or expression

Generates a subtraction expression

Generates a subtraction expression

Value parameters

op1

First parameter sub-expression, must be of IntermediateCode.LongType

op2

Second parameter sub-expression, must be of IntermediateCode.LongType

Attributes

Returns

Subtraction expression

def Throw(e: ImpLanExpr, forType: ImpLanType): ImpLanExpr

Generates a throw expression

Generates a throw expression

Value parameters

e

sub expression of the error to be thrown, must be of IntermediateCode.ErrorType

forType

Type which should be returned inst

Attributes

Returns

Expression throwing an error

def defaultValueForStreamType(t: TypeExpression): Option[ImpLanVal]

Calculates a static default value for a stream type. For Events[t] it is the default value of t.

Calculates a static default value for a stream type. For Events[t] it is the default value of t.

Value parameters

t

Type whose default value shall be determined. Must be Events[...]

Attributes

Returns

Default value for given type

def defaultValueForType(t: TypeExpression): Option[ImpLanVal]

Calculates a static default value for a non-stream type.

Calculates a static default value for a non-stream type.

Value parameters

t

Type whose default value shall be determined. May not be Events[...]

Attributes

Returns

Default value for given type

def foldAST[A](exp: ImpLanExpr, n: A, f: (A, ImpLanExpr) => A, g: (A, ImpLanStmt) => A): A

Folds an IntermediateCode.ImpLanExpr including all sub-expressions and sub-statements. Sub-statements/sub-expressions are traversed prior their parent expressions

Folds an IntermediateCode.ImpLanExpr including all sub-expressions and sub-statements. Sub-statements/sub-expressions are traversed prior their parent expressions

Type parameters

A

The result type of the folding operation

Value parameters

exp

The sequence of statements to be folded

f

Function executed on every expression

g

Function executed on every statement

n

The start value

Attributes

Returns

The result of the folding

def foldAST[A](stmts: Seq[ImpLanStmt], n: A, f: (A, ImpLanExpr) => A, g: (A, ImpLanStmt) => A): A

Folds a sequence of statements including all sub-expressions and sub-statements. Sub-statements/sub-expressions are traversed prior their parent expressions

Folds a sequence of statements including all sub-expressions and sub-statements. Sub-statements/sub-expressions are traversed prior their parent expressions

Type parameters

A

The result type of the folding operation

Value parameters

f

Function executed on every expression

g

Function executed on every statement

n

The start value

stmts

The sequence of statements to be folded

Attributes

Returns

The result of the folding

def getVariableSeq(stmts: Seq[ImpLanStmt], baseSeq: Seq[(String, (ImpLanType, Option[ImpLanExpr], DeclarationType))], global: Boolean): Seq[(String, (ImpLanType, Option[ImpLanExpr], DeclarationType))]

Builds a sequence containing type/default/lazyness/global-definition information for all variables defined in stmts. If unsound information (e.g. multiple declarations) are found an error is thrown. The order is the one of the corresponding assignments.

Builds a sequence containing type/default/lazyness/global-definition information for all variables defined in stmts. If unsound information (e.g. multiple declarations) are found an error is thrown. The order is the one of the corresponding assignments.

Value parameters

baseSeq

The base sequence to be extended

global

Include global definitions in sub-expressions (e.g. functions)

stmts

The sequence of statements to be examined

Attributes

Returns

Map containing variable information.

def mapAST(stmts: Seq[ImpLanStmt], f: ImpLanExpr => ImpLanExpr, g: ImpLanStmt => Option[ImpLanStmt]): Seq[ImpLanStmt]

Maps f on all subexpressions and g on all sub-statements of a sequence of statements

Maps f on all subexpressions and g on all sub-statements of a sequence of statements

Value parameters

f

Function to map expressions

g

Function to map statements

stmts

The sequence of statements to be mapped

Attributes

Returns

Mapped sequence of statements

Maps f on all subexpressions and g on all sub-statements of an IntermediateCode.ImpLanExpr

Maps f on all subexpressions and g on all sub-statements of an IntermediateCode.ImpLanExpr

Value parameters

exp

The expression to be mapped

f

Function to map expressions

g

Function to map statements

Attributes

Returns

Mapped expression

def structComparison(s1: String, s2: String): Boolean

Sorting function for structs taking care of the right sorting of tuple fild names

Sorting function for structs taking care of the right sorting of tuple fild names

Value parameters

s1

First param for comparison

s2

Second param for comparison

Attributes

Returns

true if s1 <= s2 with respect to the special sorting rules

def structIsTuple(structType: StructType): Boolean

Figures out if a struct is a tuple. i.e. has field names _1,_2 ...

Figures out if a struct is a tuple. i.e. has field names _1,_2 ...

Value parameters

structType

The struct to be examined

Attributes

Returns

Whether given struct is tuple

Implicits

Implicits

implicit def stringToVariable(str: String): Variable
implicit def typeConversion(t: TypeExpression): ImpLanType

Converts TeSSLa type to corresponding IntermediateCode.ImpLanType

Converts TeSSLa type to corresponding IntermediateCode.ImpLanType

Value parameters

t

Type to be converted. If type is Events[t] the result is equal to calling the function with t.

Attributes

Returns

The converted type