RPA Toolkit
work on the cache subsystem, found out the indirect left recursion(loop) is broken
authorMartin Stoilov <martin@rpasearch.com>
Tue, 5 Apr 2011 06:42:19 +0000 (23:42 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Tue, 5 Apr 2011 06:42:19 +0000 (23:42 -0700)
19 files changed:
datapatterns/directloop.rpa [new file with mode: 0644]
datapatterns/indirectloop.rpa [new file with mode: 0644]
datapatterns/loopy.rpa
rgrep/ecma262.rpa [new file with mode: 0644]
rgrep/rpagrep.c
rgrep/unix/main.c
rpa2/build/linux/rpa.mk
rpa2/rpacache.c [new file with mode: 0644]
rpa2/rpacache.h [new file with mode: 0644]
rpa2/rpacompiler.c
rpa2/rpadbex.c
rpa2/rparecord.h
rpa2/rpastat.c
rpa2/rpastat.h
rpa2/rpavm.c
rvm/rvmcpu.c
testrpa2/rpacompiler-rulealtrec.c
testrpa2/rpacompiler-ruleloop.c
testrpa2/rpacompiler-ruleloopcls.c

diff --git a/datapatterns/directloop.rpa b/datapatterns/directloop.rpa
new file mode 100644 (file)
index 0000000..a90ee1a
--- /dev/null
@@ -0,0 +1,5 @@
+term    ::= [0-9]+ | '(' <:exp:> ')'
+exp     ::= <:exp:> '+' <:term:> |
+            <:exp:> '-' <:term:> |
+            <:term:>
+
diff --git a/datapatterns/indirectloop.rpa b/datapatterns/indirectloop.rpa
new file mode 100644 (file)
index 0000000..a9111ff
--- /dev/null
@@ -0,0 +1,6 @@
+term    ::= [0-9]+ 
+expop   ::= <:exp:> '+' <:term:> |
+            <:exp:> '-' <:term:> |
+            <:exp:> '*' <:term:> |
+            <:exp:> '/' <:term:>
+exp     ::= <:expop:> | <:term:>
index f8a5a17..5396988 100644 (file)
@@ -1,12 +1,12 @@
 abra   ::= [0-9]+
 #cadabra ::= <:abra:>abc
 
-term    ::= [0-9]+ | '(' <:exp:> ')'
+term    ::= [0-9]+ 
 expop   ::= <:exp:> '+' <:term:> |
             <:exp:> '-' <:term:> |
             <:exp:> '*' <:term:> |
             <:exp:> '/' <:term:> |
-            (<:exp:> - (<:exp:> -^ [a-z])) '&' <:term:>
+            <:term:>
 exp     ::= <:expop:> | <:term:>
 
 
diff --git a/rgrep/ecma262.rpa b/rgrep/ecma262.rpa
new file mode 100644 (file)
index 0000000..110f210
--- /dev/null
@@ -0,0 +1,398 @@
+# 6 Source Text
+SourceCharacter                ::= .
+
+# 7.2 White space
+WhiteSpace                             ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
+
+# 7.3 Line Terminators
+LineTerminator                 ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
+LineTerminatorSequence ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
+S                                              ::= ( <WhiteSpace> | <LineTerminator> )+
+SC                                             ::= <S>? ';' <S>?
+COMMA                                  ::= <S>? ',' <S>?
+EQ                                             ::= <S>? '=' <S>?
+
+# 7.4 Comments
+Comment                                ::= <:MultiLineComment:> | <:SingleLineComment:>
+MultiLineComment               ::= '/*' <:MultiLineCommentChar:>* '*/'
+MultiLineCommentChar   ::= . - '*/'
+SingleLineComment              ::= '#' <:SingleLineCommentChar:>*
+SingleLineCommentChar  ::= <SourceCharacter> - <LineTerminator>
+
+# 7.5 Tokens
+Token                                  ::= <:IdentifierName:> |
+                                               <:NumericLiteral:> |
+                                               <:StringLiteral:>
+
+# 7.6 Identifier Names and Identifiers
+
+Identifier                             ::= <IdentifierName> - <ReservedWord> - <ReservedWord> <IdentifierPart>
+IdentifierName                 ::= <IdentifierStart> <IdentifierPart>*
+IdentifierStart                ::= <UnicodeLetter> | '$' | '_' | '\' <:UnicodeLetter:>
+UnicodeLetter                  ::= <Lu> |
+                       <Ll>
+
+Lu                                             ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232]   # TBD
+Ll                                             ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE]                                               # TBD
+IdentifierPart                 ::= <IdentifierStart> | 
+                                   <:UnicodeDigit:> 
+UnicodeDigit           ::= [0-9] | [#0x0660-#0x0669]                                   # TBD
+
+ReservedWord                   ::= <:Keyword:>
+                                                       <:FutureReservedWord:> |
+                                                       <:NullLiteral:> |
+                                                       <:BooleanLiteral:>
+
+Keyword                                ::= 'instanceof' | 'typeof'     | 'break' |
+                                               'do' | 'new' | 'var' |
+                                               'case' | 'else' | 'return' | 'void' | 
+                                               'catch' | 'finally' | 'continue' | 'for' | 
+                                               'switch' | 'while' | 'this' | 'with' | 
+                                               'debugger' | 'function' | 'throw' | 'default' |  
+                                               'if' | 'try' | 'delete' | 'in'
+
+FutureReservedWord                     ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
+                                                       'implements' | 'let' | 'private' | 'public' |
+                               'static' | 'interface' | 'package' | 'protected'
+
+NullLiteral                                    ::= 'null'
+BooleanLiteral                                 ::= 'true' | 'false'
+Literal                                        ::= <:NullLiteral:> |
+                                                       <:BooleanLiteral:> |
+                                                       <:NumericLiteral:> |
+                                                       <:StringLiteral:>
+                                                       
+LiteralOp                                      ::= <:Literal:>
+
+# 7.8.3 Numeric Literals
+
+NumericLiteral                                 ::= <:HexIntegerLiteral:> | <:DecimalNonIntegerLiteral:> | <:DecimalIntegerLiteral:>
+DecimalNonIntegerLiteral               ::= ('0' | <:NonZeroDigit:> <DecimalDigits>?) '.' <DecimalDigits>? <:ExponentPart:>? |
+                                                               '.' <:DecimalDigits:> <:ExponentPart:>? 
+DecimalIntegerLiteral                  ::= '0' | <:NonZeroDigit:> <:DecimalDigits:>? <:ExponentPart:>?
+DecimalDigits                                  ::= <:DecimalDigit:>+
+DecimalDigit                                   ::= [0-9]
+NonZeroDigit                                   ::= [1-9]
+ExponentPart                                   ::= <:ExponentIndicator:> <:SignedInteger:>
+ExponentIndicator                              ::= [eE]
+SignedInteger                                  ::= '-' <:DecimalDigits:> |
+                                                               '+' <:DecimalDigits:> |
+                                                               <:DecimalDigits:>
+HexIntegerLiteral                              ::= '0' [xX] <:HexDigit:>+
+HexDigit                                               ::= [0-9a-fA-F]
+
+# 7.8.4 String Literals
+StringLiteral                                  ::= '"' <:DoubleStringCharacters:>? '"' |
+                                                               "'" <:SingleStringCharacters:>? "'"
+
+DoubleStringCharacters                 ::= <DoubleStringCharacter>+
+SingleStringCharacters                 ::= <SingleStringCharacter>+
+
+DoubleStringCharacter                  ::= <:SourceCharacter:> - ('"' | '\\' | <:LineTerminator:>)
+
+SingleStringCharacter                  ::= <:SourceCharacter:> - ("'" | '\\' | <:LineTerminator:>)
+
+BracketExpressionOp                            ::= '(' <S>? <:Expression:> <S>? ')'
+ThisOp                                                 ::= 'this'
+
+PrimaryExpression                              ::= <:ThisOp:> | 
+                                                               '(' <S>? <:Expression:> <S>? ')' |
+                                                               <:LiteralOp:> |
+                                                               (<:SwiId:>) |
+                                                               <:IdentifierOp:>
+
+# The next line is mine
+IdentifierOp                                   ::= <:Identifier:> 
+SwiId                                                  ::= <:Identifier:> 
+SwiIdExist                                             ::= <SwiId> 
+
+
+ArrayLiteral                                   ::= '[' <S>? <:Elision:>? <S>? ']' |
+                                                               '[' <S>? <:ElementList:> <S>? ']' |
+                                                               '[' <S>? <:ElementList:> <S>? ',' <S>? <:Elision:> <S>? ']'
+ElementList                                            ::= <:Elision:>? <S>? <:AssignmentExpression:> (<S>? ',' <S>? <:Elision:>? <S>? <:AssignmentExpression:> )*
+Elision                                                        ::= ',' <S>? <:Elision:> | <S>? ','
+
+
+# 11.2 Left-Hand-Side Expressions
+NewKeyword                                             ::= 'new' - 'new' <IdentifierPart>
+LSB                                                            ::= <S>? '[' <S>?
+RSB                                                            ::= <S>? ']' <S>?
+dot                                                            ::= '.'
+MemberIdentifierNameOp                 ::= <:Identifier:>
+MemberIdentifierNameLookupOp   ::= <:Identifier:>
+MemberExpressionBaseOp                 ::= <:MemberExpression:>
+MemberExpressionIndexOp                        ::= <:MemberExpressionBaseOp:>  <:LSB:> <:Expression:> <:RSB:>
+MemberExpressionNameOp                 ::= <:MemberExpressionBaseOp:> <:dot:> <:MemberIdentifierNameOp:>
+MemberExpressionNewOp                  ::= <:NewKeyword:> <S>? <:CallExpression:>
+
+MemberExpression                               ::= <:MemberExpressionIndexOp:>  |
+                                                                       <:MemberExpressionNameOp:> |
+                                                                       <:FunctionExpression:> |
+                                                                       <:PrimaryExpression:>
+
+NewExpressionCallName                  ::= <:MemberExpression:>
+NewExpressionCallOp                            ::= <:NewKeyword:> <S>? <:NewExpressionCallName:> <S>? <:ArgumentsOp:>?
+NewArrayExpressionOp                   ::= <S>? 'new' <S> ( 'Array' | 'Object') <S>? <ArgumentsOp>?
+
+NewExpression                                  ::= <:NewArrayExpressionOp:> |
+                                                                       <:NewExpressionCallOp:> |
+                                                                       <:MemberExpression:>
+
+FunctionCallName                               ::= <:CallExpression:> | <:MemberExpression:>
+CallExpressionOp                               ::= <:FunctionCallName:> <S>? <:ArgumentsOp:>
+CallExpressionBaseOp                   ::= <:CallExpression:>
+CallExpressionIndexOp                  ::= <:CallExpressionBaseOp:> <S>? '[' <S>? <:Expression:> <S>? ']'
+CallExpressionNameOp                   ::= <:CallExpressionBaseOp:> '.' <:MemberIdentifierNameOp:>
+
+CallExpression                                 ::= <:CallExpressionIndexOp:> |
+                                                                       <:CallExpressionNameOp:> |
+                                                                       <:CallExpressionOp:>
+
+ArgumentsOp                                            ::= '(' <S>? ')' |
+                                                               '(' <S>? <:ArgumentList:> <S>? ')'
+ArgumentList                                   ::= <:ArgumentList:> <S>? ',' <S>? <:AssignmentExpression:> |
+                                                                       <:AssignmentExpression:>
+
+ArgumentList                                   ::= <:ArgumentList:> <S>? ',' <S>? <:FunctionCallParameter:> |
+                                                                       <:FunctionCallParameter:>
+FunctionCallParameter                  ::= <:AssignmentExpression:>
+                                                                       
+ValLeftHandSideExpression              ::= <:CallExpression:> | <:NewExpression:>
+AddressLeftHandSideExpression  ::= <:ValLeftHandSideExpression:>
+LeftHandSideExpression                 ::= <:AddressLeftHandSideExpression:>
+
+
+# 11.3 Postfix Expressions
+# RULE: LeftHandSideExpression always ends up in R0 (Let see if this would work)
+PostfixOperator                                ::= '++' | '--'
+PostfixExpressionOp                    ::= <:LeftHandSideExpression:> <:PostfixOperator:>
+PostfixExpressionValOp                 ::= <:ValLeftHandSideExpression:>
+PostfixExpression                              ::= <:PostfixExpressionOp:> |
+                                                                       <:PostfixExpressionValOp:> 
+
+PrefixOperator                                         ::= <:PostfixOperator:>
+PrefixExpressionOp                             ::= <:PrefixOperator:> <:LeftHandSideExpression:>
+PrefixExpression                               ::= <:PrefixExpressionOp:>
+
+# 11.4 Unary Operators
+UnaryOperatorOpcode                            ::= '~' | '!' | ('+' - '++') | ('-' - '--') | 'delete' | 'void' | 'typeof'
+UnaryOperator                          ::= <:UnaryOperatorOpcode:>
+UnaryExpressionOp                      ::=     <S>? <:UnaryOperator:> <S>? <:UnaryExpression:>
+UnaryExpression                                ::=     <:UnaryExpressionOp:> | <:PrefixExpression:> | <:PostfixExpression:>
+
+
+# 11.5 Multiplicative Operators
+MultiplicativeOperator                         ::= '*' | '/' | '%'
+MultiplicativeExpressionOp             ::= <:MultiplicativeExpression:> <S>? <:MultiplicativeOperator:> <S>? <:UnaryExpression:>
+MultiplicativeExpression               ::= <:MultiplicativeExpressionOp:> | 
+                                                                       <:UnaryExpression:>
+
+# 11.6 Additive Operators
+AdditiveOperator                               ::= '+' | '-'
+AdditiveExpressionOp                   ::= <:AdditiveExpression:> <S>? <:AdditiveOperator:> <S>? <:MultiplicativeExpression:>
+AdditiveExpression                             ::= <:AdditiveExpressionOp:> | 
+                                                                       <:MultiplicativeExpression:>
+
+
+11.7 Bitwise Shift Operators
+ShiftOperator                                  ::= '>>>' | '<<' | '>>'
+ShiftExpressionOp                              ::= <:ShiftExpression:> <S>? <:ShiftOperator:> <S>? <:AdditiveExpression:>
+ShiftExpression                                        ::= <:ShiftExpressionOp:> |
+                                                               <:AdditiveExpression:> 
+
+
+# 11.8 Relational Operators
+RelationalOperator                             ::= '<=' | '>=' | '<' | '>' | 'instanceof'
+RelationalExpressionOp                 ::= <:RelationalExpression:> <S>? <:RelationalOperator:> <S>? <:ShiftExpression:>
+RelationalExpression                   ::= <:RelationalExpressionOp:> |
+                                                               <:ShiftExpression:>
+
+# 11.9 Equality Operators
+EqualityOperator                               ::= '===' | '==' | '!==' | '!='
+EqualityExpressionOp                   ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpression:> 
+EqualityExpression                             ::= <:EqualityExpressionOp:> |
+                                                               <:RelationalExpression:>
+
+BitwiseANDOperator                             ::= '&' - '&&'
+BitwiseANDOp                                   ::= <:BitwiseANDExpression:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpression:>
+BitwiseANDExpression                   ::= <:BitwiseANDOp:> |
+                                                               <:EqualityExpression:>
+
+BitwiseXOROperator                             ::= '^'
+BitwiseXOROp                                   ::= <:BitwiseXORExpression:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpression:>
+BitwiseXORExpression                   ::= <:BitwiseXOROp:> |
+                                                               <:BitwiseANDExpression:>
+
+BitwiseOROperator                              ::= '|' - '||'
+BitwiseOROp                                            ::= <:BitwiseORExpression:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpression:>
+BitwiseORExpression                    ::= <:BitwiseOROp:> |
+                                                               <:BitwiseXORExpression:>
+
+# 11.11 Binary Logical Operators
+LogicalANDOperator                             ::= '&&'
+LogicalANDOp                                   ::= <:LogicalANDExpression:> <S>? <:LogicalANDOperator:>  <S>? <:BitwiseORExpression:>
+LogicalANDExpression                   ::= <:LogicalANDOp:> |
+                                                               <:BitwiseORExpression:>
+
+LogicalOROperator                              ::= '||'
+LogicalOROp                                            ::= <:LogicalORExpression:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpression:>
+LogicalORExpression                    ::= <:LogicalOROp:> |
+                                                               <:LogicalANDExpression:>
+
+
+# 11.12 Conditional Operator ( ? : )
+AssignmentExpressionIfTrueOp           ::= <:AssignmentExpression:>
+AssignmentExpressionIfFalseOp          ::= <:AssignmentExpression:>
+QuestionMarkOp                                         ::= '?'
+ConditionalExpression                          ::= <:LogicalORExpression:> (<S>? <:QuestionMarkOp:> <S>? <:AssignmentExpressionIfTrueOp:> <S>? ':' <S>? <:AssignmentExpressionIfFalseOp:>)?
+
+# 11.13 Assignment Operators
+LeftHandSideExpressionPush             ::= <:LeftHandSideExpression:>
+IdentifierAddressPush                  ::= <:Identifier:>
+AssignmentExpressionOp                         ::= <:LeftHandSideExpressionPush:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpression:>
+AssignmentExpression                   ::= <:AssignmentExpressionOp:> | 
+                                                                       <:ConditionalExpression:>
+
+AssignmentExpressionNoIn               ::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpressionNoIn:>
+AssignmentOperator                             ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
+
+
+# 11.14 Comma Operator         ( , )
+Expression             ::= <:AssignmentExpression:> ( <S>? ',' <S>? <:AssignmentExpression:> )*
+ExpressionNoIn         ::= <:AssignmentExpressionNoIn:> ( <S>? ',' <S>? <:AssignmentExpressionNoIn:> )*
+
+
+# 12 Statements
+Statement                                              ::= <:FunctionDefinitionStatement:> |
+                                                                       <:BreakStatement:> |
+                                                                       <:ContinueStatement:> |
+                                                                       <:Block:> |
+                                                               <:Comment:> |
+                                                               <:VariableStatement:> |
+                                                               <:EmptyStatement:> |
+                                                               <:ExpressionStatement:> |
+                                                               <:IfStatement:> |
+                                                               <:IterationStatement:> |
+                                                               <:ContinueStatement:> |
+                                                               <:BreakStatement:> |
+                                                               <:ReturnStatement:> |
+                                                               <:WithStatement:> |
+                                                               <:SwitchStatementOp:>
+
+# 12.1 Block
+BlockBegin                                                     ::= <S>? '{' <S>?
+BlockEnd                                                       ::= <S>? '}' <S>?
+Block                                                          ::= <:BlockBegin:> <:StatementList:>? <:BlockEnd:>
+StatementList                                          ::= (<S>? <:Statement:>)+
+
+# 12.2 Variable Statement
+VariableStatement                                      ::= 'var' <S>? <:VariableDeclarationList:> <:SC:>
+VariableDeclarationList                        ::= <:VariableDeclaration:> (<:COMMA:> <:VariableDeclaration:> )*
+VariableAllocate                                       ::= <:Identifier:>
+VariableAllocateAndInit                                ::= <:Identifier:>
+VariableDeclaration                                    ::= <:VariableAllocateAndInit:> <:Initialiser:> | <:VariableAllocate:>
+Initialiser                                                    ::= <:EQ:> <:AssignmentExpression:>
+
+
+# 12.3 Empty Statement
+EmptyStatement                                         ::= <:SC:>
+
+# 12.4 Expression Statement
+ExpressionStatement                            ::= (<:Expression:> - ('function' | '{')) <:SC:>
+
+
+# 12.5 The if Statement
+
+ElseOp                                                         ::= 'else'
+IfConditionOp                                          ::= 'if' <S>? '(' <S>? <:Expression:> <S>? ')'
+IfOp                                                           ::= <:IfConditionOp:> <S>? <:Statement:>
+IfElseOp                                                       ::= <:IfConditionOp:> <S>? <:Statement:> <S>? <:ElseOp:> <S>? <:Statement:>
+
+IfStatement                                                    ::= <:IfElseOp:> |
+                                                                               <:IfOp:>
+
+# 12.6 Iteration Statements
+# 12.6a Iteration do ... while() 
+WhileKeyword                                           ::= 'while'
+WhileExpression                                                ::= <:WhileKeyword:> <S>? '(' <S>? <:Expression:> <S>? ')'
+DoKeyword                                                      ::= 'do'
+IterationDo                                                    ::= <:DoKeyword:> <S>? <:Statement:> <S>? <:WhileExpression:> (<S>? ';')
+
+# 12.6b Iteration while()
+WhileConditionOp                                       ::= 'while' <S>? '(' <S>? <:Expression:> <S>? ')'
+IterationWhileOp                                       ::= <:WhileConditionOp:> <S>? <:Statement:>
+
+# 12.6c Iteration for ( ; ; )
+ForKeyword                                                     ::= 'for'
+ExpressionNoIn                                         ::= <:Expression:>
+ForExpressionInitOp                                    ::= ('var' <S>? <:VariableDeclarationList:>) | <:ExpressionNoIn:>
+ForExpressionCompareOp                         ::= <:Expression:>
+ForExpressionIncrementOp                       ::= <:Expression:>
+
+# The following & expression is done in order to swap the places of the code generated for the comparison and increment.
+# This is done by selectively turning on/off callbacks in both statement so that the final result appears as if the
+# <:ForExpressionCompareOp:> <:ForExpressionIncrementOp:> appear in the opposite order.
+ForIterationStatementOp                                ::= <:ForKeyword:> <S>? '(' <S>? <:ForExpressionInitOp:>? <S>? ';' <S>? <ForExpressionCompareOp>? <S>? ';' <S>? <:ForExpressionIncrementOp:>? <S>? ')'
+IterationForOp                                         ::= <:ForIterationStatementOp:> <S>? <:Statement:>
+
+
+IterationStatement                                     ::= <:IterationWhileOp:> |
+                                                                               <:IterationForOp:> |
+                                                                       <:IterationDo:>
+
+# 12.9 The return Statement
+ReturnOp                                                       ::= ('return' - 'return' <:IdentifierPart:>) <WhiteSpace>* <:AssignmentExpression:>? (<S>? ';')
+ReturnStatement                                                ::= <:ReturnOp:>
+
+# The Break Statement
+BreakOp                                                                ::= 'break' - 'break' <:IdentifierPart:>
+BreakStatement                                         ::= <S>? <:BreakOp:> <:SC:>
+
+# The Continue Statement
+ContinueOp                                                     ::= 'continue' - 'continue' <:IdentifierPart:>
+ContinueStatement                                      ::= <S>? <:ContinueOp:> <:SC:>
+
+
+
+# 12.10 The with Statement
+WithStatement                                          ::= 'with' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:>
+
+
+# 12.11 The switch Statement
+SwitchExpressionOp                                     ::= ('switch' - 'switch' <IdentifierPart>) <S>? '(' <S>? <:Expression:> <S>? ')'
+SwitchStatementOp                                      ::= <:SwitchExpressionOp:> <S>? <:CaseBlock:>
+
+CaseBlock                                                      ::= '{' <S>? <:CaseClauses:>? <S>? <:DefaultClauseOp:>? <S>? <:CaseClauses:>? <S>? '}' |
+                                                                       '{' <S>? <:CaseClauses:>? <S>? '}'
+
+
+
+CaseClauses                                            ::= (<S>? <:CaseClauseOp:>)+
+CaseExpressionOp                                       ::= ('case' - 'case' <IdentifierPart>) <S>? <:Expression:> <S>? ':'
+CaseClauseOp                                           ::= <:CaseExpressionOp:> <S>? <:StatementList:>?
+DefaultKeywordOp                                       ::= 'default' - 'default' <IdentifierPart>
+DefaultClauseOp                                                ::= <:DefaultKeywordOp:> <S>? ':' <S>? <:StatementList:>?
+
+
+# 13 Function Definition
+FunctionName                                           ::= <:Identifier:>
+FunctionNameLookupAlloc                                ::= <:Identifier:>
+FunctionDefinition                                     ::= ('function' - 'function' <IdentifierPart>)<S>?<:FunctionName:><S>?'('<S>?<:FormalParameterList:>?<S>?')'
+FunctionDeclaration                                    ::= <:FunctionDefinition:><S>?'{'<S>?<:FunctionBody:>?<S>?'}'
+FunctionExpression                                     ::= ('function' - 'function'<IdentifierPart>)<S>?<:FunctionName:>?<S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
+FunctionParameter                                      ::= <:Identifier:>
+FormalParameterList                            ::= <:FunctionParameter:> ( <S>? ',' <S>? <:FunctionParameter:> )*
+FunctionDefinitionStatement                    ::= ('function' - 'function' <IdentifierPart>)<S>?<:FunctionNameLookupAlloc:><S>?'('<S>?<FormalParameterList>?<S>?')' <:SC:>
+FunctionBody                                           ::= <:SourceElements:>
+
+
+# 14 Program
+SourceElements                                         ::= (<S>? <:SourceElement:>)+
+SourceElement                                          ::= <:FunctionDeclaration:> |
+                                                                       <:Statement:>
+Program                                                        ::= <:SourceElements:>
+# The root rule, it is anonymous
+<:Program:>
+       
+
index 2a5e38a..f70caf7 100644 (file)
@@ -199,7 +199,7 @@ int rpa_grep_match(rpa_grep_t *pGrep, const char* buffer, unsigned long size)
                rpa_grep_output(pGrep, input, ret, pGrep->encoding);
                rpa_grep_output_utf8_string(pGrep, "\n");
        }
