Presentation is loading. Please wait.

Presentation is loading. Please wait.

TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies.

Similar presentations


Presentation on theme: "TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies."— Presentation transcript:

1 TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies

2 Needed for better description of data to the compiler Optional in source-code (always present internally) Core types: boolean, integer, real, array, tarray, string, char, struct, list, group, enum, union, object, proc hash (numeric hash) dict (string hash) cproc The Type system

3 A value's type is declared as a cast: set a struct:{ int:x f64:y } Variables can be constrained by a type: define a struct:{ int:x f64:y } Variables can reference another variable: let a b set a 3 ;# 3 → a → b The Type system TYPE:VALUE

4 What is a type? struct:{ integer:refOnly @create @cast @toString @set @get @length @copy @clone @exec @setMember@getMember@refMember @setIndex@getIndex@refIndex @setRange@getRange@refRange @add@sub@mul@div@exp @asr@asl@rsh@lsh @eq@ne@ge@le @gt@lt @csgn@num@neg@not } The Type system

5 Values in memory VARIABLE DATA (64-bits) Extra Desc. (32-bits) TYPE+FLAGS (32-bits) RAW DATA INDEX TO TYPE DESCRIPTOR EXTRA DESCRIPTIONS FLAGS DATA MODES

6 Values in memory a Pointer (64-bits) Index (32-bits) TYPE+FLAGS (32-bits) 1 4 -5 67 4 INDEX TO TYPE GROUP INDEX TO TYPE INTEGER FLAGS:0 MODES:? set a {group:integer}:{1 4 -5 integer:”67” integer:4.3}

7 TyCL supports the global and local scopes but not namespaces yet, however the syntax to reference such variables is a bit different Local variables: They are just as Tcl's ones Accessed inside execution blocks only TyCL's Scopes & data access

8 Global variables: Variables stored at the root of the calling stack TyCL has its own way to reference this variables from any part of the program without using the command: global (as Tcl does) by prefixing the name with a dot (.) TyCL's Scopes data & access

9 Global variables (example): set a 4; # global variable proc foo {x} { set.a $x; # the global 'a' is accessed } foo 99;# actually: 'a' is set to the value: 99 TyCL's Scopes & data access

10 Accessing internal members: Types such as struct, object, or enum, have internal members (or fields), these members can be accessed by joining the variable's name and the member's name with a dot (.) and by following the previous rules if the variable is global or local. If the access to an object's member is present inside one of its own methods, a new prefix: 'my' must be used to indicate that such member is present inside itself. TyCL's Scopes & data access

11 Struct's fields (example): set point struct:{ float:x float:y } set point.x 88;# access to point's field: x set point.y 314;# access to point's field: w TyCL's Scopes & data access

12 Object's members (example): set a object:{ x 0 ~count {} { incr my.x 1 ;# access to a.x puts “call number: $my.x”;# access to a.x } a.count;# It should print: 'call number: 1' a.count;# It should print: 'call number: 2' TyCL's Scopes & data access

13 A new syntax was created to handle indexes an ranges for data-types that support them, which account for all except objects and structs # for indexes VARIABLE_NAME(INDEX) # for ranges VARIABLE_NAME(INITIAL_INDEX.. FINAL_INDEX) TyCL's Indexes and Ranges

14 Integers: gets or sets particular bits. Floats: gets or sets particular bits. Boolean: gets or sets bits, but the complete values is stored always as 0 or 1. Chars: gets or sets particular bits. Strings: gets or sets particular characters. Arrays: gets or sets particular values. Lists: gets or sets particular values. Groups: gets or sets particular values. TyCL's Indexes and Ranges

15 Using indexes to insert, append replace data # inserts the value before index set VARIABLE_NAME(*INDEX) VALUE # inserts the value after the index set VARIABLE_NAME(INDEX*) VALUE if the index is -1, it references the last item in the content, thus an append would be written as: set VARIABLE_NAME(-1*) VALUE ;# this is an append Expansion: by prefixing the index with a plus-sign '+' set VARIABLE_NAME(+-1*) VALUE ;# this is an append # and expand TyCL's Indexes and Ranges (cont.)

16 proc FUNCTION_NAME PARAMETERS BODY [proc PARAMETERS BODY] Parameters: Return value: TYPE:* Required: exactly as TCL's Optional: exactly as TCL's Named: -PARAMETER Flags: --FLAG Boolean variables which are false by default Procedures (functions) What is different? Parameters can be typed

17 funcname 1 2 list:{a 4 5.7} -x 99 --nocount All arguments are passed by reference … except for native types: boolean, integer, real but, … not exactly! proc func {@var} {...BODY...} Calling a proc

18 Architecture TyCL Source code Application Lexical Parser TIR Binary Tree WordCo de Generato r WordCode Binary Machine Code Generato r Virtual Machine Binary code Code+Tables

19 Status The project is close to have a working (basic and naive compiler) version on Linux i386 Only the compiler Next: On-the-fly interpreter A port to Linux on ARM and X86_64 The posibility to run TyCL code in compiling time...this allows the modification of the whole compiler right at the spot.

20 To anyone interested … in any way :) aabuss@otlettech.com aabuss@gmail.com


Download ppt "TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies."

Similar presentations


Ads by Google