-
Notifications
You must be signed in to change notification settings - Fork 7
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 Vars, used to pass around environment. Here is an analysis.
Some of the Vars 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 BootstrapOmpile.Compile.Main and SimpleConsole. Main.clj: bound at startup time Used in GenContext, GenClass
CompileVar = “compile” Used in BootstrapCompile to invoke the clojure.core/compile.
SourceVar = source-path Not found in .clj code, despite having a name. Used in DefExpr, HostExpr, InvokeExpr, RecurExpr, Compiler.AnalyzeSymbol Bound in Compiler.compile and Compiler.load
SourceFileVar = file file used in clojure.core/throw-if, clojure.core/validate-fields (error messages) file bound in clojure.core/load-data-reader-file Used in CaseExpr, DefExpr, InstanceFieldExpr, InstanceZeroArityCallExpr, NewExpr, StaticMethodExpr, Compiler.Analyze (error msg), Compiler.AnalyzeSeq (error msg), Reflector.MaybeReflectionWarn Bound in Compiler.compile and Compiler.load
LineVar Used in DefExpr, Compiler.LineVarDeref Bound in Compiler.eval, Compiler.Compile1, Compiler.AnalyzeSeq Compiler.LineVarDeref used in DefExpr, Compiler.eval, Compiler.Compile1, Compiler.Analyze (error msg), Compiler.AnalyzeSeq (error msg)
ColumnVar Similar to LineVar
SourceSpanVar Used in CaseExpr, FnExpr, FnMethod, HostExpr, Ifxpr, InvokeExpr, NewExpr, NewInstanceExpr, NewInstanceMethod, RecurExpr, Compiler.eval, Compiler.Compile1, Compiler.AnalyzeSymbol, Compiler.AnalyzeSeq
Bound in Compiler.eval, Compiler.Compile1, Compiler.AnalyzeSeq
MethodVar Used in FnExpr, FnMethod, LetEsxpr, NewInstanceExpr, NewInstanceMethod, ObjMethod Compiler.RegisterLocalInternal (modifies the method) Compiler.GetAndIncLocalNum (modifies the method) Compiler.ReferenceLocal (modifies the method) Bound in FnMethod, NewInstanceMethod, ObjMethod, Compiler.Compile
LocalEnvVar Used in HostExpr, Compiler.MacroexpandSeq1, ReferenceLocal Bound in FnMethod, LetExpr, LetFnExpr, NewInstanceExpr, NewInstanceMethod, TryExpr, Compiler.Compile, Set in Compiler.RegisterLocalInternal
NextLocalNumVar Used in Compiler.GetAndIncLocalNum Bound in FnMethod, LetExpr, LetFnExpr, NewInstanceMethod, TryExpr, Compiler.Compile Set in Compiler.GetAndIncLocalNum
LoopLocalsVar Used in RecurExpr Bound in FnMethod, LetExpr, NewInstanceMethod, Compiler.Compile Set in FnMethod, LetExpr, NewInstanceMethod
LoopLabelVar Used in RecurExpr Bound in FnMethod, LetExpr, NewInstanceMethod, ObjMethod
InTryBlockVar Used in Compiler.InTailCall Bound in TryExpr
InCatchFinallyVar Used in TryExpr, Compiler.CloseOver Bound in TryExpr
NoRecurVar Used in RecurExpr Bound in FnExpr, LetExpr, NewInstanceExpr, TryExpr
VarsVar Used in FnExpr, NewInstanceExpr, Compiler.Compile1, Compiler.RegisterVar Bound in FnExpr, NewInstanceExpr, Compiler.Compile Set in Compiler.RegisterVar
ConstantsVar Used in FnExpr, NewInstanceExpr. Compiler.Compile1, Compiler.RegisterConstant Bound in FnExpr, NewInstanceExpr, Compiler.Compile, Set in Compiler.RegisterConstant
ConstantIdsVar Bound in FnExpr, NewInstanceExpr, Compiler.Compile Set in Compiler.RegisterConstant
KeywordsVar Used in FnExpr, NewInstanceExpr, Compiler.Compile1 Bound in FnExpr, NewInstanceExpr, Compiler.Compile Set in Compiler.RegisterKeyword
KeywordCallsitesVar Used in FnExpr, NewInstanceExpr, InvokeExpr Bound in FnExpr, NewInstanceExpr Set in Compiler.RegisterKeywordCallsite
ProtocolCallsitesVar Used in FnExpr, NewInstanceExpr, InvokeExpr Bound in FnExpr, NewInstanceExpr Set in Compiler.RegisterProtocolCallsite
VarCallsitesVar Used in FnExpr, NewInstanceExpr Bound in FnExpr, NewInstanceExpr Set in RegisterVarCallsite
CompileStubSymVar Used in HostExpr.MaybeType, Compiler.ResolveIn Bound in NewInstanceExpr
CompileStubClassVar Used in HostExpr.MaybeType, NewExpr.ComputeCtor, , Compiler.ResolveIn
Bound in NewInstanceExpr
CompileStubOrigClassVar Used in NewExpr.EmitTargetExpression Bound in ObjExpr.Compile
CompilingDefTypeVar Used in Compiler.IsCompilingDefType Bound in NewInstanceExpr, ObjExprt
CompilerContextVar Used in FnExpr, GenContext, MethodExpr, NewInstanceExpr, Compiler.IsCompilingSuffix, GenInterface, GenProxy Bound in FnExpr, NewInstanceExpr, ObjExpr, Compiler.eval, Compiler.Compile, Compiler.load,
CompilerActiveVar Used in Compiler.IsCompiling Bound in Compiler.Compile
CompilerOptionsVar Used in Compiler.GetCompilerOption Initialized in Compiler.InitializeCompilerOptions