-
Notifications
You must be signed in to change notification settings - Fork 5
V1 Var usage
In the Compiler in Clojure document, Rich indicates the following goal(s):
Remove warts from current design
e.g. use of vars and binding
explicitly pass environment
current code modifies environment to e.g. tag things as closed-over ...
could turn into query against child tree
in any case, will need to take and return environment (in addition to returning expression object)
There are a number of global variables used in the compiler that are actually Var
s, used to pass around environment.
Here is an analysis.
Some of the Var
s have names and are visible to the ClojureCLR user.
-
CompileFilesVar
=*compile-files*
Used in RT to determine if we are compiling
*compile-files*
appears inclojure.core/compile
andclojure.core/gen-class
Not used directly in the compiler. We are compiling because this has been set to not-false.
-
InstanceVar
=instance?
Used in
InvokeExpr
to detect forms of the form(instance? X Y)
Why do we not just consider this a primitive?
-
CompilePathVar
=*compile-path*
Bound in
BootstrapCompile.Compile.Main
andSimpleConsole
.
Bound inmain.clj
at startup time
Used inGenContext
,GenClass
-
CompileVar
=compile
Used in
BootstrapCompile
to invokeclojure.core/compile
.
Many of the Var
's do not have names. They are threadbound in various places, often the start of compilation or in the scopes of FnExpr
s and NewInstanceExpr
s (or their corresponding methods). Some are bound to pass a single piece of information. Some are just flags. Some are bound to collections and then set to updated collections.
-
SourceVar
=*source-path*
Not found in .clj code, despite having a name.
Used inDefExpr
,HostExpr
,InvokeExpr
,RecurExpr
,Compiler.AnalyzeSymbol
Bound inCompiler.compile
andCompiler.load
-
SourceFileVar
=*file*
*file*
used inclojure.core/throw-if
,clojure.core/validate-fields
(error messages)
*file*
bound inclojure.core/load-data-reader-file
Used inCaseExpr
,DefExpr
,InstanceFieldExpr
,InstanceZeroArityCallExpr
,NewExpr
,StaticMethodExpr
,Compiler.Analyze
(error msg),Compiler.AnalyzeSeq
(error msg),Reflector.MaybeReflectionWarn
Bound inCompiler.compile
andCompiler.load
LineVar
Used in
DefExpr
,Compiler.LineVarDeref
(and so used in many other places)
Bound inCompiler.eval
,Compiler.Compile1
,Compiler.AnalyzeSeq
Compiler.LineVarDeref
used inDefExpr
,Compiler.eval
,Compiler.Compile1
,Compiler.Analyze
(error msg),Compiler.AnalyzeSeq
(error msg)
ColumnVar
Similar to
LineVar
SourceSpanVar
Used in
CaseExpr
,FnExpr
,FnMethod
,HostExpr
,IfExpr
,InvokeExpr
,NewExpr
,NewInstanceExpr
,NewInstanceMethod
,RecurExpr
,Compiler.eval
,Compiler.Compile1
,Compiler.AnalyzeSymbol
,Compiler.AnalyzeSeq
Bound inCompiler.eval
,Compiler.Compile1
,Compiler.AnalyzeSeq
MethodVar
Used in
FnExpr
,FnMethod
,LetExpr
,NewInstanceExpr
,NewInstanceMethod
,ObjMethod
,Compiler.RegisterLocalInternal
(modifies the method),Compiler.GetAndIncLocalNum
(modifies the method),Compiler.ReferenceLocal
(modifies the method)
Bound inFnMethod
,NewInstanceMethod
,ObjMethod
,Compiler.Compile
LocalEnvVar
Used in
HostExpr
,Compiler.MacroexpandSeq1
,ReferenceLocal
Bound inFnMethod
,LetExpr
,LetFnExpr
,NewInstanceExpr
,NewInstanceMethod
,TryExpr
,Compiler.Compile
Set inCompiler.RegisterLocalInternal
NextLocalNumVar
Used in
Compiler.GetAndIncLocalNum
Bound inFnMethod
,LetExpr
,LetFnExpr
,NewInstanceMethod
,TryExpr
,Compiler.Compile
Set inCompiler.GetAndIncLocalNum
LoopLocalsVar
Used in
RecurExpr
Bound inFnMethod
,LetExpr
,NewInstanceMethod
,Compiler.Compile
Set inFnMethod
,LetExpr
,NewInstanceMethod
LoopLabelVar
Used in
RecurExpr
Bound inFnMethod
,LetExpr
,NewInstanceMethod
,ObjMethod
InTryBlockVar
Used in
Compiler.InTailCall
Bound inTryExpr
InCatchFinallyVar
Used in
TryExpr
,Compiler.CloseOver
Bound inTryExpr
NoRecurVar
Used in
RecurExpr
Bound inFnExpr
,LetExpr
,NewInstanceExpr
,TryExpr
VarsVar
Used in
FnExpr
,NewInstanceExpr
,Compiler.Compile1
,Compiler.RegisterVar
Bound inFnExpr
,NewInstanceExpr
,Compiler.Compile
Set inCompiler.RegisterVar
ConstantsVar
Used in
FnExpr
,NewInstanceExpr
.Compiler.Compile1
,Compiler.RegisterConstant
Bound inFnExpr
,NewInstanceExpr
,Compiler.Compile
,
Set inCompiler.RegisterConstant
ConstantIdsVar
Bound in
FnExpr
,NewInstanceExpr
,Compiler.Compile
Set inCompiler.RegisterConstant
KeywordsVar
Used in
FnExpr
,NewInstanceExpr
,Compiler.Compile1
Bound inFnExpr
,NewInstanceExpr
,Compiler.Compile
Set inCompiler.RegisterKeyword
KeywordCallsitesVar
Used in
FnExpr
,NewInstanceExpr
,InvokeExpr
Bound inFnExpr
,NewInstanceExpr
Set inCompiler.RegisterKeywordCallsite
ProtocolCallsitesVar
Used in
FnExpr
,NewInstanceExpr
,InvokeExpr
Bound inFnExpr
,NewInstanceExpr
Set inCompiler.RegisterProtocolCallsite
VarCallsitesVar
Used in
FnExpr
,NewInstanceExpr
Bound inFnExpr
,NewInstanceExpr
Set inRegisterVarCallsite
CompileStubSymVar
Used in
HostExpr.MaybeType
,Compiler.ResolveIn
Bound inNewInstanceExpr
- CompileStubClassVar
Used in
HostExpr.MaybeType
,NewExpr.ComputeCtor
,Compiler.ResolveIn
Bound inNewInstanceExpr
CompileStubOrigClassVar
Used in NewExpr.EmitTargetExpression
Bound inObjExpr.Compile
CompilingDefTypeVar
Used in
Compiler.IsCompilingDefType
Bound inNewInstanceExpr
,ObjExpr
CompilerContextVar
Used in
FnExpr
,GenContext
,MethodExpr
,NewInstanceExpr
,Compiler.IsCompilingSuffix
,GenInterface
,GenProxy
Bound inFnExpr
,NewInstanceExpr
,ObjExpr
,Compiler.eval
,Compiler.Compile
,Compiler.load
,
CompilerActiveVar
Used in
Compiler.IsCompiling
Bound inCompiler.Compile
CompilerOptionsVar
Used in
Compiler.GetCompilerOption
Initialized inCompiler.InitializeCompilerOptions