-       pGrep->cachehit = hStat->cache.hit;
+       pGrep->cachehit = hStat->cache->hit;
        rpa_stat_destroy(hStat);
        return 0;
 }
@@ -231,7 +231,7 @@ int rpa_grep_parse(rpa_grep_t *pGrep, const char* buffer, unsigned long size)
                }
                r_array_destroy(records);
        }
-       pGrep->cachehit = hStat->cache.hit;
+       pGrep->cachehit = hStat->cache->hit;
        rpa_stat_destroy(hStat);
        return 0;
 }
@@ -250,11 +250,11 @@ int rpa_grep_scan(rpa_grep_t *pGrep, const char* buffer, unsigned long size)
                return -1;
        rpa_stat_encodingset(hStat, pGrep->encoding);
        hStat->debug = pGrep->execdebug;
-       pGrep->cachehit = hStat->cache.hit;
+       pGrep->cachehit = hStat->cache->hit;
 
 again:
        ret = rpa_stat_scan(hStat, pGrep->hPattern, input, start, end, &matched);
-       pGrep->cachehit += hStat->cache.hit;
+       pGrep->cachehit += hStat->cache->hit;
        if (ret > 0) {
                if (!displayed) {
                        displayed = 1;
index bcbba18..4df9699 100644 (file)
@@ -187,6 +187,11 @@ int main(int argc, const char *argv[])
                }
        }
 
