You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the prelude is being passed via the require call and added to the new visitor.
The prelude should be the top-most layer in the hierarchy, appending program execution scopes to it. It should be passed as an initialization argument to the Visitor. This would allow us to reuse the same Visitor instance for each file that's executed.
Instead of passing the prelude to the require call, the active visitor instance would be passed.
Also, there should be an easier way of getting code executed.
Idea
source =<<-SOURCE let a = 25 let b = 25 a + bSOURCE
vm =Charly::VM.new
result = vm.run source, "input"puts result.value # => 50
Charly::VM should be the top-level interface to the interpreter. Config options would added to the initialize call. Charly::VM#run takes two arguments:
The source code of the program
An optional filename
If no filename is passed, VM-#{current_timestamp} will be used
Charly::VM should also keep track of the scope hierarchy, making sure each file is run in it's own scope, with the prelude being at the top.
The class PreludeLoader would be incorporated into the initialize call of Charly::VM and can then be removed. Configuration options would need a new class Charly::Config. This class would contain the values used for STDOUT, STDIN, STDERR, ARGV, IFLAGS, ENV, etc.
The internal methods api needs access to these config values as it contains the bindings to stdout etc.
The text was updated successfully, but these errors were encountered:
Currently the prelude is being passed via the require call and added to the new visitor.
The prelude should be the top-most layer in the hierarchy, appending program execution scopes to it. It should be passed as an initialization argument to the Visitor. This would allow us to reuse the same Visitor instance for each file that's executed.
Instead of passing the prelude to the require call, the active visitor instance would be passed.
Also, there should be an easier way of getting code executed.
Idea
Charly::VM
should be the top-level interface to the interpreter. Config options would added to the initialize call.Charly::VM#run
takes two arguments:Charly::VM
should also keep track of the scope hierarchy, making sure each file is run in it's own scope, with the prelude being at the top.The class
PreludeLoader
would be incorporated into the initialize call of Charly::VM and can then be removed. Configuration options would need a new classCharly::Config
. This class would contain the values used forSTDOUT
,STDIN
,STDERR
,ARGV
,IFLAGS
,ENV
, etc.The internal methods api needs access to these config values as it contains the bindings to stdout etc.
The text was updated successfully, but these errors were encountered: