mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 15:14:12 +00:00
separate coreLibs and userLibs for LispFactory
This commit is contained in:
parent
90a9b3aa53
commit
871df1f691
@ -3,7 +3,7 @@ namespace MadLisp;
|
|||||||
|
|
||||||
class LispFactory
|
class LispFactory
|
||||||
{
|
{
|
||||||
public function make(array $libraries = []): Lisp
|
public function make(array $coreLibs = [], array $userLibs = []): Lisp
|
||||||
{
|
{
|
||||||
$tokenizer = new Tokenizer();
|
$tokenizer = new Tokenizer();
|
||||||
$reader = new Reader();
|
$reader = new Reader();
|
||||||
@ -50,14 +50,19 @@ class LispFactory
|
|||||||
(new Lib\Time())->register($env);
|
(new Lib\Time())->register($env);
|
||||||
(new Lib\Types())->register($env);
|
(new Lib\Types())->register($env);
|
||||||
|
|
||||||
// Register additional libraries
|
// Register additional libs for root env
|
||||||
foreach ($libraries as $lib) {
|
foreach ($coreLibs as $lib) {
|
||||||
$lib->register($env);
|
$lib->register($env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// User environment
|
// User environment
|
||||||
$env = new Env('user', $env);
|
$env = new Env('user', $env);
|
||||||
|
|
||||||
|
// Register additional libs for user env
|
||||||
|
foreach ($userLibs as $lib) {
|
||||||
|
$lib->register($env);
|
||||||
|
}
|
||||||
|
|
||||||
return new Lisp($tokenizer, $reader, $eval, $printer, $env);
|
return new Lisp($tokenizer, $reader, $eval, $printer, $env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user