SEERE Workshop, Neum 2009 1
Tempura RetargetingDamyan Mitev, Vladimir ValkanovPlovdiv University “Paisii Hilendarski”
SEERE Workshop, Neum 2009 2
CAMeLS project
• flexible, adaptive, collaborative, context-aware service and agent-oriented eLearning environment
• uses InfoStation network architecture• delivers personalized, mobile, any-time and
any-where assess to educational content and services
SEERE Workshop, Neum 2009 3
InfoStation middleware
• manages services and mobile users• scenario based– « No change » scenario– « Change IS » scenario– « Change MD » scenario– « Change both » scenario
SEERE Workshop, Neum 2009 4
Scenarios
• depend on movement of user and used mobile device
• mandate different behavior of the middleware– different device profiles (capabilities)– cached information in the InfoStations– availability of services in different InfoStations
• time dependant
SEERE Workshop, Neum 2009 5
Scenario detection and control
• we need– formal description of scenarios– mechanisms to interpret that description
• we gain– flexible mechanisms for creating new (sub)
scenarios – easily define corresponding middleware behavior
SEERE Workshop, Neum 2009 6
Scenario formalism
• Interval Temporal Logic– propositional and first-order logical reasoning– finite sequences – time intervals – capable of handling sequential and parallel
composition
• Tempura - executable ITL framework.
SEERE Workshop, Neum 2009 7
Tempura usage
• middleware– written in Java
• Tempura– written in C– open source
• possible usage of Tempura– wrapping existing Tempura executable with Java IO
redirection– development of entirely new project, based on execution
rules of ITL– reengineering of Tempura and rewriting it in Java
SEERE Workshop, Neum 2009 8
Tempura retargeting
• homogenous environment• usage of quality code as a basis• no steep curve learning ITL nuts and bolts
SEERE Workshop, Neum 2009 9
Tempura source code diagram
top-lev.c
init.c
system.c
r-assign.c
r-expr.c
r-int.c
r-io.c
r-linear.c
r-lists.c
r-symbol.c
r-system.c
mem.c
store.c
io.c
errors.c
version.c
parser.c
lexer.c
val.c
SEERE Workshop, Neum 2009 10
Retargeting plan
• based on iterations• iteration phases– research phase– implementation phase– testing phase
SEERE Workshop, Neum 2009 11
Plan for first iteration
• research– understand Interval Temporal Logic• In progress
– learn code structure, main program flow, structures and variables of Tempura interpreter• Mostly done
– check possible usages of existing C-to Java conversion tools• No suitable software found
– check possible usages of existing C analysis tools• No suitable software found
SEERE Workshop, Neum 2009 12
Plan for first iteration (cont’d)
• implementation– create a Java class for every C source file and its associate header file– create a static method in the Java class for every function in the C file
with the same name (ignoring Java naming conventions)– create static variable in the Java class for every global variable in the
header file– create a static method in the Java class for every macro function in the
header file (where appropriate)– expand the contents of every macro, not covered by the previous step– implement all struct and union types as Java classes– convert integer boolean assignments and expressions into proper Java
boolean constructs– replace function pointers with instances of specially created Interface,
which will call the desired Java method (delegates)
SEERE Workshop, Neum 2009 13
Plan for first iteration (cont’d)
• implementation status (estimated)– 40 % of the source code – 80 % of the structures – 30 % of function pointers
• problems– console oriented– scattered functions and variables– heavy use of c-specific syntax structures like macros, pointers, memory
addressing, null terminated strings, inline initializers
SEERE Workshop, Neum 2009 14
Plan for first iteration (cont’d)
• testing– run the examples, which come with the original
sources, on the Java interpreter and compare results
• desired outcome– working JTempura interpreter by the end of the
year
SEERE Workshop, Neum 2009 15
Plan for second iteration
• towards object-oriented structure– converting different Node types (denoted by their
type member) into hierarchy of base class TNode and a descendant for every node type, supported by JTempura
– converting various reducers from static members to Java classes and creating hierarchy of reducers with base class TReducer
SEERE Workshop, Neum 2009 16
Plan for second iteration (cont’d)
• towards object-oriented structure– redirecting input and output of the interpreter into
streams– redesign memory management– redesign error handling and notification– group similar and relevant methods in one class– design complex objects for storing lexemes– implement syntax tree outcome of the parser,
representing the given ITL expression
SEERE Workshop, Neum 2009 17
Plan for second iteration (cont’d)
• Object-oriented model for the second iteration
Tempura
TInterpreter
+ init () : int
TReducer
TLexer
TParser
TAssignmentReducer
TException
TInputOutput
TUtilsTNode
TInteger TStringTLink
TDouble TBoolean
TEnvironment
TBlock
TBinding
TList
TName
TSymbolTMemory
TLocation
TExpressionReducer
TListReducer
TLinearReducer
TIOReducer
TIntervalReducer
TStatement
TSymbolReducerTSystemRecurer
TStack
TState
SEERE Workshop, Neum 2009 18
Plan for third iteration
• research– analyze different runtime verification (RV) tools and
frameworks – learn different RV strategies– choose suitable strategy for our needs (service
monitoring, scenario detection, Java)
• implementation– towards runtime verification framework– implement at least one of the strategies