Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit 61152b8

Browse files
committed
chore: rename namespace global to context
1 parent 7650000 commit 61152b8

10 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎include/lbd/frontend/lexer.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
namespace frontend {
1010
struct Lexer {
11-
static Lexer fromFile(const std::string &filepath, global::Options options = {});
11+
static Lexer fromFile(const std::string &filepath, context::Options options = {});
1212

13-
static Lexer fromRepl(const std::string &source, global::Options options = {});
13+
static Lexer fromRepl(const std::string &source, context::Options options = {});
1414

1515
// TODO: Add fromStdin
1616

@@ -19,7 +19,7 @@ namespace frontend {
1919
std::vector<token::Token> lex();
2020

2121
private:
22-
explicit Lexer(std::string filepath, std::string source, global::Options options = {});
22+
explicit Lexer(std::string filepath, std::string source, context::Options options = {});
2323

2424
std::string source;
2525
size_t position = 0;

‎include/lbd/frontend/parser.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace frontend {
1010
struct Parser {
1111
Program program;
1212

13-
explicit Parser(const std::vector<token::Token> &tokens, global::Options options_ = {});
13+
explicit Parser(const std::vector<token::Token> &tokens, context::Options options_ = {});
1414

1515
private:
1616
// TODO: Add checks for T to be a variant of frontend::TokenType

‎include/lbd/interpreter/builtins.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <lbd/options.h>
55

66
namespace interpreter::builtins {
7-
extern global::Options optionsValue;
7+
extern context::Options optionsValue;
88

9-
std::vector<NativeFunction> getBuiltins(global::Options options_ = {});
9+
std::vector<NativeFunction> getBuiltins(context::Options options_ = {});
1010
}

‎include/lbd/interpreter/interpreter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace interpreter {
124124

125125
Result interpret(frontend::Program &program,
126126
std::optional<std::shared_ptr<Environment> > globalEnvironment = std::nullopt,
127-
global::Options options_ = {});
127+
context::Options options_ = {});
128128

129129
/// Add builtins Native Functions into Environment.
130130
void installBuiltins(const std::shared_ptr<Environment> &environment);

‎include/lbd/options.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "logs.h"
44

5-
namespace global {
5+
namespace context {
66
struct Options {
77
bool ownExpression = false; /// Owning Expression inside Thunk. Turned on for REPL
88
bool forceOnEnvironmentDump = false;

‎src/frontend/lexer.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <fstream>
66

77
namespace frontend {
8-
static global::Options optionsValue;
8+
static context::Options optionsValue;
99

1010
char Lexer::peek() const {
1111
return position < source.size() ? source[position] : '\0';
@@ -33,7 +33,7 @@ namespace frontend {
3333
return {row, col, filepath};
3434
}
3535

36-
Lexer Lexer::fromFile(const std::string &filepath, const global::Options options) {
36+
Lexer Lexer::fromFile(const std::string &filepath, const context::Options options) {
3737
std::ifstream fileStream(filepath);
3838
if (!fileStream) {
3939
optionsValue.logger.error({}, "IO error: could not open file ", filepath);
@@ -43,11 +43,11 @@ namespace frontend {
4343
return Lexer(filepath, stringStream.str(), options);
4444
}
4545

46-
Lexer Lexer::fromRepl(const std::string &source, const global::Options options) {
46+
Lexer Lexer::fromRepl(const std::string &source, const context::Options options) {
4747
return Lexer("", source, options);
4848
}
4949

50-
Lexer::Lexer(std::string filepath, std::string source, const global::Options options) : source(std::move(source)),
50+
Lexer::Lexer(std::string filepath, std::string source, const context::Options options) : source(std::move(source)),
5151
filepath(std::move(filepath)) {
5252
optionsValue = options;
5353
}

‎src/frontend/parser.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace frontend {
99
static std::unordered_set<std::string> loadedFiles;
10-
static global::Options optionsValue;
10+
static context::Options optionsValue;
1111

12-
Parser::Parser(const std::vector<token::Token> &tokens, const global::Options options_) {
12+
Parser::Parser(const std::vector<token::Token> &tokens, const context::Options options_) {
1313
optionsValue = options_;
1414
size_t index = 0;
1515
program = Program{build(tokens, index)};

‎src/interpreter/builtins.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// TODO: Add module system like use module io. Which dlopen's the module and loads it.
77

88
namespace interpreter::builtins {
9-
global::Options optionsValue;
9+
context::Options optionsValue;
1010

11-
std::vector<NativeFunction> getBuiltins(const global::Options options_) {
11+
std::vector<NativeFunction> getBuiltins(const context::Options options_) {
1212
optionsValue = options_;
1313
return {
1414
{makePrint()},

‎src/interpreter/interpreter.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "lbd/utils/string_escape.h"
88

99
namespace interpreter {
10-
static global::Options optionsValue;
10+
static context::Options optionsValue;
1111
static ResultOptions globalResultOptions;
1212

1313
[[nodiscard]] std::string Closure::toString() const {
@@ -334,7 +334,7 @@ namespace interpreter {
334334
// Creates placeholder Thunk then set body so recursion can refer to it during lazy evaluation
335335
static void bindDefinitionAstNodeLazy(frontend::DefinitionAstNode &definitionAstNode,
336336
const std::shared_ptr<Environment> &environment,
337-
const global::Options options) {
337+
const context::Options options) {
338338
const auto thunk = std::make_shared<Thunk>();
339339
environment->bind(definitionAstNode.definitionName.value, thunk);
340340
if (options.ownExpression) {
@@ -346,7 +346,7 @@ namespace interpreter {
346346
}
347347

348348
Result interpret(frontend::Program &program, std::optional<std::shared_ptr<Environment> > globalEnvironment,
349-
const global::Options options_) {
349+
const context::Options options_) {
350350
optionsValue = options_;
351351
if (!globalEnvironment) {
352352
globalEnvironment = std::make_shared<Environment>();

‎src/repl.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
// TODO: Option :t for display type information of a symbol.
1414

1515
namespace repl {
16-
static global::Options optionsValue;
16+
static context::Options optionsValue;
1717

1818
static void processLoadCommand(const std::string &argument,
1919
std::optional<std::shared_ptr<interpreter::Environment> > &sharedEnvironment) {
2020
const std::string &filepath = argument;
21-
global::Options subOptions = optionsValue;
21+
context::Options subOptions = optionsValue;
2222
subOptions.logger.showLocation = true;
2323

2424
if (!std::filesystem::exists(filepath)) {

0 commit comments

Comments
 (0)