zxul767 / lox

An interpreter for the Lox language
1 stars 0 forks source link

add `:globals` command in REPLs #21

Open zxul767 opened 1 year ago

zxul767 commented 1 year ago

the :globals command should print a list of all the globals in the current session, organized by type:

CoffeeMaker   <class>
maker         <CoffeeMaker instance>

start         <function>
counter1      <closure>
counter2      <closure>

count         <primitive:number>
program       <primitive:string>
flag          <primitive:bool>

for clox, even though we always wrap functions in closures, by inspecting the upvalues array we can tell if a function is an actual closure.