Skip to content

Commit c14feca

Browse files
committed
Add unsafeConstants parameter to Compiler constructor
1 parent 44f1371 commit c14feca

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎include/scratchcpp/compiler.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class LIBSCRATCHCPP_EXPORT Compiler
5353
using Args = std::vector<CompilerValue *>;
5454

5555
Compiler(CompilerContext *ctx);
56-
Compiler(IEngine *engine, Target *target);
56+
Compiler(IEngine *engine, Target *target, const std::unordered_set<std::string> &unsafeConstants = {});
5757
Compiler(const Compiler &) = delete;
5858

5959
IEngine *engine() const;

‎src/engine/compiler.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Compiler::Compiler(CompilerContext *ctx) :
2020
}
2121

2222
/*! Constructs Compiler using a new context for the given target. */
23-
Compiler::Compiler(IEngine *engine, Target *target) :
24-
impl(spimpl::make_unique_impl<CompilerPrivate>(engine, target))
23+
Compiler::Compiler(IEngine *engine, Target *target, const std::unordered_set<std::string> &unsafeConstants) :
24+
impl(spimpl::make_unique_impl<CompilerPrivate>(engine, target, unsafeConstants))
2525
{
2626
}
2727

‎src/engine/compiler_p.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ CompilerPrivate::CompilerPrivate(CompilerContext *ctx) :
1717
initBuilderFactory();
1818
}
1919

20-
CompilerPrivate::CompilerPrivate(IEngine *engine, Target *target) :
21-
ctxPtr(Compiler::createContext(engine, target, {})), // NOTE: This constructor is only used in tests, so we can leave unsafe constants empty
20+
CompilerPrivate::CompilerPrivate(IEngine *engine, Target *target, const std::unordered_set<std::string> &unsafeConstants) :
21+
ctxPtr(Compiler::createContext(engine, target, unsafeConstants)),
2222
ctx(ctxPtr.get())
2323
{
2424
initBuilderFactory();

‎src/engine/compiler_p.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LIBSCRATCHCPP_TEST_EXPORT CompilerPrivate
2929
};
3030

3131
CompilerPrivate(CompilerContext *ctx);
32-
CompilerPrivate(IEngine *engine, Target *target);
32+
CompilerPrivate(IEngine *engine, Target *target, const std::unordered_set<std::string> &unsafeConstants);
3333

3434
static void initBuilderFactory();
3535

0 commit comments

Comments
 (0)