| java.lang.Object gnu.expr.Compilation kawa.lang.Translator
Translator | public class Translator extends Compilation (Code) | | Used to translate from source to Expression.
The result has macros expanded, lexical names bound, etc, and is
ready for code generation.
This is sometimes called a "compilation environment",
but we modify it as we go along - there is a single Translator for
each top-level form.
|
Method Summary | |
Expression | apply_rewrite(Syntax syntax, Pair form) Apply a Syntax object. | Syntax | check_if_Syntax(Declaration decl) Check if a Declaration is bound to a Syntax. | public Declaration | define(Object name, SyntaxForm nameSyntax, ScopeExp defs) | public Type | exp2Type(Pair typeSpecPair) Extract a type from the car of a pair. | public void | finishModule(ModuleExp mexp) | public Syntax | getCurrentSyntax() | final public Environment | getGlobalEnvironment() | static ReferenceExp | getOriginalRef(Declaration decl) Check if declaraton is an alias for some other name.
This is needed to chase identifiers renamed for hygienic macro
expansion - see SyntaxRules.expand. | public boolean | isLexical(Declaration decl) Return true if decl is lexical and not fluid. | public static int | listLength(Object obj) Returns the length of a syntax list.
Returns Integer.MIN_VALUE for cyclic lists.
For impure lists returns the negative of one more than
the number of pairs before the "dot".
Similar to LList.listLength, but descends into SyntaxForm. | public Declaration | lookup(Object name, int namespace) | public Declaration | lookupGlobal(Object name) Find global Declaration, creating one if not found. | public Declaration | lookupGlobal(Object name, int namespace) Find global Declaration, creating one if not found. | public Expression | makeBody(int first, ScopeExp scope) Combine a list of zero or more expression forms into a "body". | public static Pair | makePair(Pair pair, Object car, Object cdr) | public Declaration | makeRenamedAlias(Declaration decl, ScopeExp templateScope) | public Declaration | makeRenamedAlias(Object name, Declaration decl, ScopeExp templateScope) | final public boolean | matches(Object form, String literal) True iff a form matches a literal symbol. | public boolean | matches(Object form, SyntaxForm syntax, String literal) | public Symbol | namespaceResolve(Expression context, Expression member) | public Object | namespaceResolve(Object name) | public void | noteAccess(Object name, ScopeExp scope) Note that we reference name in a given scope.
This may be called when defining a macro, at scan-time,
and the name may be bound to a declaration we haven't seen yet. | public Expression | parse(Object input) | public Object | popForms(int first) | public void | popPositionOf(Object saved) Restore line number position from a previous pushPositionOf. | public void | popRenamedAlias(int count) Remove one or more aliases created by pushRenamedAlias . | public void | processAccesses() Check references recorded by noteAccess. | public Object | pushPositionOf(Object pair) Note current line number position from a PairWithPosition. | public void | pushRenamedAlias(Declaration alias) Push an alias for a declaration in a scope.
If the name of decl came from a syntax template
whose immediate scope is templateScope ,
then the same syntax template may contain local variable references
that are also in the same templateScope .
Such variable references will not look in the current
"physical" scope, where we just created decl , but
will instead search the "lexical" templateScope.
So that such references can resolve to decl , we
create an alias in templateScope that points
to decl . | public void | resolveModule(ModuleExp mexp) | public Expression | rewrite(Object exp) Re-write a Scheme expression in S-expression format into internal form. | public Expression | rewrite(Object exp, boolean function) Re-write a Scheme expression in S-expression format into internal form. | public void | rewriteBody(int first) | public void | rewriteInBody(Object exp) | public Expression | rewrite_body(Object exp) Re-write a Scheme in S-expression format into internal form. | final public Expression | rewrite_car(Pair pair, SyntaxForm syntax) | final public Expression | rewrite_car(Pair pair, boolean function) | public Expression | rewrite_pair(Pair p, boolean function) | public Expression | rewrite_with_position(Object exp, boolean function, PairWithPosition pair) | public static Object | safeCar(Object obj) | public static Object | safeCdr(Object obj) | public Object | scanBody(Object body, ScopeExp defs, boolean makeList) Recursive helper method for rewrite_body. | public void | scanForm(Object st, ScopeExp defs) | final boolean | selfEvaluatingSymbol(Object obj) | public void | setCurrentScope(ScopeExp scope) | public static void | setLine(Expression exp, Object location) | public static void | setLine(Declaration decl, Object location) | public void | setLineOf(Expression exp) Set the line position of the argument to the current position. | public static Object | stripSyntax(Object obj) | public static Object | wrapSyntax(Object form, SyntaxForm syntax) |
currentMacroDefinition | public Macro currentMacroDefinition(Code) | | Set if we're processing (as opposed to expanding)
a define-syntax or defmacro .
|
firstForm | public int firstForm(Code) | | |
macroContext | Declaration macroContext(Code) | | The module instance containing the current macro.
This is only used temporarily, set when resolving a Declaration
bound to a macro, and used to set the macroContext field of the
TemplateScope created when expanding the macro's template(s).
|
matchArray | public Declaration matchArray(Code) | | A variable to hold the matched values for syntax-case
pattern variables.
|
notedAccess | Vector notedAccess(Code) | | Storage used by noteAccess and processAccesses.
|
patternScope | public PatternScope patternScope(Code) | | Innermost current scope of pattern variable,
from a syntax-case .
|
renamedAliasStack | Stack renamedAliasStack(Code) | | A stack of aliases pushed by pushRenamedAlias .
|
apply_rewrite | Expression apply_rewrite(Syntax syntax, Pair form)(Code) | | Apply a Syntax object.
Parameters: syntax - the Syntax object whose rewrite method we call Parameters: form - the syntax form (including the macro name) the re-written form as an Expression object |
check_if_Syntax | Syntax check_if_Syntax(Declaration decl)(Code) | | Check if a Declaration is bound to a Syntax.
Parameters: decl - the Declaration to check the Syntax bound to decl, or null.In the former case, macroContext may be set as a side effect. |
exp2Type | public Type exp2Type(Pair typeSpecPair)(Code) | | Extract a type from the car of a pair.
|
getOriginalRef | static ReferenceExp getOriginalRef(Declaration decl)(Code) | | Check if declaraton is an alias for some other name.
This is needed to chase identifiers renamed for hygienic macro
expansion - see SyntaxRules.expand.
|
isLexical | public boolean isLexical(Declaration decl)(Code) | | Return true if decl is lexical and not fluid.
|
listLength | public static int listLength(Object obj)(Code) | | Returns the length of a syntax list.
Returns Integer.MIN_VALUE for cyclic lists.
For impure lists returns the negative of one more than
the number of pairs before the "dot".
Similar to LList.listLength, but descends into SyntaxForm.
|
lookupGlobal | public Declaration lookupGlobal(Object name, int namespace)(Code) | | Find global Declaration, creating one if not found.
|
makeBody | public Expression makeBody(int first, ScopeExp scope)(Code) | | Combine a list of zero or more expression forms into a "body".
|
matches | final public boolean matches(Object form, String literal)(Code) | | True iff a form matches a literal symbol.
|
noteAccess | public void noteAccess(Object name, ScopeExp scope)(Code) | | Note that we reference name in a given scope.
This may be called when defining a macro, at scan-time,
and the name may be bound to a declaration we haven't seen yet.
|
popPositionOf | public void popPositionOf(Object saved)(Code) | | Restore line number position from a previous pushPositionOf.
Parameters: saved - value returned by matching pushPositionOf. |
popRenamedAlias | public void popRenamedAlias(int count)(Code) | | Remove one or more aliases created by pushRenamedAlias .
|
processAccesses | public void processAccesses()(Code) | | Check references recorded by noteAccess.
Resolve now to a Declaration, and note the access.
This is needed in case an exported macro references a private Declaration.
|
pushPositionOf | public Object pushPositionOf(Object pair)(Code) | | Note current line number position from a PairWithPosition.
Return an object to pass to popPositionOf.
|
pushRenamedAlias | public void pushRenamedAlias(Declaration alias)(Code) | | Push an alias for a declaration in a scope.
If the name of decl came from a syntax template
whose immediate scope is templateScope ,
then the same syntax template may contain local variable references
that are also in the same templateScope .
Such variable references will not look in the current
"physical" scope, where we just created decl , but
will instead search the "lexical" templateScope.
So that such references can resolve to decl , we
create an alias in templateScope that points
to decl . We record that we did this in the
renamedLiasStack , so we can remove the alias later.
|
rewrite | public Expression rewrite(Object exp)(Code) | | Re-write a Scheme expression in S-expression format into internal form.
|
rewrite | public Expression rewrite(Object exp, boolean function)(Code) | | Re-write a Scheme expression in S-expression format into internal form.
|
rewriteBody | public void rewriteBody(int first)(Code) | | |
rewrite_body | public Expression rewrite_body(Object exp)(Code) | | Re-write a Scheme in S-expression format into internal form.
|
scanBody | public Object scanBody(Object body, ScopeExp defs, boolean makeList)(Code) | | Recursive helper method for rewrite_body.
Scan body for definitions, adding partially macro-expanded
expressions into the formStack .
Parameters: makeList - if true, return a list representation of the scannedforms (not including declarations); else forms are push on formStack a list of forms if makeList (possibly wrappedin a SyntaxForm ); otherwise null . |
selfEvaluatingSymbol | final boolean selfEvaluatingSymbol(Object obj)(Code) | | |
setLineOf | public void setLineOf(Expression exp)(Code) | | Set the line position of the argument to the current position.
|
Methods inherited from gnu.expr.Compilation | public void addClass(ClassType new_class)(Code)(Java Doc) public void addMainClass(ModuleExp module)(Code)(Java Doc) public Field allocLocalField(Type type, String name)(Code)(Java Doc) public void compileConstant(Object value)(Code)(Java Doc) public void compileConstant(Object value, Target target)(Code)(Java Doc) public Field compileConstantToField(Object value)(Code)(Java Doc) public void compileToArchive(ModuleExp mexp, String fname) throws java.io.IOException(Code)(Java Doc) public LambdaExp currentLambda()(Code)(Java Doc) public ModuleExp currentModule()(Code)(Java Doc) public ScopeExp currentScope()(Code)(Java Doc) public static char demangle2(char char1, char char2)(Code)(Java Doc) public static String demangleName(String name)(Code)(Java Doc) public static String demangleName(String name, boolean reversible)(Code)(Java Doc) public void error(char severity, String message, SourceLocator location)(Code)(Java Doc) public void error(char severity, String message)(Code)(Java Doc) public void error(char severity, Declaration decl, String msg1, String msg2)(Code)(Java Doc) public void error(char severity, String message, String code, Declaration decl)(Code)(Java Doc) public static synchronized Compilation findForImmediateLiterals(int key)(Code)(Java Doc) public ClassType findNamedClass(String name)(Code)(Java Doc) public void freeLocalField(Field field)(Code)(Java Doc) public void generateApplyMethodsWithContext(LambdaExp lexp)(Code)(Java Doc) public void generateApplyMethodsWithoutContext(LambdaExp lexp)(Code)(Java Doc) public String generateClassName(String hint)(Code)(Java Doc) final public void generateConstructor(LambdaExp lexp)(Code)(Java Doc) final public void generateConstructor(ClassType clas, LambdaExp lexp)(Code)(Java Doc) public void generateMatchMethods(LambdaExp lexp)(Code)(Java Doc) final public boolean getBooleanOption(String key, boolean defaultValue)(Code)(Java Doc) final public boolean getBooleanOption(String key)(Code)(Java Doc) final public CodeAttr getCode()(Code)(Java Doc) final public int getColumnNumber()(Code)(Java Doc) final public Method getConstructor(LambdaExp lexp)(Code)(Java Doc) final public static Method getConstructor(ClassType clas, LambdaExp lexp)(Code)(Java Doc) public static Compilation getCurrent()(Code)(Java Doc) final public String getFileName()(Code)(Java Doc) public Method getForNameHelper()(Code)(Java Doc) public Language getLanguage()(Code)(Java Doc) final public int getLineNumber()(Code)(Java Doc) public SourceMessages getMessages()(Code)(Java Doc) final public ModuleExp getModule()(Code)(Java Doc) final public ClassType getModuleType()(Code)(Java Doc) public String getPublicId()(Code)(Java Doc) public int getState()(Code)(Java Doc) public String getSystemId()(Code)(Java Doc) public boolean inlineOk(Expression proc)(Code)(Java Doc) public boolean inlineOk(Procedure proc)(Code)(Java Doc) public boolean isPedantic()(Code)(Java Doc) public boolean isStableSourceLocation()(Code)(Java Doc) public boolean isStatic()(Code)(Java Doc) public static boolean isValidJavaName(String name)(Code)(Java Doc) public LetExp letDone(Expression body)(Code)(Java Doc) public void letEnter()(Code)(Java Doc) public void letStart()(Code)(Java Doc) public Declaration letVariable(Object name, Type type, Expression init)(Code)(Java Doc) final public void loadCallContext()(Code)(Java Doc) public void loadClassRef(ClassType clas)(Code)(Java Doc) public void loadClassRef(String className)(Code)(Java Doc) public Declaration lookup(Object name, int namespace)(Code)(Java Doc) public void loopBody(Expression body)(Code)(Java Doc) public void loopCond(Expression cond)(Code)(Java Doc) public void loopEnter()(Code)(Java Doc) public Expression loopRepeat(Expression[] exps)(Code)(Java Doc) public Expression loopRepeat()(Code)(Java Doc) public Expression loopRepeat(Expression exp)(Code)(Java Doc) public void loopStart()(Code)(Java Doc) public Declaration loopVariable(Object name, Type type, Expression init)(Code)(Java Doc) public static String mangleName(String name)(Code)(Java Doc) public static String mangleName(String name, boolean reversible)(Code)(Java Doc) public static String mangleName(String name, int kind)(Code)(Java Doc) public static String mangleNameIfNeeded(String name)(Code)(Java Doc) public static String mangleURI(String name)(Code)(Java Doc) public void mustCompileHere()(Code)(Java Doc) public void outputClass(String directory) throws IOException(Code)(Java Doc) public Expression parse(Object input)(Code)(Java Doc) public void pop(ScopeExp scope)(Code)(Java Doc) final public void pop()(Code)(Java Doc) public void process(int wantedState)(Code)(Java Doc) public void push(ScopeExp scope)(Code)(Java Doc) public void push(Declaration decl)(Code)(Java Doc) public ModuleExp pushNewModule(Lexer lexer)(Code)(Java Doc) public ModuleExp pushNewModule(String filename)(Code)(Java Doc) public void pushPendingImport(ModuleInfo info, ScopeExp defs)(Code)(Java Doc) final public void pushScope(ScopeExp scope)(Code)(Java Doc) public static synchronized int registerForImmediateLiterals(Compilation comp)(Code)(Java Doc) public Object resolve(Object name, boolean function)(Code)(Java Doc) public void setColumn(int column)(Code)(Java Doc) public static void setCurrent(Compilation comp)(Code)(Java Doc) public void setCurrentScope(ScopeExp scope)(Code)(Java Doc) public void setFile(String filename)(Code)(Java Doc) public void setLine(int line)(Code)(Java Doc) final public void setLine(Expression position)(Code)(Java Doc) public void setLine(Object location)(Code)(Java Doc) public void setLine(String filename, int line, int column)(Code)(Java Doc) final public void setLocation(SourceLocator position)(Code)(Java Doc) public void setMessages(SourceMessages messages)(Code)(Java Doc) public void setModule(ModuleExp mexp)(Code)(Java Doc) public void setState(int state)(Code)(Java Doc) public static void setupLiterals(int key)(Code)(Java Doc) public Expression syntaxError(String message)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void usedClass(Type type)(Code)(Java Doc) public boolean usingCPStyle()(Code)(Java Doc) public boolean usingTailCalls()(Code)(Java Doc) public void walkModule(ModuleExp mexp)(Code)(Java Doc)
|
|
|