IMPROVING THE ROOT INTERPRETER
a.k.a. Cling
Javier López-Gómez <jalopezg@inf.uc3m.es> September 29, 2019
Computer Architecture and Technology Area, University Carlos III of Madrid
IMPROVING THE ROOT INTERPRETER Javier Lpez-Gmez - - PowerPoint PPT Presentation
a.k.a. Cling September 29, 2019 Computer Architecture and Technology Area, University Carlos III of Madrid IMPROVING THE ROOT INTERPRETER Javier Lpez-Gmez <jalopezg@inf.uc3m.es> A CS PhD. student @ARCOS UC3M (Computer Architecture
Computer Architecture and Technology Area, University Carlos III of Madrid
1/19
2/19
3/19
3/19
3/19
Source code Scanner (Lex) Parser (Parse) Semantic analysis (Sema) AST IR generation (CodeGen) … Object code 4/19
equation ::= expr '=' expr ; expr ::= '(' expr ')' | expr '+' expr | expr '^' expr | NUMBER | IDENTIFIER ;
5/19
equation expr '=' expr expr 'a' ^ expr 2 ( expr expr '+' expr ) expr 'b' ^ expr 2 expr 'c' ^ expr 2
6/19
declaration-list ::= declaration-list declaration | declaration ; declaration ::= type IDENTIFIER ';' | type IDENTIFIER '=' expr ';' ; type ::= 'int' | 'double' ; expr ::= '(' expr ')' | ...
7/19
declaration-list |- declaration `j' type=int | `- initial value 3 `- declaration `i' type=int `- initial value j
8/19
`-FunctionDecl 0xf317a0 </tmp/in.cpp:1:1, col:34> col:5 f 'int (int)' |-ParmVarDecl 0xf316c0 <col:7, col:15> col:11 used x 'int' cinit | `-IntegerLiteral 0xf31720 <col:15> 'int' 0 `-CompoundStmt 0xf31908 <col:18, col:34> `-ReturnStmt 0xf318f8 <col:20, col:31> `-BinaryOperator 0xf318d8 <col:27, col:31> 'int' '+' |-ImplicitCastExpr 0xf318c0 <col:27> 'int' <LValueToRValue> | `-DeclRefExpr 0xf31880 <col:27> 'int' lvalue | ParmVar 0xf316c0 'x' 'int' `-IntegerLiteral 0xf318a0 <col:31> 'int' 1
9/19
int f(int x); int f(int x) { return 0; } // OK, no previous definition 10/19
int foo = 0; double foo; // Can't redefine 'foo' in this scope int f(int x) { return 0; } int f(int x) { return x + 1; } // Ditto
11/19
12/19
12/19
namespace { unsigned int i = 0; // line 1 namespace { double i = 1.0; // line 2 namespace { … } } }
namespace __cling_1 { unsigned int i = 0; // line 1 } namespace __cling_2 { using namespace __cling_1; double i = 1.0; // line 2 } …
13/19
inline namespace __cling_N50 { int foo = 0; /* input line 1 */ } inline namespace __cling_N51 { double foo; /* input line 2 */ } …
14/19
15/19
16/19
17/19
18/19
root [0] int f(int x) { return 0; } root [1] int f(int x) { return (x << 1); } root [2] f(4) (int) 8
19/19
19/19