+       if (rpa_dbex_compile(pGrep->hDbex) < 0) {
+
+               goto end;
+       }
+
 
        for (i = 1; i < argc; i++) {
                if (strcmp(argv[i], "--dump-records") == 0) {
@@ -224,20 +229,6 @@ int main(int argc, const char *argv[])
                
        }
 
-       if (rpa_dbex_compile(pGrep->hDbex) < 0) {
-
-               goto end;
-       }
-
-       if (rpa_dbex_compile(pGrep->hDbex) < 0) {
-
-               goto end;
-       }
-
-       if (rpa_dbex_compile(pGrep->hDbex) < 0) {
-
-               goto end;
-       }
 
        for (i = 1; i < argc; i++) {
                if (strcmp(argv[i], "-s") == 0) {
index ff13596..de4a7de 100644 (file)
@@ -5,6 +5,7 @@ RPA_SO = $(OUTDIR)/librpa2.so.1.0
 CFLAGS += -I$(RVM_SRCDIR)/config -I$(SRCDIR)/rlib -I$(SRCDIR)/rvm
 
 RPA_OBJECTS =  \
+       $(OUTDIR)/rpacache.o \
        $(OUTDIR)/rpadbex.o \
        $(OUTDIR)/rpastat.o \
        $(OUTDIR)/rparecord.o \
diff --git a/rpa2/rpacache.c b/rpa2/rpacache.c
new file mode 100644 (file)
index 0000000..6d14d6b
--- /dev/null
@@ -0,0 +1,83 @@
+#include "rpacache.h"
+#include "rmem.h"
+#include "rparecord.h"
+
+#define RPA_MCACHE_BUCKET(_top_, _ruleid_) ( ( ((rulong)(_top_)) ^ ((rulong)(_ruleid_)) ) & RPA_MCACHE_MASK)
+
+
+rpacache_t *rpa_cache_create()
+{
+       rint i;
+       rpacache_t *cache = (rpacache_t*) r_zmalloc(sizeof(*cache));
+
+       if (!cache)
+               return NULL;
+       for (i = 0; i < RPA_MCACHE_SIZE; i++) {
+               cache->entry[i].records = r_array_create(sizeof(rparecord_t));
+               if (!cache->entry[i].records) {
+                       rpa_cache_destroy(cache);
+                       return NULL;
+               }
+       }
+
+       return cache;
+}
+
+
+void rpa_cache_destroy(rpacache_t *cache)
+{
+       rint i;
+
+       if (!cache)
+               return;
+       for (i = 0; i < RPA_MCACHE_SIZE; i++) {
+               if (cache->entry[i].records) {
+                       r_array_destroy(cache->entry[i].records);
+               }
+       }
+       r_free(cache);
+}
+
+void rpa_cache_invalidate(rpacache_t *cache)
+{
+       ++cache->serial;
+}
+
+
+void rpa_cache_disable(rpacache_t *cache, rlong disable)
+{
+       cache->disalbled = disable;
+}
+
+
+void rpa_cache_set(rpacache_t *cache, rlong top, rlong ruleid, rlong ret, rparecord_t* records, rsize_t nrecords)
+{
+       rlong i;
+       rulong bucket = RPA_MCACHE_BUCKET(top, ruleid);
+
+       if (ret <= 0 || cache->disalbled)
+               return;
+//     r_printf("Set the cache @ %ld for: top = %ld, ret = %d, nrecors = %ld, rulename = %s\n", bucket, top, ret, nrecords, records->rule);
+       cache->entry[bucket].ruleid = ruleid;
+       cache->entry[bucket].top = top;
+       cache->entry[bucket].ret = ret;
+       cache->entry[bucket].serial = cache->serial;
+       r_array_setlength(cache->entry[bucket].records, 0);
+       for (i = 0; i < nrecords; i++)
+               r_array_add(cache->entry[bucket].records, &records[i]);
+}
+
+
+rpacachedentry_t *rpa_cache_lookup(rpacache_t *cache, rlong top, rlong ruleid)
+{
+       rulong bucket = RPA_MCACHE_BUCKET(top, ruleid);
+       rpacachedentry_t *entry = &cache->entry[bucket];
+
+       if (entry->serial == cache->serial && entry->ruleid == ruleid && entry->top == top) {
+               rparecord_t *prec = (rparecord_t *)r_array_slot(entry->records, 0);
+//             r_printf("HIT the cache @ %ld,  top = %ld, ret = %ld, rulename = %s\n", bucket, entry->top, entry->ret, prec->rule);
+               ++cache->hit;
+               return entry;
+       }
+       return NULL;
+}
diff --git a/rpa2/rpacache.h b/rpa2/rpacache.h
new file mode 100644 (file)
index 0000000..ea0c974
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef _RPACACHE_H_
+#define _RPACACHE_H_
+
+#include "rtypes.h"
+#include "rarray.h"
+#include "rparecord.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RPA_MCACHE_BITS 8
+#define RPA_MCACHE_SIZE (1 << RPA_MCACHE_BITS)
+#define RPA_MCACHE_MASK (RPA_MCACHE_SIZE - 1)
+
+
+typedef struct rpacachedentry_s {
+       rlong ruleid;
+       rlong top;
+       rlong ret;
+       rulong serial;
+       rarray_t *records;
+} rpacachedentry_t;
+
+typedef struct rpacache_s {
+       rpacachedentry_t entry[RPA_MCACHE_SIZE];
+       rlong hit;
+       rlong disalbled;
+       rulong serial;
+} rpacache_t;
+
+
+rpacache_t *rpa_cache_create();
+void rpa_cache_destroy(rpacache_t *cache);
+void rpa_cache_disable(rpacache_t *cache, rlong disable);
+void rpa_cache_invalidate(rpacache_t *cache);
+void rpa_cache_set(rpacache_t *cache, rlong top, rlong ruleid, rlong ret, rparecord_t* records, rsize_t nrecords);
+rpacachedentry_t *rpa_cache_lookup(rpacache_t *cache, rlong top, rlong ruleid);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 54ec0c4..985efca 100644 (file)
@@ -130,9 +130,10 @@ rint rpa_compiler_loop_begin(rpa_compiler_t *co, const rchar *name, ruint namesi
        exp.start = rvm_codegen_getcodesize(co->cg);
        rvm_codegen_addins(co->cg, rvm_asm(RPA_LOOPDETECT, DA, R_TOP, XX, exp.start));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_CMP, R0, DA, XX, 0));
-       rvm_codegen_addins(co->cg, rvm_asm(RVM_BLES, DA, XX, XX, 4));
+       rvm_codegen_addins(co->cg, rvm_asm(RVM_BLES, DA, XX, XX, 5));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_BGRE, DA, XX, XX, 2));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_MOVS, R0, DA, XX, -1));
+       rvm_codegen_addins(co->cg, rvm_asm(RVM_ADD, R_TOP, R_TOP, R0, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_BX, LR, XX, XX, 0));
 
        rvm_codegen_addins(co->cg, rvm_asm(RPA_CHECKCACHE, DA, R_TOP, XX, exp.start));
