提交 447c3183 编写于 作者: K ksrini

7198582: (java) Minor refactor of JavacParser

Reviewed-by: jjg, ksrini
Contributed-by: jan.lahoda@oracle.com
上级 97d9fb71
......@@ -251,7 +251,7 @@ public class Resolve {
/** An environment is "static" if its static level is greater than
* the one of its outer environment
*/
static boolean isStatic(Env<AttrContext> env) {
protected static boolean isStatic(Env<AttrContext> env) {
return env.info.staticLevel > env.outer.info.staticLevel;
}
......
......@@ -2165,27 +2165,10 @@ public class JavacParser implements Parser {
while (true) {
int pos = token.pos;
switch (token.kind) {
case CASE: {
nextToken();
JCExpression pat = parseExpression();
accept(COLON);
List<JCStatement> stats = blockStatements();
JCCase c = F.at(pos).Case(pat, stats);
if (stats.isEmpty())
storeEnd(c, S.prevToken().endPos);
cases.append(c);
break;
}
case DEFAULT: {
nextToken();
accept(COLON);
List<JCStatement> stats = blockStatements();
JCCase c = F.at(pos).Case(null, stats);
if (stats.isEmpty())
storeEnd(c, S.prevToken().endPos);
cases.append(c);
case CASE:
case DEFAULT:
cases.append(switchBlockStatementGroup());
break;
}
case RBRACE: case EOF:
return cases.toList();
default:
......@@ -2196,6 +2179,32 @@ public class JavacParser implements Parser {
}
}
protected JCCase switchBlockStatementGroup() {
int pos = token.pos;
List<JCStatement> stats;
JCCase c;
switch (token.kind) {
case CASE:
nextToken();
JCExpression pat = parseExpression();
accept(COLON);
stats = blockStatements();
c = F.at(pos).Case(pat, stats);
if (stats.isEmpty())
storeEnd(c, S.prevToken().endPos);
return c;
case DEFAULT:
nextToken();
accept(COLON);
stats = blockStatements();
c = F.at(pos).Case(null, stats);
if (stats.isEmpty())
storeEnd(c, S.prevToken().endPos);
return c;
}
throw new AssertionError("should not reach here");
}
/** MoreStatementExpressions = { COMMA StatementExpression }
*/
<T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos,
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -45,8 +45,8 @@ import com.sun.tools.classfile.Method;
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
class CodeWriter extends BasicWriter {
static CodeWriter instance(Context context) {
public class CodeWriter extends BasicWriter {
public static CodeWriter instance(Context context) {
CodeWriter instance = context.get(CodeWriter.class);
if (instance == null)
instance = new CodeWriter(context);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册