修复定义变量未提供值时内存泄漏的bug。修复lexer解析字符串不能多行的bug
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#include "Ast/Statements/InterfaceDefSt.hpp"
|
#include <Ast/Statements/InterfaceDefSt.hpp>
|
||||||
#include <Evaluator/Core/ExprResult.hpp>
|
#include <Evaluator/Core/ExprResult.hpp>
|
||||||
#include <Ast/AccessModifier.hpp>
|
#include <Ast/AccessModifier.hpp>
|
||||||
#include <Ast/Expressions/FunctionCall.hpp>
|
#include <Ast/Expressions/FunctionCall.hpp>
|
||||||
@@ -65,6 +65,10 @@ namespace Fig
|
|||||||
value = std::make_shared<Object>(Object::defaultValue(declaredType));
|
value = std::make_shared<Object>(Object::defaultValue(declaredType));
|
||||||
} // else -> Ok
|
} // else -> Ok
|
||||||
} // else -> type is Any (default)
|
} // else -> type is Any (default)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = Object::getNullInstance();
|
||||||
|
}
|
||||||
AccessModifier am =
|
AccessModifier am =
|
||||||
(varDef->isConst ? (varDef->isPublic ? AccessModifier::PublicConst : AccessModifier::Const) :
|
(varDef->isConst ? (varDef->isPublic ? AccessModifier::PublicConst : AccessModifier::Const) :
|
||||||
(varDef->isPublic ? AccessModifier::Public : AccessModifier::Normal));
|
(varDef->isPublic ? AccessModifier::Public : AccessModifier::Normal));
|
||||||
@@ -185,31 +189,23 @@ namespace Fig
|
|||||||
ObjectPtr itf_val = check_unwrap_stres(eval(exp, ctx));
|
ObjectPtr itf_val = check_unwrap_stres(eval(exp, ctx));
|
||||||
if (!itf_val->is<InterfaceType>())
|
if (!itf_val->is<InterfaceType>())
|
||||||
{
|
{
|
||||||
throw EvaluatorError(
|
throw EvaluatorError(u8"TypeError",
|
||||||
u8"TypeError",
|
std::format("Cannot bundle type '{}' that is not interface",
|
||||||
std::format(
|
prettyType(itf_val).toBasicString()),
|
||||||
"Cannot bundle type '{}' that is not interface",
|
exp);
|
||||||
prettyType(itf_val).toBasicString()
|
|
||||||
),
|
|
||||||
exp
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const InterfaceType &itfType = itf_val->as<InterfaceType>();
|
const InterfaceType &itfType = itf_val->as<InterfaceType>();
|
||||||
for (const auto &method : itfType.methods)
|
for (const auto &method : itfType.methods)
|
||||||
{
|
{
|
||||||
if (cache_methods.contains(method.name))
|
if (cache_methods.contains(method.name))
|
||||||
{
|
{
|
||||||
throw EvaluatorError(
|
throw EvaluatorError(u8"DuplicateInterfaceMethodError",
|
||||||
u8"DuplicateInterfaceMethodError",
|
std::format("Interface `{}` has duplicate method '{}' with '{}.{}'",
|
||||||
std::format(
|
itfType.type.toString().toBasicString(),
|
||||||
"Interface `{}` has duplicate method '{}' with '{}.{}'",
|
method.name.toBasicString(),
|
||||||
itfType.type.toString().toBasicString(),
|
cache_methods[method.name].toBasicString(),
|
||||||
method.name.toBasicString(),
|
method.name.toBasicString()),
|
||||||
cache_methods[method.name].toBasicString(),
|
ifd);
|
||||||
method.name.toBasicString()
|
|
||||||
),
|
|
||||||
ifd
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
cache_methods[method.name] = itfType.type.toString();
|
cache_methods[method.name] = itfType.type.toString();
|
||||||
bundle_methods.push_back(method);
|
bundle_methods.push_back(method);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace Fig
|
|||||||
while (hasNext())
|
while (hasNext())
|
||||||
{
|
{
|
||||||
UTF8Char c = *it;
|
UTF8Char c = *it;
|
||||||
if (c == U'"' || c == U'\n')
|
if (c == U'"')
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
unterminated = false;
|
unterminated = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user