mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 05:44:10 +00:00
Cosmetics: removal of tabs left by the previous commit
This commit is contained in:
parent
3cab5b3e26
commit
75d4dec8ea
@ -40,31 +40,31 @@ package org.mozilla.javascript;
|
||||
|
||||
public class CompilerEnvirons
|
||||
{
|
||||
public void initFromContext(Context cx, ErrorReporter syntaxErrorReporter)
|
||||
{
|
||||
setSyntaxErrorReporter(syntaxErrorReporter);
|
||||
this.languageVersion = cx.getLanguageVersion();
|
||||
public void initFromContext(Context cx, ErrorReporter syntaxErrorReporter)
|
||||
{
|
||||
setSyntaxErrorReporter(syntaxErrorReporter);
|
||||
this.languageVersion = cx.getLanguageVersion();
|
||||
useDynamicScope = cx.hasCompileFunctionsWithDynamicScope();
|
||||
generateDebugInfo = (!cx.isGeneratingDebugChanged()
|
||||
|| cx.isGeneratingDebug());
|
||||
this.reservedKeywordAsIdentifier
|
||||
= cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
|
||||
this.allowMemberExprAsFunctionName
|
||||
= cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
|
||||
}
|
||||
this.reservedKeywordAsIdentifier
|
||||
= cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
|
||||
this.allowMemberExprAsFunctionName
|
||||
= cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
|
||||
}
|
||||
|
||||
public final int getSyntaxErrorCount()
|
||||
{
|
||||
return syntaxErrorCount;
|
||||
}
|
||||
|
||||
public void setSyntaxErrorReporter(ErrorReporter syntaxErrorReporter)
|
||||
{
|
||||
if (syntaxErrorReporter == null) Kit.argBug();
|
||||
this.syntaxErrorReporter = syntaxErrorReporter;
|
||||
}
|
||||
|
||||
public final void reportSyntaxError(boolean isError,
|
||||
{
|
||||
return syntaxErrorCount;
|
||||
}
|
||||
|
||||
public void setSyntaxErrorReporter(ErrorReporter syntaxErrorReporter)
|
||||
{
|
||||
if (syntaxErrorReporter == null) Kit.argBug();
|
||||
this.syntaxErrorReporter = syntaxErrorReporter;
|
||||
}
|
||||
|
||||
public final void reportSyntaxError(boolean isError,
|
||||
String messageProperty, Object[] args,
|
||||
String sourceName, int lineno,
|
||||
String line, int lineOffset)
|
||||
@ -86,43 +86,43 @@ public class CompilerEnvirons
|
||||
lineno, line, lineOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isFromEval()
|
||||
{
|
||||
return fromEval;
|
||||
}
|
||||
|
||||
public void setFromEval(boolean fromEval)
|
||||
{
|
||||
this.fromEval = fromEval;
|
||||
}
|
||||
|
||||
public final int getLanguageVersion()
|
||||
{
|
||||
return languageVersion;
|
||||
}
|
||||
public final boolean isFromEval()
|
||||
{
|
||||
return fromEval;
|
||||
}
|
||||
|
||||
public final boolean isGenerateDebugInfo()
|
||||
{
|
||||
return generateDebugInfo;
|
||||
}
|
||||
public void setFromEval(boolean fromEval)
|
||||
{
|
||||
this.fromEval = fromEval;
|
||||
}
|
||||
|
||||
public final boolean isUseDynamicScope()
|
||||
{
|
||||
return useDynamicScope;
|
||||
}
|
||||
public final int getLanguageVersion()
|
||||
{
|
||||
return languageVersion;
|
||||
}
|
||||
|
||||
public final boolean isGenerateDebugInfo()
|
||||
{
|
||||
return generateDebugInfo;
|
||||
}
|
||||
|
||||
public final boolean isUseDynamicScope()
|
||||
{
|
||||
return useDynamicScope;
|
||||
}
|
||||
|
||||
private ErrorReporter syntaxErrorReporter;
|
||||
private int syntaxErrorCount;
|
||||
|
||||
private boolean fromEval;
|
||||
|
||||
int languageVersion = Context.VERSION_DEFAULT;
|
||||
boolean generateDebugInfo;
|
||||
boolean useDynamicScope;
|
||||
boolean reservedKeywordAsIdentifier;
|
||||
|
||||
int languageVersion = Context.VERSION_DEFAULT;
|
||||
boolean generateDebugInfo;
|
||||
boolean useDynamicScope;
|
||||
boolean reservedKeywordAsIdentifier;
|
||||
boolean allowMemberExprAsFunctionName;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -977,12 +977,12 @@ public class Context
|
||||
public boolean stringIsCompilableUnit(String source)
|
||||
{
|
||||
boolean errorseen = false;
|
||||
CompilerEnvirons compilerEnv = new CompilerEnvirons();
|
||||
CompilerEnvirons compilerEnv = new CompilerEnvirons();
|
||||
compilerEnv.initFromContext(this, new DefaultErrorReporter());
|
||||
// no source name or source text manager, because we're just
|
||||
// going to throw away the result.
|
||||
TokenStream ts = new TokenStream(compilerEnv,
|
||||
null, source, null, 1);
|
||||
TokenStream ts = new TokenStream(compilerEnv,
|
||||
null, source, null, 1);
|
||||
|
||||
Parser p = new Parser(compilerEnv);
|
||||
Decompiler decompiler = new Decompiler();
|
||||
@ -2014,10 +2014,10 @@ public class Context
|
||||
// scope should be given if and only if compiling function
|
||||
if (!(scope == null ^ returnFunction)) Kit.codeBug();
|
||||
|
||||
CompilerEnvirons compilerEnv = new CompilerEnvirons();
|
||||
CompilerEnvirons compilerEnv = new CompilerEnvirons();
|
||||
ErrorReporter reporter = getErrorReporter();
|
||||
compilerEnv.initFromContext(this, reporter);
|
||||
compilerEnv.setFromEval(fromEval);
|
||||
compilerEnv.setFromEval(fromEval);
|
||||
|
||||
if (debugger != null) {
|
||||
if (sourceReader != null) {
|
||||
@ -2033,15 +2033,15 @@ public class Context
|
||||
Decompiler decompiler = new Decompiler();
|
||||
ScriptOrFnNode tree = p.parse(ts, decompiler);
|
||||
int syntaxErrorCount = compilerEnv.getSyntaxErrorCount();
|
||||
if (syntaxErrorCount == 0) {
|
||||
Interpreter compiler = createCompiler();
|
||||
compiler.compilerEnv = compilerEnv;
|
||||
if (securityController != null) {
|
||||
securityDomain = securityController.
|
||||
getDynamicSecurityDomain(securityDomain);
|
||||
} else {
|
||||
securityDomain = null;
|
||||
}
|
||||
if (syntaxErrorCount == 0) {
|
||||
Interpreter compiler = createCompiler();
|
||||
compiler.compilerEnv = compilerEnv;
|
||||
if (securityController != null) {
|
||||
securityDomain = securityController.
|
||||
getDynamicSecurityDomain(securityDomain);
|
||||
} else {
|
||||
securityDomain = null;
|
||||
}
|
||||
|
||||
String encodedSource = null;
|
||||
if (isGeneratingSource()) {
|
||||
@ -2065,7 +2065,7 @@ public class Context
|
||||
Object result = compiler.compile(this, scope, tree,
|
||||
securityController, securityDomain,
|
||||
encodedSource);
|
||||
syntaxErrorCount = compilerEnv.getSyntaxErrorCount();
|
||||
syntaxErrorCount = compilerEnv.getSyntaxErrorCount();
|
||||
if (syntaxErrorCount == 0) {
|
||||
if (debugger != null) {
|
||||
if (sourceString == null) Kit.codeBug();
|
||||
|
@ -43,15 +43,15 @@ package org.mozilla.javascript;
|
||||
* @author Mike McCabe
|
||||
* @author Norris Boyd
|
||||
*/
|
||||
class IRFactory
|
||||
class IRFactory
|
||||
{
|
||||
IRFactory(TokenStream ts)
|
||||
{
|
||||
IRFactory(TokenStream ts)
|
||||
{
|
||||
this.ts = ts;
|
||||
}
|
||||
|
||||
ScriptOrFnNode createScript()
|
||||
{
|
||||
ScriptOrFnNode createScript()
|
||||
{
|
||||
return new ScriptOrFnNode(Token.SCRIPT);
|
||||
}
|
||||
|
||||
@ -67,13 +67,13 @@ class IRFactory
|
||||
/**
|
||||
* Leaf
|
||||
*/
|
||||
Object createLeaf(int nodeType)
|
||||
{
|
||||
Object createLeaf(int nodeType)
|
||||
{
|
||||
return new Node(nodeType);
|
||||
}
|
||||
|
||||
Object createLeaf(int nodeType, int nodeOp)
|
||||
{
|
||||
Object createLeaf(int nodeType, int nodeOp)
|
||||
{
|
||||
return new Node(nodeType, nodeOp);
|
||||
}
|
||||
|
||||
@ -81,47 +81,47 @@ class IRFactory
|
||||
* Statement leaf nodes.
|
||||
*/
|
||||
|
||||
Object createSwitch(int lineno)
|
||||
{
|
||||
Object createSwitch(int lineno)
|
||||
{
|
||||
return new Node.Jump(Token.SWITCH, lineno);
|
||||
}
|
||||
|
||||
Object createVariables(int lineno)
|
||||
{
|
||||
Object createVariables(int lineno)
|
||||
{
|
||||
return new Node(Token.VAR, lineno);
|
||||
}
|
||||
|
||||
Object createExprStatement(Object expr, int lineno)
|
||||
{
|
||||
Object createExprStatement(Object expr, int lineno)
|
||||
{
|
||||
return new Node(Token.EXPRSTMT, (Node) expr, lineno);
|
||||
}
|
||||
|
||||
Object createExprStatementNoReturn(Object expr, int lineno)
|
||||
{
|
||||
Object createExprStatementNoReturn(Object expr, int lineno)
|
||||
{
|
||||
return new Node(Token.POP, (Node) expr, lineno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
Object createName(String name)
|
||||
{
|
||||
Object createName(String name)
|
||||
{
|
||||
return Node.newString(Token.NAME, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* String (for literals)
|
||||
*/
|
||||
Object createString(String string)
|
||||
{
|
||||
Object createString(String string)
|
||||
{
|
||||
return Node.newString(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number (for literals)
|
||||
*/
|
||||
Object createNumber(double number)
|
||||
{
|
||||
Object createNumber(double number)
|
||||
{
|
||||
return Node.newNumber(number);
|
||||
}
|
||||
|
||||
@ -146,16 +146,16 @@ class IRFactory
|
||||
/**
|
||||
* Throw
|
||||
*/
|
||||
Object createThrow(Object expr, int lineno)
|
||||
{
|
||||
Object createThrow(Object expr, int lineno)
|
||||
{
|
||||
return new Node(Token.THROW, (Node)expr, lineno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return
|
||||
*/
|
||||
Object createReturn(Object expr, int lineno)
|
||||
{
|
||||
Object createReturn(Object expr, int lineno)
|
||||
{
|
||||
return expr == null
|
||||
? new Node(Token.RETURN, lineno)
|
||||
: new Node(Token.RETURN, (Node)expr, lineno);
|
||||
@ -270,16 +270,16 @@ class IRFactory
|
||||
* breaks the Factory abstraction, but it removes a requirement
|
||||
* from implementors of Node.
|
||||
*/
|
||||
void addChildToBack(Object parent, Object child)
|
||||
{
|
||||
void addChildToBack(Object parent, Object child)
|
||||
{
|
||||
((Node)parent).addChildToBack((Node)child);
|
||||
}
|
||||
|
||||
/**
|
||||
* While
|
||||
*/
|
||||
Object createWhile(Object cond, Object body, int lineno)
|
||||
{
|
||||
Object createWhile(Object cond, Object body, int lineno)
|
||||
{
|
||||
return createLoop(LOOP_WHILE, (Node)body, (Node)cond, null, null,
|
||||
lineno);
|
||||
}
|
||||
@ -287,8 +287,8 @@ class IRFactory
|
||||
/**
|
||||
* DoWhile
|
||||
*/
|
||||
Object createDoWhile(Object body, Object cond, int lineno)
|
||||
{
|
||||
Object createDoWhile(Object body, Object cond, int lineno)
|
||||
{
|
||||
return createLoop(LOOP_DO_WHILE, (Node)body, (Node)cond, null, null,
|
||||
lineno);
|
||||
}
|
||||
@ -296,8 +296,8 @@ class IRFactory
|
||||
/**
|
||||
* For
|
||||
*/
|
||||
Object createFor(Object init, Object test, Object incr, Object body,
|
||||
int lineno)
|
||||
Object createFor(Object init, Object test, Object incr, Object body,
|
||||
int lineno)
|
||||
{
|
||||
return createLoop(LOOP_FOR, (Node)body, (Node)test,
|
||||
(Node)init, (Node)incr, lineno);
|
||||
@ -361,8 +361,8 @@ class IRFactory
|
||||
* For .. In
|
||||
*
|
||||
*/
|
||||
Object createForIn(Object lhs, Object obj, Object body, int lineno)
|
||||
{
|
||||
Object createForIn(Object lhs, Object obj, Object body, int lineno)
|
||||
{
|
||||
String name;
|
||||
Node lhsNode = (Node) lhs;
|
||||
Node objNode = (Node) obj;
|
||||
@ -599,8 +599,8 @@ class IRFactory
|
||||
/**
|
||||
* With
|
||||
*/
|
||||
Object createWith(Object obj, Object body, int lineno)
|
||||
{
|
||||
Object createWith(Object obj, Object body, int lineno)
|
||||
{
|
||||
Node result = new Node(Token.BLOCK, lineno);
|
||||
result.addChildToBack(new Node(Token.ENTERWITH, (Node)obj));
|
||||
Node bodyNode = new Node(Token.WITH, (Node) body, lineno);
|
||||
@ -615,8 +615,8 @@ class IRFactory
|
||||
* plus a series of array element entries, so later compiler
|
||||
* stages don't need to know about array literals.
|
||||
*/
|
||||
Object createArrayLiteral(Object obj)
|
||||
{
|
||||
Object createArrayLiteral(Object obj)
|
||||
{
|
||||
Node array;
|
||||
array = new Node(Token.NEW, Node.newString(Token.NAME, "Array"));
|
||||
Node list = new Node(Token.INIT_LIST, array);
|
||||
@ -672,8 +672,8 @@ class IRFactory
|
||||
* creation plus object property entries, so later compiler
|
||||
* stages don't need to know about object literals.
|
||||
*/
|
||||
Object createObjectLiteral(Object obj)
|
||||
{
|
||||
Object createObjectLiteral(Object obj)
|
||||
{
|
||||
Node result = new Node(Token.NEW,
|
||||
Node.newString(Token.NAME, "Object"));
|
||||
Node list = new Node(Token.INIT_LIST, result);
|
||||
@ -696,8 +696,8 @@ class IRFactory
|
||||
/**
|
||||
* Regular expressions
|
||||
*/
|
||||
Object createRegExp(int regexpIndex)
|
||||
{
|
||||
Object createRegExp(int regexpIndex)
|
||||
{
|
||||
Node n = new Node(Token.REGEXP);
|
||||
n.putIntProp(Node.REGEXP_PROP, regexpIndex);
|
||||
return n;
|
||||
@ -758,8 +758,8 @@ class IRFactory
|
||||
/**
|
||||
* Unary
|
||||
*/
|
||||
Object createUnary(int nodeType, Object child)
|
||||
{
|
||||
Object createUnary(int nodeType, Object child)
|
||||
{
|
||||
Node childNode = (Node) child;
|
||||
int childType = childNode.getType();
|
||||
switch (nodeType) {
|
||||
@ -1133,8 +1133,8 @@ class IRFactory
|
||||
}
|
||||
}
|
||||
|
||||
Node createUseLocal(Node localBlock)
|
||||
{
|
||||
Node createUseLocal(Node localBlock)
|
||||
{
|
||||
if (Token.LOCAL_BLOCK != localBlock.getType()) Kit.codeBug();
|
||||
Node result = new Node(Token.LOCAL_LOAD);
|
||||
result.putProp(Node.LOCAL_BLOCK_PROP, localBlock);
|
||||
@ -1163,8 +1163,8 @@ class IRFactory
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static boolean hasSideEffects(Node exprTree)
|
||||
{
|
||||
private static boolean hasSideEffects(Node exprTree)
|
||||
{
|
||||
switch (exprTree.getType()) {
|
||||
case Token.INC:
|
||||
case Token.DEC:
|
||||
|
@ -122,7 +122,7 @@ public class Interpreter
|
||||
{
|
||||
scriptOrFn = tree;
|
||||
itsData = new InterpreterData(securityDomain,
|
||||
compilerEnv.getLanguageVersion());
|
||||
compilerEnv.getLanguageVersion());
|
||||
itsData.itsSourceFile = scriptOrFn.getSourceName();
|
||||
itsData.encodedSource = encodedSource;
|
||||
itsData.topLevel = true;
|
||||
@ -260,7 +260,7 @@ public class Interpreter
|
||||
for (int i = 0; i != functionCount; i++) {
|
||||
FunctionNode def = scriptOrFn.getFunctionNode(i);
|
||||
Interpreter jsi = new Interpreter();
|
||||
jsi.compilerEnv = compilerEnv;
|
||||
jsi.compilerEnv = compilerEnv;
|
||||
jsi.scriptOrFn = def;
|
||||
jsi.itsData = new InterpreterData(itsData.securityDomain,
|
||||
itsData.languageVersion);
|
||||
@ -3283,8 +3283,8 @@ public class Interpreter
|
||||
}
|
||||
|
||||
protected CompilerEnvirons compilerEnv;
|
||||
|
||||
private boolean itsInFunctionFlag;
|
||||
|
||||
private boolean itsInFunctionFlag;
|
||||
|
||||
private InterpreterData itsData;
|
||||
private ScriptOrFnNode scriptOrFn;
|
||||
|
@ -535,7 +535,7 @@ public class NodeTransformer
|
||||
int lineno = stmt.getLineno();
|
||||
String sourceName = tree.getSourceName();
|
||||
compiler.compilerEnv.reportSyntaxError(
|
||||
true, messageId, messageArgs, sourceName, lineno, null, 0);
|
||||
true, messageId, messageArgs, sourceName, lineno, null, 0);
|
||||
}
|
||||
|
||||
private ObjArray loops;
|
||||
|
@ -53,10 +53,10 @@ import java.io.IOException;
|
||||
|
||||
class Parser {
|
||||
|
||||
public Parser(CompilerEnvirons compilerEnv)
|
||||
{
|
||||
this.compilerEnv = compilerEnv;
|
||||
}
|
||||
public Parser(CompilerEnvirons compilerEnv)
|
||||
{
|
||||
this.compilerEnv = compilerEnv;
|
||||
}
|
||||
|
||||
private void mustMatchToken(TokenStream ts, int toMatch, String messageId)
|
||||
throws IOException, ParserException
|
||||
@ -1478,8 +1478,8 @@ class Parser {
|
||||
}
|
||||
|
||||
private CompilerEnvirons compilerEnv;
|
||||
|
||||
private IRFactory nf;
|
||||
|
||||
private IRFactory nf;
|
||||
|
||||
private boolean ok; // Did the parse encounter an error?
|
||||
|
||||
|
@ -300,7 +300,7 @@ public class Codegen extends Interpreter {
|
||||
BodyCodegen bodygen = new BodyCodegen();
|
||||
bodygen.cfw = cfw;
|
||||
bodygen.codegen = this;
|
||||
bodygen.compilerEnv = compilerEnv;
|
||||
bodygen.compilerEnv = compilerEnv;
|
||||
bodygen.scriptOrFn = n;
|
||||
|
||||
bodygen.generateBodyCode();
|
||||
@ -3881,7 +3881,7 @@ class BodyCodegen
|
||||
|
||||
ClassFileWriter cfw;
|
||||
Codegen codegen;
|
||||
CompilerEnvirons compilerEnv;
|
||||
CompilerEnvirons compilerEnv;
|
||||
ScriptOrFnNode scriptOrFn;
|
||||
|
||||
private OptFunctionNode fnCurrent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user