@@ -186,7 +187,7 @@ rint rpa_compiler_loop_end(rpa_compiler_t *co)
         * Loop again
         */
        rvm_codegen_addins(co->cg, rvm_asm(RVM_MOV, R_LOO, R0, XX, 0));
-       rvm_codegen_index_addrelocins(co->cg, RVM_RELOC_STRING, exp.emitidx, rvm_asm(RPA_EMITEND, DA, R2, R_LOO, 0));
+       rvm_codegen_index_addrelocins(co->cg, RVM_RELOC_STRING, exp.emitidx, rvm_asm(RPA_EMITEND, DA, R2, R0, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECID, DA, XX, XX, exp.start));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECUID, DA, XX, XX, exp.recuid));
 
@@ -202,7 +203,7 @@ rint rpa_compiler_loop_end(rpa_compiler_t *co)
        rvm_codegen_addins(co->cg, rvm_asm(RVM_MOVS, R0, R_LOO, XX, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_POPM, DA, XX, XX, BIT(R1)|BIT(R_TOP)|BIT(R_LOO)|BIT(R_WHT)|BIT(LR)));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECLEN, R1, XX, XX, 0));
-       rvm_codegen_addins(co->cg, rvm_asml(RPA_SETCACHE, XX, XX, XX, 0));
+       rvm_codegen_addins(co->cg, rvm_asml(RVM_NOP, DA, R0, R1, exp.start)); // TBD: RPA_SETCACHE
        rvm_codegen_addins(co->cg, rvm_asm(RVM_ADD, R_TOP, R_TOP, R0, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_BX, LR, XX, XX, 0));
 //     rvm_codegen_redefinelabel(co->cg, exp.endidx);
