Fixing bug 256389: working CompilerEnvirons.isXmlAvailable() etc.

This commit is contained in:
igor%mir2.org 2004-08-21 11:10:24 +00:00
Родитель 6a2e5fcf57
Коммит 0e329a3dc0
3 изменённых файлов: 61 добавлений и 32 удалений

Просмотреть файл

@ -44,14 +44,15 @@ public class CompilerEnvirons
{
public CompilerEnvirons()
{
this.errorReporter = DefaultErrorReporter.instance;
this.languageVersion = Context.VERSION_DEFAULT;
this.generateDebugInfo = true;
this.useDynamicScope = false;
this.reservedKeywordAsIdentifier = false;
this.allowMemberExprAsFunctionName = false;
this.optimizationLevel = 0;
this.generatingSource = true;
errorReporter = DefaultErrorReporter.instance;
languageVersion = Context.VERSION_DEFAULT;
generateDebugInfo = true;
useDynamicScope = false;
reservedKeywordAsIdentifier = false;
allowMemberExprAsFunctionName = false;
xmlAvailable = true;
optimizationLevel = 0;
generatingSource = true;
}
public void initFromContext(Context cx)
@ -61,15 +62,17 @@ public class CompilerEnvirons
useDynamicScope = cx.hasCompileFunctionsWithDynamicScope();
generateDebugInfo = (!cx.isGeneratingDebugChanged()
|| cx.isGeneratingDebug());
this.reservedKeywordAsIdentifier
reservedKeywordAsIdentifier
= cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
this.allowMemberExprAsFunctionName
allowMemberExprAsFunctionName
= cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
xmlAvailable
= cx.hasFeature(Context.FEATURE_E4X);
this.optimizationLevel = cx.getOptimizationLevel();
optimizationLevel = cx.getOptimizationLevel();
this.generatingSource = cx.isGeneratingSource();
this.activationNames = cx.activationNames;
generatingSource = cx.isGeneratingSource();
activationNames = cx.activationNames;
}
public final ErrorReporter getErrorReporter()
@ -114,6 +117,36 @@ public class CompilerEnvirons
this.useDynamicScope = flag;
}
public final boolean isReservedKeywordAsIdentifier()
{
return reservedKeywordAsIdentifier;
}
public void setReservedKeywordAsIdentifier(boolean flag)
{
reservedKeywordAsIdentifier = flag;
}
public final boolean isAllowMemberExprAsFunctionName()
{
return allowMemberExprAsFunctionName;
}
public void setAllowMemberExprAsFunctionName(boolean flag)
{
allowMemberExprAsFunctionName = flag;
}
public final boolean isXmlAvailable()
{
return xmlAvailable;
}
public void setXmlAvailable(boolean flag)
{
xmlAvailable = flag;
}
public final int getOptimizationLevel()
{
return optimizationLevel;
@ -125,7 +158,7 @@ public class CompilerEnvirons
this.optimizationLevel = level;
}
public boolean isGeneratingSource()
public final boolean isGeneratingSource()
{
return generatingSource;
}
@ -144,20 +177,16 @@ public class CompilerEnvirons
this.generatingSource = generatingSource;
}
final boolean isXmlAvailable()
{
return true;
}
private ErrorReporter errorReporter;
int languageVersion = Context.VERSION_DEFAULT;
boolean generateDebugInfo = true;
boolean useDynamicScope;
boolean reservedKeywordAsIdentifier;
boolean allowMemberExprAsFunctionName;
private int optimizationLevel = 0;
private boolean generatingSource = true;
private int languageVersion;
private boolean generateDebugInfo;
private boolean useDynamicScope;
private boolean reservedKeywordAsIdentifier;
private boolean allowMemberExprAsFunctionName;
private boolean xmlAvailable;
private int optimizationLevel;
private boolean generatingSource;
Hashtable activationNames;
}

Просмотреть файл

@ -317,7 +317,7 @@ public class Parser
name = ts.getString();
decompiler.addName(name);
if (!ts.matchToken(Token.LP)) {
if (compilerEnv.allowMemberExprAsFunctionName) {
if (compilerEnv.isAllowMemberExprAsFunctionName()) {
// Extension to ECMA: if 'function <name>' does not follow
// by '(', assume <name> starts memberExpr
Node memberExprHead = nf.createName(name);
@ -331,7 +331,7 @@ public class Parser
name = "";
} else {
name = "";
if (compilerEnv.allowMemberExprAsFunctionName) {
if (compilerEnv.isAllowMemberExprAsFunctionName()) {
// Note that memberExpr can not start with '(' like
// in function (1+2).toString(), because 'function (' already
// processed as anonymous function
@ -480,7 +480,7 @@ public class Parser
return;
case Token.FUNCTION:
if (compilerEnv.languageVersion < Context.VERSION_1_2) {
if (compilerEnv.getLanguageVersion() < Context.VERSION_1_2) {
/*
* Checking against version < 1.2 and version >= 1.0
* in the above line breaks old javascript, so we keep it
@ -495,7 +495,7 @@ public class Parser
private void checkWellTerminatedFunction()
throws IOException, ParserException
{
if (compilerEnv.languageVersion < Context.VERSION_1_2) {
if (compilerEnv.getLanguageVersion() < Context.VERSION_1_2) {
// See comments in checkWellTerminated
return;
}
@ -1207,7 +1207,7 @@ public class Parser
ts.getToken();
int decompilerToken = tt;
int parseToken = tt;
if (compilerEnv.languageVersion == Context.VERSION_1_2) {
if (compilerEnv.getLanguageVersion() == Context.VERSION_1_2) {
// JavaScript 1.2 uses shallow equality for == and != .
// In addition, convert === and !== for decompiler into
// == and != since the decompiler is supposed to show

Просмотреть файл

@ -466,7 +466,7 @@ public class TokenStream
if (result != Token.RESERVED) {
return result;
} else if (!parser.compilerEnv.
reservedKeywordAsIdentifier)
isReservedKeywordAsIdentifier())
{
return result;
} else {