Refactor the rules related to the .parameter directive, so that it doesn't use syntactic predicates

git-svn-id: https://smali.googlecode.com/svn/trunk@716 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2010-04-17 07:02:56 +00:00
parent 368a8faed9
commit 4fb7679be9
2 changed files with 14 additions and 13 deletions

View File

@ -285,7 +285,7 @@ access_list
field field
@init {List<CommonTree> annotations = new ArrayList<CommonTree>();} @init {List<CommonTree> annotations = new ArrayList<CommonTree>();}
: FIELD_DIRECTIVE access_list simple_name COLON nonvoid_type_descriptor (EQUAL literal)? : FIELD_DIRECTIVE access_list simple_name COLON nonvoid_type_descriptor (EQUAL literal)?
( ({input.LA(1) == ANNOTATION_DIRECTIVE}? annotation { annotations.add($annotation.tree); } )* ( ({input.LA(1) == ANNOTATION_DIRECTIVE}? annotation {annotations.add($annotation.tree);})*
( END_FIELD_DIRECTIVE ( END_FIELD_DIRECTIVE
-> ^(I_FIELD[$start, "I_FIELD"] simple_name access_list ^(I_FIELD_TYPE nonvoid_type_descriptor) ^(I_FIELD_INITIAL_VALUE literal)? ^(I_ANNOTATIONS annotation*)) -> ^(I_FIELD[$start, "I_FIELD"] simple_name access_list ^(I_FIELD_TYPE nonvoid_type_descriptor) ^(I_FIELD_INITIAL_VALUE literal)? ^(I_ANNOTATIONS annotation*))
| /*epsilon*/ {$smali_file::classAnnotations.addAll(annotations);} | /*epsilon*/ {$smali_file::classAnnotations.addAll(annotations);}
@ -306,12 +306,14 @@ statements_and_directives
boolean hasRegistersDirective; boolean hasRegistersDirective;
List<CommonTree> packedSwitchDeclarations; List<CommonTree> packedSwitchDeclarations;
List<CommonTree> sparseSwitchDeclarations; List<CommonTree> sparseSwitchDeclarations;
List<CommonTree> methodAnnotations;
} }
: { : {
$method::currentAddress = 0; $method::currentAddress = 0;
$statements_and_directives::hasRegistersDirective = false; $statements_and_directives::hasRegistersDirective = false;
$statements_and_directives::packedSwitchDeclarations = new ArrayList<CommonTree>(); $statements_and_directives::packedSwitchDeclarations = new ArrayList<CommonTree>();
$statements_and_directives::sparseSwitchDeclarations = new ArrayList<CommonTree>(); $statements_and_directives::sparseSwitchDeclarations = new ArrayList<CommonTree>();
$statements_and_directives::methodAnnotations = new ArrayList<CommonTree>();
} }
( instruction {$method::currentAddress += $instruction.size/2;} ( instruction {$method::currentAddress += $instruction.size/2;}
| {!$statements_and_directives::hasRegistersDirective}?=> registers_directive {$statements_and_directives::hasRegistersDirective = true;} | {!$statements_and_directives::hasRegistersDirective}?=> registers_directive {$statements_and_directives::hasRegistersDirective = true;}
@ -320,7 +322,7 @@ statements_and_directives
| catchall_directive | catchall_directive
| parameter_directive | parameter_directive
| ordered_debug_directive | ordered_debug_directive
| annotation | annotation {$statements_and_directives::methodAnnotations.add($annotation.tree);}
)* )*
-> ^(I_REGISTERS registers_directive?) -> ^(I_REGISTERS registers_directive?)
^(I_LABELS label*) ^(I_LABELS label*)
@ -330,7 +332,7 @@ statements_and_directives
^(I_CATCHES catch_directive* catchall_directive*) ^(I_CATCHES catch_directive* catchall_directive*)
^(I_PARAMETERS parameter_directive*) ^(I_PARAMETERS parameter_directive*)
^(I_ORDERED_DEBUG_DIRECTIVES ordered_debug_directive*) ^(I_ORDERED_DEBUG_DIRECTIVES ordered_debug_directive*)
^(I_ANNOTATIONS annotation*); {buildTree(I_ANNOTATIONS, "I_ANNOTATIONS", $statements_and_directives::methodAnnotations)};
registers_directive registers_directive
: (REGISTERS_DIRECTIVE | LOCALS_DIRECTIVE) integral_literal : (REGISTERS_DIRECTIVE | LOCALS_DIRECTIVE) integral_literal
@ -519,16 +521,15 @@ catchall_directive
-> ^(I_CATCHALL[$start, "I_CATCHALL"] I_ADDRESS[$start, Integer.toString($method::currentAddress)] $from $to $using); -> ^(I_CATCHALL[$start, "I_CATCHALL"] I_ADDRESS[$start, Integer.toString($method::currentAddress)] $from $to $using);
parameter_directive parameter_directive
@init {List<CommonTree> annotations = new ArrayList<CommonTree>();}
: PARAMETER_DIRECTIVE : PARAMETER_DIRECTIVE
( STRING_LITERAL STRING_LITERAL?
( (annotation+ END_PARAMETER_DIRECTIVE)=> annotation+ END_PARAMETER_DIRECTIVE ({input.LA(1) == ANNOTATION_DIRECTIVE}? annotation {annotations.add($annotation.tree);})*
| END_PARAMETER_DIRECTIVE?
) ( END_PARAMETER_DIRECTIVE
-> ^(I_PARAMETER STRING_LITERAL ^(I_ANNOTATIONS annotation*)) -> ^(I_PARAMETER STRING_LITERAL? ^(I_ANNOTATIONS annotation*))
| ( (annotation+ END_PARAMETER_DIRECTIVE)=> annotation+ END_PARAMETER_DIRECTIVE | /*epsilon*/ {$statements_and_directives::methodAnnotations.addAll(annotations);}
| END_PARAMETER_DIRECTIVE? -> ^(I_PARAMETER STRING_LITERAL? ^(I_ANNOTATIONS))
)
-> ^(I_PARAMETER I_PARAMETER_NOT_SPECIFIED ^(I_ANNOTATIONS annotation*))
); );
ordered_debug_directive ordered_debug_directive

View File

@ -724,7 +724,7 @@ parameters returns[AnnotationSetRefList parameterAnnotations]
parameter returns[AnnotationSetItem parameterAnnotationSet] parameter returns[AnnotationSetItem parameterAnnotationSet]
: ^(I_PARAMETER ( string_literal {$method::debugInfo.addParameterName($string_literal.value);} : ^(I_PARAMETER ( string_literal {$method::debugInfo.addParameterName($string_literal.value);}
| I_PARAMETER_NOT_SPECIFIED {$method::debugInfo.addParameterName(null);} | {$method::debugInfo.addParameterName(null);}
) )
annotations {$parameterAnnotationSet = $annotations.annotationSetItem;} annotations {$parameterAnnotationSet = $annotations.annotationSetItem;}
); );