@@ -258,7 +259,7 @@ rint rpa_compiler_rule_end(rpa_compiler_t *co)
        rvm_codegen_index_addrelocins(co->cg, RVM_RELOC_STRING, exp.emitidx, rvm_asm(RPA_EMITEND, DA, R2, R0, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECID, DA, XX, XX, exp.start));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECUID, DA, XX, XX, exp.recuid));
-       rvm_codegen_addins(co->cg, rvm_asml(RPA_SETCACHE, XX, XX, XX, 0));
+       rvm_codegen_addins(co->cg, rvm_asml(RPA_SETCACHE, DA, R0, R1, exp.start));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_BX, LR, XX, XX, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RPA_SETRECLEN, R1, XX, XX, 0));
        rvm_codegen_addins(co->cg, rvm_asm(RVM_MOVS, R0, DA, XX, -1));
index 0feca9a..e4ed101 100644 (file)
@@ -579,7 +579,7 @@ static rint rpa_parseinfo_checkforloop(rpadbex_t *dbex, rlong parent, rlong loop
                                R_ASSERT(0);
                        info = (rpa_ruleinfo_t *) r_harray_get(dbex->rules, r_harray_lookup(dbex->rules, name, namesiz));
                        if (!info)
-                               R_ASSERT(0);
+                               continue;
                        ret |= rpa_parseinfo_checkforloop(dbex, info->startrec, loopto, inderction + 1);
                } else {
                        lret = rpa_parseinfo_checkforloop(dbex, i, loopto, inderction + 1);
@@ -588,9 +588,6 @@ static rint rpa_parseinfo_checkforloop(rpadbex_t *dbex, rlong parent, rlong loop
                                ret |= lret;
                        }
                }
