ooo-build r11725 - trunk/doc



Author: noelpwer
Date: Wed Feb 27 19:07:04 2008
New Revision: 11725
URL: http://svn.gnome.org/viewvc/ooo-build?rev=11725&view=rev

Log:
some more code-walkthought, must fill with detail about the code image
etc ( and how that interacts with the module/parser )


Modified:
   trunk/doc/macro-compile-parse.txt

Modified: trunk/doc/macro-compile-parse.txt
==============================================================================
--- trunk/doc/macro-compile-parse.txt	(original)
+++ trunk/doc/macro-compile-parse.txt	Wed Feb 27 19:07:04 2008
@@ -6,16 +6,62 @@
 for the purpose of example consider the following module code
 
 e.g. 
-
-REM  *****  BASIC  *****
-
-Sub Main
-n = 52
-cMAX = 10.234
-Dim mRangeArray(0, 0) as String
-ReDim mRangeArray(CInt(cMAX), n) as String
-'msgbox (  ("here"), cInt(2) , "foo" )
-End Sub
+line: content
+-------------
+1     REM  *****  BASIC  *****
+2     
+3     Sub Main
+4     n = 52
+5     cMAX = 10.234
+6     Dim mRangeArray(0, 0) as String
+7     ReDim mRangeArray(CInt(cMAX), n) as String
+8     'msgbox (  ("here"), cInt(2) , "foo" )
+9     End Sub
+
+
+this compiles into the following pcode
+
+SbiRuntime::StepSTMNT (3, 0)
+SbiRuntime::StepSTMNT (4, 0)
+SbiRuntime::StepFIND (2, 12)
+SbiRuntime::StepLOADI (52)
+SbiRuntime::StepPUT
+SbiRuntime::StepSTMNT (5, 0)
+SbiRuntime::StepFIND (3, 12)
+SbiRuntime::StepLOADNC (4)
+SbiRuntime::StepPUT
+SbiRuntime::StepSTMNT (6, 0)
+SbiRuntime::StepLOCAL (5, 8)
+SbiRuntime::StepARGC
+SbiRuntime::StepLOADI (0)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepLOADI (0)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepFIND (32773, 8)
+SbiRuntime::StepDIM
+SbiRuntime::StepSTMNT (7, 0)
+SbiRuntime::StepFIND (5, 8)
+SbiRuntime::StepERASE
+SbiRuntime::StepARGC
+SbiRuntime::StepARGC
+SbiRuntime::StepFIND (3, 12)
+SbiRuntime::StepARGV
+SbiRuntime::StepRTL (32774, 2)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepFIND (2, 12)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepFIND (32773, 8)
+SbiRuntime::StepREDIM
+SbiRuntime::StepSTMNT (9, 0)
+SbiRuntime::StepLEAVE
 
 REM and its line contents are practically ignored as they are not compilable content, ditto the blank lines, the Next significate line to be processed is
 
@@ -61,16 +107,55 @@
                       note: first call of SbiCodeGen::Gen will generate a statement ( STMNT  ) prior ti the desired type ( so in fact this will generates StepSTMNT(..) followed by StepFIND
                    the above generates the lhs of the assignment
                    for the rhs another SbiExpression is created e.g. SbiExpression aExpr(this) - note the lack a SbSYMBOL in the ctor [3]
-                   aExpr.Gen() is called  ( which generated another _FIND (*I think*) )
+                   aExpr.Gen() is called  ( which generates _NUMBER with 52 )
                    and then a _PUT is forced
 2nd iter
 ========
          processes newline
-2nd iter
+3rd iter
 ========
          processes cMAX = 10.234
+            the processing is identical to the previous processing for "n = 52"
+4th iter
+========
+
+         Dim mRangeArray(0, 0) as String
 
+         fixed token to be consumed is of course the Dim
+         from the StmntTable we know SbiParser::DIM
+         First a STMNT is generated
+         then SbiParser::Dim()
+            calls SbiParser::DefVar()
+               calls SbiParser::VarDecl
+                   if the peeked token is a LPARAM then
+                      creates pDim = new SbiDimList( this );
+                         loops around each comma delimited expression ( and creates a SbiExpression for those )
+                   call TypeDecl to see if there is a 'as something' following the variable declaration  
+               add the SbiSymDef returned from SbiParser::VarDecl to the localvariables
+               another STMNT is emmited
+               An expression is created from the SbiSymDef returned from SbiParser::VarDecl ( no further parsing here, it's already done, it just sets up the info in the SbiExpression to allow the appropriate p-code to be emitted )
+               calling the Gen() on the the SbiExrNode recusively calls each SbiExprNode via aVar.pNext ( where aVar is essentially struture containing a linked list of more nodes, paramaters ( SbiExprList ( ARGC/ARGV ) ) & a symbol definition.
+
+this essentially results in the following pcode generated for the line above
+
+SbiRuntime::StepLOCAL (5, 8)     aVar.pNext->Gen() ( I think )
+SbiRuntime::StepARGC             aVar.pVar->Gen() - results in the SbiExprList->Gen()
+SbiRuntime::StepLOADI (0)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepLOADI (0)
+SbiRuntime::StepBASED (0)
+SbiRuntime::StepARGV
+SbiRuntime::StepARGV
+SbiRuntime::StepFIND (32773, 8)
+SbiRuntime::StepDIM
+
+5th iter
+---------
+7:     ReDim mRangeArray(CInt(cMAX), n) as String
 
+    this follows nearly the same path as above with the exception that a secodary sub-parsing happens for CInt(cMAX) which results in some extra processing for the RTL function ( and it's paramaters )
 [1]
 SbiExpression() this class is passed an instance of the parser and all of the work is done in the ctor,
   basically depending of the type passed either
@@ -91,7 +176,10 @@
           the SbiExprNode always has a valid instance of SbiParameters associated with it ( event if there are no paramaters ) so a new SbiParameters is created 
           column is unlocked and the SbiNode created previously is returned
 
----------
+      
+[2]
+A symbol definintion is defined by the SbiSymDef class, it of course defines the name of the symbol, it's type, it's scope, and can of course also define it's own symbols ( e.g. if the symbol is a procedure )
+
 [3]
 SbiExpression::SbiExpression calles
     SbiExpression::Boolean() is called for a Standard expression
@@ -100,8 +188,10 @@
                 in the case of "n = 52" in Unary() pNd is set to result of Operand()
                     Operand()
                         just returns a new SbiExpression for a simple number, result falls back through each of the previous AddSub(), Mod(), IntDiv() etc. calls 
-[2]
-A symbol definintion is defined by the SbiSymDef class, it of course defines the name of the symbol, it's type, it's scope, and can of course also define it's own symbols ( e.g. if the symbol is a procedure )
+
+
+The Tokenizer
+=============
 
 The tokenizer is a strange beast that operates with
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]