AS3: Editing return type of methods

This commit is contained in:
Jindra Pet��k
2011-07-30 10:58:24 +02:00
parent 97a4a2c961
commit 459f8ecb56
3 changed files with 59 additions and 9 deletions
@@ -32,7 +32,33 @@ import java.util.List;
*/
public class MethodInfoParser {
public static void parse(String text, MethodInfo update,ABC abc) throws ParseException {
public static boolean parseReturnType(String text, MethodInfo update) throws ParseException {
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
ParsedSymbol symb;
int type=-1;
try {
symb = lexer.yylex();
if(symb.type==ParsedSymbol.TYPE_STAR)
{
type=0;
}else if(symb.type==ParsedSymbol.TYPE_MULTINAME){
type=(int)(long)(Long)symb.value;
}else{
throw new ParseException("Multiname or * expected", lexer.yyline());
}
symb = lexer.yylex();
if(symb.type!=ParsedSymbol.TYPE_EOF)
{
throw new ParseException("Only one return type allowed", lexer.yyline());
}
update.ret_type=type;
return true;
} catch (IOException ex) {
}
return false;
}
public static boolean parseParams(String text, MethodInfo update,ABC abc) throws ParseException {
MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes()));
List<String> paramNames=new ArrayList<String>();
List<Long> paramTypes=new ArrayList<Long>();
@@ -173,6 +199,7 @@ public class MethodInfoParser {
symb = lexer.yylex();
}
} catch (IOException iex) {
return false;
}
if(needsRest&&(!optionalValues.isEmpty())){
@@ -213,7 +240,7 @@ public class MethodInfoParser {
update.paramNames[p]=abc.constants.forceGetStringId(paramNames.get(p));
}
}
return true;
}
}