diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 9f13098..5b8ca0d 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -78,7 +78,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 78 | "close"s // Lua 5.4 | 78 | "close"s // Lua 5.4 |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | const std::string_view version = "0.33.4"sv; | 81 | const std::string_view version = "0.33.5"sv; |
| 82 | const std::string_view extension = "yue"sv; | 82 | const std::string_view extension = "yue"sv; |
| 83 | 83 | ||
| 84 | class CompileError : public std::logic_error { | 84 | class CompileError : public std::logic_error { |
| @@ -10125,7 +10125,7 @@ private: | |||
| 10125 | transformAssignment(assignment, tmp); | 10125 | transformAssignment(assignment, tmp); |
| 10126 | } | 10126 | } |
| 10127 | if (extend) { | 10127 | if (extend) { |
| 10128 | _buf << indent() << "setmetatable("sv << baseVar << ", "sv << parentVar << ".__base)"sv << nl(classDecl); | 10128 | _buf << indent() << globalVar("setmetatable"sv, classDecl, AccessType::Read) << '(' << baseVar << ", "sv << parentVar << ".__base)"sv << nl(classDecl); |
| 10129 | } | 10129 | } |
| 10130 | _buf << indent() << classVar << " = "sv << globalVar("setmetatable"sv, classDecl, AccessType::Read) << "({"sv << nl(classDecl); | 10130 | _buf << indent() << classVar << " = "sv << globalVar("setmetatable"sv, classDecl, AccessType::Read) << "({"sv << nl(classDecl); |
| 10131 | if (!builtinFields.empty()) { | 10131 | if (!builtinFields.empty()) { |
| @@ -10162,9 +10162,9 @@ private: | |||
| 10162 | _buf << indent() << "}, {"sv << nl(classDecl); | 10162 | _buf << indent() << "}, {"sv << nl(classDecl); |
| 10163 | if (extend) { | 10163 | if (extend) { |
| 10164 | _buf << indent(1) << "__index = function(cls, name)"sv << nl(classDecl); | 10164 | _buf << indent(1) << "__index = function(cls, name)"sv << nl(classDecl); |
| 10165 | _buf << indent(2) << "local val = rawget("sv << baseVar << ", name)"sv << nl(classDecl); | 10165 | _buf << indent(2) << "local val = "sv << globalVar("rawget", classDecl, AccessType::Read) << '(' << baseVar << ", name)"sv << nl(classDecl); |
| 10166 | _buf << indent(2) << "if val == nil then"sv << nl(classDecl); | 10166 | _buf << indent(2) << "if val == nil then"sv << nl(classDecl); |
| 10167 | _buf << indent(3) << "local parent = rawget(cls, \"__parent\")"sv << nl(classDecl); | 10167 | _buf << indent(3) << "local parent = "sv << globalVar("rawget", classDecl, AccessType::Read) << "(cls, \"__parent\")"sv << nl(classDecl); |
| 10168 | _buf << indent(3) << "if parent then"sv << nl(classDecl); | 10168 | _buf << indent(3) << "if parent then"sv << nl(classDecl); |
| 10169 | _buf << indent(4) << "return parent[name]"sv << nl(classDecl); | 10169 | _buf << indent(4) << "return parent[name]"sv << nl(classDecl); |
| 10170 | _buf << indent(3) << "end"sv << nl(classDecl); | 10170 | _buf << indent(3) << "end"sv << nl(classDecl); |
| @@ -10179,7 +10179,7 @@ private: | |||
| 10179 | pushScope(); | 10179 | pushScope(); |
| 10180 | auto selfVar = getUnusedName("_self_"sv); | 10180 | auto selfVar = getUnusedName("_self_"sv); |
| 10181 | addToScope(selfVar); | 10181 | addToScope(selfVar); |
| 10182 | _buf << indent(1) << "local "sv << selfVar << " = setmetatable({ }, "sv << baseVar << ")"sv << nl(classDecl); | 10182 | _buf << indent(1) << "local "sv << selfVar << " = "sv << globalVar("setmetatable", classDecl, AccessType::Read) << "({ }, "sv << baseVar << ")"sv << nl(classDecl); |
| 10183 | _buf << indent(1) << "cls.__init("sv << selfVar << ", ...)"sv << nl(classDecl); | 10183 | _buf << indent(1) << "cls.__init("sv << selfVar << ", ...)"sv << nl(classDecl); |
| 10184 | _buf << indent(1) << "return "sv << selfVar << nl(classDecl); | 10184 | _buf << indent(1) << "return "sv << selfVar << nl(classDecl); |
| 10185 | popScope(); | 10185 | popScope(); |