-//             if ((prec->usertype & RPA_MATCH_OPTIONAL) == 0 && prec->userid != RPA_PRODUCTION_OROP && prec->userid != RPA_PRODUCTION_ALTBRANCH &&
-//                             prec->userid != RPA_PRODUCTION_MINOP && prec->userid != RPA_PRODUCTION_NOROP && prec->userid != RPA_PRODUCTION_NEGBRANCH)
-//                     break;
 
                if ((prec->usertype & RPA_MATCH_OPTIONAL) == 0 && (prec->userid == RPA_PRODUCTION_CREF || prec->userid == RPA_PRODUCTION_AREF ||
                                prec->userid == RPA_PRODUCTION_CHAR || prec->userid == RPA_PRODUCTION_CLS || prec->userid == RPA_PRODUCTION_SPECIALCHAR ||
@@ -622,7 +619,9 @@ static void rpa_dbex_buildloopinfo(rpadbex_t *dbex)
         */
        for (i = 0; i < r_array_length(dbex->records); i++) {
                rparecord_t *prec = (rparecord_t *)r_array_slot(dbex->records, i);
-               if (prec->type == RPA_RECORD_START && prec->userid == RPA_PRODUCTION_ALTBRANCH && (prec->usertype & RPA_LOOP_PATH) == 0) {
+               if (prec->type == RPA_RECORD_START &&
+                       (prec->userid == RPA_PRODUCTION_ALTBRANCH) &&
+                       (prec->usertype & RPA_LOOP_PATH) == 0) {
                        p = rpa_recordtree_parent(dbex->records, i, RPA_RECORD_START);
                        if (p >= 0) {
                                prec = (rparecord_t *)r_array_slot(dbex->records, p);
index 8bde48b..3fcfe4c 100644 (file)
@@ -21,6 +21,7 @@ extern "C" {
 typedef struct rparecord_s {
        rlist_t head;
        rlink_t lnk;
+       rword loo;
        const char *rule;
        ruint32 ruleid;
        ruint32 top;
index d443d66..d45ea2c 100644 (file)
@@ -13,6 +13,7 @@ rpastat_t *rpa_stat_create(rpadbex_t *dbex, rulong stacksize)
        if (stacksize == 0)
                stacksize = RPA_DEFAULT_STACKSIZE;
        stat->cpu = rpavm_cpu_create(stacksize);
+       stat->cache = rpa_cache_create();
        if (!stat->cpu) {
                r_free(stat);
                return NULL;
@@ -32,6 +33,7 @@ void rpa_stat_destroy(rpastat_t *stat)
                        r_free(stat->instackbuffer);
                r_object_destroy((robject_t*)stat->records);
                rpavm_cpu_destroy(stat->cpu);
+               rpa_cache_destroy(stat->cache);
                r_free(stat);
        }
 }
@@ -39,7 +41,7 @@ void rpa_stat_destroy(rpastat_t *stat)
 
 void rpa_stat_cachedisable(rpastat_t *stat, ruint disable)
 {
-       stat->cache.disabled = disable;
+       rpa_cache_disable(stat->cache, disable);
 }
 
 
@@ -68,8 +70,7 @@ rint rpa_stat_init(rpastat_t *stat, const rchar *input, const rchar *start, cons
        stat->input = input;
        stat->error = 0;
        stat->cursize = 0;
-       stat->cache.reclen = 0;
-       stat->cache.hit = 0;
+       stat->cache->hit = 0;
        if (stat->instacksize < size) {
                stat->instackbuffer = r_realloc(stat->instackbuffer, (size + 2) * sizeof(rpainput_t));
                stat->instacksize = size + 1;
@@ -79,6 +80,7 @@ rint rpa_stat_init(rpastat_t *stat, const rchar *input, const rchar *start, cons
        stat->ip.input = input;
        stat->ip.serial = 0;
        rpa_stat_resetrecords(stat);
+       rpa_stat_cacheinvalidate(stat);
        RVM_CPUREG_SETU(stat->cpu, SP, 0);
        RVM_CPUREG_SETU(stat->cpu, R_LOO, 0);
        RVM_CPUREG_SETU(stat->cpu, R_WHT, 0);
@@ -89,7 +91,7 @@ rint rpa_stat_init(rpastat_t *stat, const rchar *input, const rchar *start, cons
 
 void rpa_stat_cacheinvalidate(rpastat_t *stat)
 {
-       stat->cache.reclen = 0;
+       rpa_cache_invalidate(stat->cache);
 }
 
 
index 412f3f3..1fc58ac 100644 (file)
@@ -6,6 +6,7 @@
 #include "rvmreg.h"
 #include "rpavm.h"
 #include "rpadbex.h"
+#include "rpacache.h"
 
 #define RPA_ENCODING_UTF8 0
 #define RPA_ENCODING_BYTE 1
@@ -23,12 +24,6 @@ extern "C" {
 #endif
 
 
-typedef struct rpacache_s {
-       rword disabled;
-       rword startrec;
-       rword reclen;
-       rword hit;
-} rpacache_t;
 
 typedef struct rpastat_s rpastat_t;
 struct rpastat_s {
@@ -44,7 +39,7 @@ struct rpastat_s {
        rpainput_t *instack;                    /* instack = &instackbuffer[1]; This allows R_TOP = -1, without any additional checks */
        rulong instacksize;
        rulong cursize;
-       rpacache_t cache;
+       rpacache_t *cache;
        rpainmap_t ip;
        rvmcpu_t *cpu;
 };
index d7332da..a371347 100644 (file)
@@ -244,8 +244,6 @@ static void rpavm_swi_emitstart(rvmcpu_t *cpu, rvm_asmins_t *ins)
        rec->input = stat->instack[tp].input;
        rec->inputsiz = 0;
 
-       if (index >= stat->cache.startrec && index < stat->cache.reclen)
-               rpa_stat_cacheinvalidate(stat);
 //     r_printf("START: %s(%ld)\n", name.str, (rulong)tp);
 }
 
@@ -397,7 +395,7 @@ static void rpavm_swi_loopdetect(rvmcpu_t *cpu, rvm_asmins_t *ins)
                        break;
                } else if (rec->ruleid == ruleid && rec->top == tp) {
                        RVM_CPUREG_SETU(cpu, R0, RVM_CPUREG_GETU(cpu, R_LOO));
-                       RVM_CPUREG_SETU(cpu, R_TOP, RVM_CPUREG_GETU(cpu, R_TOP) + RVM_CPUREG_GETU(cpu, R_LOO));
+//                     RVM_CPUREG_SETU(cpu, R_TOP, RVM_CPUREG_GETU(cpu, R_TOP) + RVM_CPUREG_GETU(cpu, R_LOO));
 
                        break;
                }
@@ -407,44 +405,39 @@ static void rpavm_swi_loopdetect(rvmcpu_t *cpu, rvm_asmins_t *ins)
 
 static void rpavm_swi_setcache(rvmcpu_t *cpu, rvm_asmins_t *ins)
 {
+       rparecord_t *prec;
        rpastat_t *stat = (rpastat_t *)cpu->userdata1;
-       rparecord_t *rec;
+       rlong ruleid = RVM_CPUREG_GETL(cpu, ins->op1);
+       rlong r0 = RVM_CPUREG_GETL(cpu, ins->op2);
+       rlong rec = RVM_CPUREG_GETL(cpu, ins->op3);
+       rlong nrecords = r_array_length(stat->records) - rec;
 
        if (!RVM_STATUS_GETBIT(cpu, RVM_STATUS_N) && !RVM_STATUS_GETBIT(cpu, RVM_STATUS_Z)) {
-               stat->cache.reclen = r_array_length(stat->records);
-               stat->cache.startrec = stat->cache.reclen - 1;
-               rec = (rparecord_t *)r_array_slot(stat->records, stat->cache.reclen - 1);
+               prec = (rparecord_t *)r_array_slot(stat->records, rec);
+               R_ASSERT(nrecords);
+               rpa_cache_set(stat->cache, prec->top, ruleid, r0, prec, nrecords);
        }
 }
 
 
 static void rpavm_swi_checkcache(rvmcpu_t *cpu, rvm_asmins_t *ins)
 {
+       rlong i;
        rpastat_t *stat = (rpastat_t *)cpu->userdata1;
-       rparecord_t *recstart, *recend;
-       rword curlen = r_array_length(stat->records);
-       rword ruleid = RVM_CPUREG_GETU(cpu, ins->op1);
-       rword tp = RVM_CPUREG_GETU(cpu, ins->op2);
-       rword r0 = 0;
-       rlong len;
-
-       len = stat->cache.reclen;
-       if (!stat->cache.disabled && len > 0 && len > curlen) {
-               recstart = (rparecord_t *)r_array_slot(stat->records, curlen);
-               recend = (rparecord_t *)r_array_slot(stat->records, len - 1);
-
-               if (recend->type == (RPA_RECORD_END | RPA_RECORD_MATCH) &&
-                       recstart->type == RPA_RECORD_START &&
-                       tp == recend->top &&
-                       recstart->ruleid == ruleid &&
-                       recend->ruleid == ruleid) {
-                               r0 = recend->size;
-                               RVM_CPUREG_SETU(cpu, R_TOP, RVM_CPUREG_GETU(cpu, R_TOP) + r0);
-                               r_array_setlength(stat->records, (ruint)len);
-                               stat->cache.hit += 1;
-//                             r_printf("hit the chache... len = %d, curlen = %d\n", len, curlen);
+       rpacachedentry_t *entry;
+       rlong ruleid = RVM_CPUREG_GETL(cpu, ins->op1);
+       rlong top = RVM_CPUREG_GETL(cpu, ins->op2);
+       rlong r0 = 0;
+       entry = rpa_cache_lookup(stat->cache, top, ruleid);
+       if (entry) {
+               for (i = 0; i < r_array_length(entry->records); i++) {
+                       r_array_add(stat->records, r_array_slot(entry->records, i));
                }
+               r0 = entry->ret;
+               top += r0;
+               RVM_CPUREG_SETU(cpu, R_TOP, top);
        }
+
        RVM_STATUS_CLRALL(cpu);
        RVM_CPUREG_SETU(cpu, R0, r0);
        RVM_STATUS_UPDATE(cpu, RVM_STATUS_Z, !r0);
index 41c3ae5..875c1c0 100644 (file)
@@ -1977,6 +1977,7 @@ rint rvm_cpu_exec(rvmcpu_t *cpu, rvm_asmins_t *prog, rword off)
 
 rint rvm_cpu_exec_debug(rvmcpu_t *cpu, rvm_asmins_t *prog, rword off)
 {
+       rlong line = 0;
        rvm_asmins_t *pi;
        rvmreg_t *regda = RVM_CPUREG_PTR(cpu, DA);
        rvmreg_t *regpc = RVM_CPUREG_PTR(cpu, PC);
@@ -1990,6 +1991,7 @@ rint rvm_cpu_exec_debug(rvmcpu_t *cpu, rvm_asmins_t *prog, rword off)
                        *regda = pi->data;
                }
                ops[pi->opcode](cpu, pi);
+               r_printf("%7ld :", ++line);
                rvm_cpu_dumpregs(pi, cpu);
                RVM_REG_INCIP(regpc, 1);
        } while (!cpu->abort);
index 6352724..fa3b332 100644 (file)
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
        }
 
        r_printf("(%s) Matched size: %s\n", argv[0], RVM_CPUREG_GETU(stat->cpu, R0) == 8 ? "PASSED" : "FAILED");
-       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 6 ? "PASSED" : "FAILED", stat->cache.hit);
+       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 6 ? "PASSED" : "FAILED", stat->cache->hit);
 
 end:
        rpa_stat_destroy(stat);
index 18b57d6..7819f63 100644 (file)
@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
        }
 
        r_printf("(%s) Matched size: %s\n", argv[0], RVM_CPUREG_GETU(stat->cpu, R0) == 39 ? "PASSED" : "FAILED");
-       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 24 ? "PASSED" : "FAILED", stat->cache.hit);
+       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 24 ? "PASSED" : "FAILED", stat->cache->hit);
 
 end:
        rpa_stat_destroy(stat);
index 5afa470..36e4f64 100644 (file)
@@ -342,7 +342,7 @@ int main(int argc, char *argv[])
        }
 
        r_printf("(%s) Matched size: %s\n", argv[0], RVM_CPUREG_GETU(stat->cpu, R0) == 151 ? "PASSED" : "FAILED");
-       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 500 ? "PASSED" : "FAILED", stat->cache.hit);
+       r_printf("(%s) Records size: %s(cache hits: %d)\n", argv[0], r_array_length(stat->records) == 500 ? "PASSED" : "FAILED", stat->cache->hit);
 
 end:
        rpa_stat_destroy(stat);