THIS IS AN OUTDATED TOY VERSION OF REGLOCK !!!!!


Our latest work integrates our type system to Cyclone language

Reglock User's Manual

The latest version of this manual should be available at
svn+ssh://svn.softlab.ntua.gr/var/lib/svnrepos/svn-pl/internal/reglock/branches/mlock_impl
Tar ball for external visitors

1  Introduction

This manual is meant to provide an informal introduction to Reglock.
Obviously, Reglock is a work in progress and we expect to make substantial changes to the design and implementation. Your feedback (and patience) is greatly appreciated.

2  Installation

2.1  Compilation

This section describes the compilation steps required to build reglock.

Prerequisites
This a list of software packages that must be installed on your system before compiling and installing Reglock.
Download reglock
Secure SVN access to lazy.softlab.ntua.gr is required to complete this step.
 svn co  svn+ssh://svn.softlab.ntua.gr/var/lib/svnrepos/svn-pl/internal/
    reglock/branches/mlock_impl
Change directory
Assuming that $REGLOCK_ROOT is the root path where mlock_impl is located then
 cd $RECLOCK_ROOT/mlock_impl/src
Compile Reglock
Make program is required in order to complete this step.
make
Run examples (Optional)
A new executable file named "f" should appear in $REGLOCK_ROOT/mlock_impl/src
./f ../tests/testtype.x

or you could run test cases that should fail :

./f ../tests/testtype_fail.x

3  Compiler

3.1  Options

This section describes the Reglock compiler options.Make sure you have completed Section 2 before proceeding.

Compiler options
[pgerakios@localhost src]$ ./f --help

Parsing args ...
 -I Append a directory to the search path
 -s Specify compilation stage: 0 = Parse , 1 = Binding , 
            2 = Type-checking , 3 = Interpret
 -v Specify verbosity level: 0 = None , 1 = Some ,
        2 = More , 3 = Lots
 -help  Display this list of options
 --help  Display this list of options 
Compilation stage
Reglock is a front-end compiler and interpreter. This option allows to skip some compilation steps. Option s (for stage) can take the following values Example: If you don’t want to enter the type-checking and interpretation stage you can specify the "-s 1" option.
[pgerakios@localhost src]$ ./f   -s 1 ../tests/testtype.5
Parsing args ...
Parsing file ../tests/testtype.5 [OK]
Binding ...  [OK]
Compilation successful.
Verbosity level
The compiler may become quite verbose mainly at the type-checking stage. The default value is "0" and the maximum value is "3".

Example:

[pgerakios@localhost src]$ ./f  -s 2 -v 2 ../tests/testtype.5

Parsing args ...
Parsing file ../tests/testtype.5 [OK]
Binding ... [OK]
Type-checking ...

Checking --> printInt  =  \ x. () as {} int -> unit {}
Ascripted type:  {} int -> unit {}

Checking --> printRgn  =  \ 'r. \ x. () as {} rgn('r) -> unit {}
Ascripted type:  Forall 'r. {} rgn('r) -> unit {}

Checking --> printIntRef  =  \ 'r. \ x. () as {} ref(int,'r) -> unit {}
Ascripted type:  Forall 'r. {} ref(int,'r) -> unit {}

Checking --> main  =  \ 'H. \ hrgn. newrgn 'r,x @ hrgn in ((thread1 ['r]) x $);rcapdec hrgn as {('H,1,bot,)} rgn('H) -> unit {('H,0,bot,)}
Ascripted type:  Forall 'H. {('H,1,bot,)} rgn('H) -> unit {('H,0,bot,)}

Checking --> thread1  =  \ 'r. \ x. rcapdec x as {('r,1,bot,)} rgn('r) -> unit {('r,0,bot,)}
Ascripted type:  Forall 'r. {('r,1,bot,)} rgn('r) -> unit {('r,0,bot,)}  [OK]
Interpretation
Once the type-checking stage has completed successfully the interpreter takes action: The interpreter is by default on verbose mode 3 so you should expect lots of output. The intepreter basically picks a thread of execution, evaluates (single-step semantics) the thread’s expression and prints out the following:

3.2  Syntax

 toplevel :
    EOF
  | def ID = TopFunc ; toplevel
  | def TVarList = TopType ; toplevel
 
 TVarList:
     'ID 
  |  'ID , TVarList

 TopType:
    Type
  | \ ( TVarList ).Type

 TopFunc:
   \ ID . Term as Type
  | \ TVarList . TopFunc

 Capability: 
    bar(n)
  | *
  | bot
  | n

     
Effect:
      ( 'ID , Capability , Capability , TVarList )
    | ( 'ID , Capability , Capability  )
    | ( TVarList )
    
EffectList:
 | Effect EffectList

TypeDef:
 |  LBRACKET TVarList RBRACKET 
 
AtomicType:
     int
   | ()
   | rgn ( 'ID ) 
   | ref ( Type , 'ID ) 
   | ref ( Type , 'NULL ) 
   | { EffectList } Type -> Type {  EffectList }
   | \ 'ID . Type
   | exists 'ID ( 'ID , TVarList )  . Type
   | 'ID TypeDef

TypeX:
    AtomicType
  | AtomicType * TypeX 
  | ( TypeX )

 Type:
   TypeX

 Term:
    AppTerm 
  | !Term 
  | -Term 
  | not Term 
  | if Term then Term else Term 
  | while Term do Term
  | open Term 'ID , ID in Term
  | pack 'ID, Term as Type 
  | new Term @ Term
  | newrgn 'ID,ID @ Term in Term
  | rcapi Term
  | rcapd Term
  | lcapi Term
  | lcapd Term
  | let ID = Term in Term
  | Term binop Term 

Scope:
  | $

Assign:
  | COLON := Term

AppTerm :
    PathTerm Assign
  | AppTerm PathTerm  Scope
  | AppTerm [ 'ID  ]

PathTerm:
   PathTerm.n
  | AtomicTerm

TermSeq : 
    Term
  | Term , TermSeq
  | Term ; TermSeq

ParenSeq:
  | TermSeq

AtomicTerm:
    ( ParenSeq )
  | ID
  | n
  | null
 
 

4  FAQ

Question
why are parentheses necessary around ’r below?
 def 'List = \ ('r). ref (int * 'List ['r], 'r); 
 

Answer: We only allow top-level region polymorphism in user-defined types. Therefore, when there exist several region names (a list of names) then the parenthesis aid in delimiting those regions. Consider a List whose nodes are allocated at different regions:

        def 'List = \ ('r1,'r2). ref (int * 'List ['r2], 'r1);
 

Index


This document was translated from LATEX by HEVEA.