Commit 196fadba authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

Framework extended to remember line numbers of every definition (dumped within table dump).

The public interfaces of CKStructItem and CKFunctionFormalPack have changed.
The gold files will need to change.
parent b25ffb7f
......@@ -49,7 +49,7 @@ namespace cecko {
else
r.put(ch);
}
return r.str();
return std::move(r).str();
}
void context::message(errors::err_s err, loc_t loc, std::string_view msg)
......
#include "cktables.hpp"
#include <sstream>
namespace cecko {
// DECLARATION GENERATOR
......@@ -17,6 +18,20 @@ namespace cecko {
: " " + dtor);
}
std::string generate_dump_name(const CIName& n, loc_t def_loc)
{
std::ostringstream oss;
oss << n;
oss << "_" << def_loc;
return std::move(oss).str();
}
std::string CINamePtr::get_dump_name() const
{
assert(!!name_ptr_);
return generate_dump_name(*name_ptr_, def_loc_);
}
CIDecl CKVoidType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "void" + decl_dtor(false, false, dtor); }
CIDecl CKBoolType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "_Bool" + decl_dtor(false, false, dtor); }
......@@ -29,7 +44,7 @@ namespace cecko {
CIDecl CKArrayType::declaration(bool is_const, const CIDecl& dtor) const { return element_type_->declaration(is_const, decl_dtor(true, true, dtor) + "[" + std::to_string(size_->getValue().getZExtValue()) + "]"); }
CIDecl CKStructType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "struct " + get_name() + decl_dtor(false, false, dtor); }
CIDecl CKStructType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "struct " + get_dump_name() + decl_dtor(false, false, dtor); }
void CKStructType::finalize(const CKStructItemArray& items)
{
......@@ -39,7 +54,7 @@ namespace cecko {
for (auto&& a : items)
{
elements_ir.push_back(a.pack.type->get_ir());
auto p = elements_.try_emplace(a.name, a.pack, idx);
auto p = elements_.try_emplace(a.name, a.pack, idx, a.loc);
elements_ordered_.push_back(p);
++idx;
}
......@@ -51,14 +66,14 @@ namespace cecko {
{
if (defined_)
{
os << indent << "struct " << get_name() << "{" << CIEndl;
os << indent << "struct " << get_dump_name() << "{" << CIEndl;
for (auto&& a : elements_ordered_)
os << indent << "\t" << a->get_type_pack().type->declaration(a->get_type_pack().is_const, a->get_name()) << ";" << CIEndl;
os << indent << "\t" << a->get_type_pack().type->declaration(a->get_type_pack().is_const, a->get_dump_name()) << ";" << CIEndl;
os << indent << "};" << CIEndl;
}
}
CIDecl CKEnumType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "enum " + get_name() + decl_dtor(false, false, dtor); }
CIDecl CKEnumType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "enum " + get_dump_name() + decl_dtor(false, false, dtor); }
void CKEnumType::finalize(CKConstantObsVector items)
{
......@@ -71,7 +86,7 @@ namespace cecko {
{
if (defined_)
{
os << indent << "enum " << get_name();
os << indent << "enum " << get_dump_name();
std::string delim = "{";
for (auto&& a : elements_ordered_)
{
......@@ -153,7 +168,7 @@ namespace cecko {
std::string CKConstant::declaration() const
{
return get_name() + "=" + std::to_string(value_->getValue().getZExtValue());
return get_dump_name() + "=" + std::to_string(value_->getValue().getZExtValue());
}
CKLocalTableObs CKAbstractScope::get_local()
......@@ -161,33 +176,33 @@ namespace cecko {
return nullptr;
}
CKTypedefConstObs CKUniversalTable::declare_typedef(const std::string& name, const CKTypeRefPack& type_pack)
CKTypedefConstObs CKUniversalTable::declare_typedef(const std::string& name, const CKTypeRefPack& type_pack, loc_t def_loc)
{
return typedefs_.try_emplace(name, type_pack);
return typedefs_.try_emplace(name, type_pack, def_loc);
}
CKConstantConstObs CKUniversalTable::declare_constant(const std::string& name, CKTypeObs type, CKIRConstantIntObs value)
CKConstantConstObs CKUniversalTable::declare_constant(const std::string& name, CKTypeObs type, CKIRConstantIntObs value, loc_t def_loc)
{
return constants_.try_emplace(name, type, value);
return constants_.try_emplace(name, type, value, def_loc);
}
CKGlobalVarObs CKGlobalTable::varDefine(CKIRModuleObs M, const std::string& name, const CKTypeRefPack& type_pack)
CKGlobalVarObs CKGlobalTable::varDefine(CKIRModuleObs M, const std::string& name, const CKTypeRefPack& type_pack, loc_t def_loc)
{
auto irtp = type_pack.type->get_ir();
auto var = CKCreateGlobalVariable(irtp, name, M);
return vars_.try_emplace(name, type_pack, var);
return vars_.try_emplace(name, type_pack, var, def_loc);
}
CKGlobalVarObs CKGlobalTable::declare_extern_variable(CKIRModuleObs M, const std::string& name, const CKTypeRefPack& type_pack)
{
auto irtp = type_pack.type->get_ir();
auto var = CKCreateExternVariable(irtp, name, M);
return vars_.try_emplace(name, type_pack, var);
return vars_.try_emplace(name, type_pack, var, 0);
}
CKFunctionObs CKGlobalTable::declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type)
CKFunctionObs CKGlobalTable::declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type, loc_t decl_loc)
{
return fncs_.try_emplace(n, M, type, n);
return fncs_.try_emplace(n, M, type, n, decl_loc);
}
CKFunctionObs CKGlobalTable::declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type, const std::string& irname)
{
return fncs_.try_emplace(n, M, type, irname);
return fncs_.try_emplace(n, M, type, irname, 0);
}
CKFunctionObs CKGlobalTable::find_function(const CIName& n)
{
......@@ -229,12 +244,12 @@ namespace cecko {
dump_universal(os, "");
os << "// --- FUNCTION DECLARATIONS ---" << std::endl;
auto decllambda = [&os](auto&& a) {
os << a->get_type()->declaration(false, a->get_name()) << ";" << CIEndl;
os << a->get_type()->declaration(false, a->get_dump_name()) << ";" << CIEndl;
};
fncs_.for_each(decllambda);
os << "// --- GLOBAL VARIABLES ---" << std::endl;
auto varlambda = [&os](auto&& a) {
os << a->get_type()->declaration(false, a->get_name()) << ";" << CIEndl;
os << a->get_type()->declaration(false, a->get_dump_name()) << ";" << CIEndl;
};
vars_.for_each(varlambda);
os << "// --- FUNCTION DEFINITIONS ---" << std::endl;
......@@ -263,23 +278,23 @@ namespace cecko {
auto arg_ir = f_ir->args().begin() + ix;
auto var = builder.CreateAlloca(arg_type->get_ir(), nullptr, *arg_pack.name);
builder.CreateStore(arg_ir, var);
vars_.try_emplace(*arg_pack.name, CKTypeRefPack{ arg_type, arg_pack.is_const }, var, true);
vars_.try_emplace(*arg_pack.name, CKTypeRefPack{ arg_type, arg_pack.is_const }, var, arg_pack.loc, true);
}
}
}
CKLocalVarObs CKLocalTable::varDefine(CKIRBuilderRef builder, const std::string& name, const CKTypeRefPack& type_pack)
CKLocalVarObs CKLocalTable::varDefine(CKIRBuilderRef builder, const std::string& name, const CKTypeRefPack& type_pack, loc_t def_loc)
{
auto var = builder.CreateAlloca(type_pack.type->get_ir(), nullptr, name);
return vars_.try_emplace(name, type_pack, var, false);
return vars_.try_emplace(name, type_pack, var, def_loc, false);
}
CKStructTypeObs CKLocalTable::declare_struct_type(const CIName& n, CKIRContextRef Context)
CKStructTypeObs CKLocalTable::declare_struct_type(const CIName& n, CKIRContextRef Context, loc_t decl_loc)
{
auto p = find_struct_type(n);
if (p)
return p;
return declare_struct_type_here(n, Context);
return declare_struct_type_here(n, Context, decl_loc);
}
CKStructTypeObs CKLocalTable::find_struct_type(const CIName& n)
{
......@@ -288,12 +303,12 @@ namespace cecko {
return p;
return parent_scope_->find_struct_type(n);
}
CKEnumTypeObs CKLocalTable::declare_enum_type(const CIName& n, CKTypeObs base_type)
CKEnumTypeObs CKLocalTable::declare_enum_type(const CIName& n, CKTypeObs base_type, loc_t decl_loc)
{
auto p = find_enum_type(n);
if (p)
return p;
return declare_enum_type_here(n, base_type);
return declare_enum_type_here(n, base_type, decl_loc);
}
CKEnumTypeObs CKLocalTable::find_enum_type(const CIName& n)
{
......@@ -347,7 +362,7 @@ namespace cecko {
a->dump(os, indent);
});
auto typedeflambda = [&os, &indent](auto&& a) {
os << indent << "typedef " << a->get_type_pack().type->declaration(a->get_type_pack().is_const, a->get_name()) << ";" << CIEndl;
os << indent << "typedef " << a->get_type_pack().type->declaration(a->get_type_pack().is_const, a->get_dump_name()) << ";" << CIEndl;
};
typedefs_.for_each(typedeflambda);
}
......@@ -392,12 +407,12 @@ namespace cecko {
auto&& arg_pack = get_formal_pack(ix);
if (!args.empty())
args += ",";
args += arg_type->declaration(arg_pack.is_const, !!arg_pack.name ? *arg_pack.name : std::string{});
args += arg_type->declaration(arg_pack.is_const, !!arg_pack.name ? generate_dump_name(*arg_pack.name, arg_pack.loc) : std::string{});
}
if (args.empty())
args += "void";
}
os << f_type->get_function_return_type()->declaration(false, get_name() + "(" + args + ")") << "{" << CIEndl;
os << f_type->get_function_return_type()->declaration(false, get_dump_name() + "(" + args + ")") << "{" << CIEndl;
loctab_->dump(os, "\t");
......@@ -406,12 +421,12 @@ namespace cecko {
void CKTypedef::dump(CIOStream& os) const
{
os << "\ttypedef " << get_type_pack().type->declaration(get_type_pack().is_const, get_name()) << ";" << CIEndl;
os << "\ttypedef " << get_type_pack().type->declaration(get_type_pack().is_const, get_dump_name()) << ";" << CIEndl;
}
void CKVar::dump(CIOStream& os, const std::string& indent) const
{
os << indent << get_type()->declaration(is_const(), get_name()) << ";" << CIEndl;
os << indent << get_type()->declaration(is_const(), get_dump_name()) << ";" << CIEndl;
}
// CONTEXT
......@@ -492,23 +507,26 @@ namespace cecko {
{
if (!!loctable_)
{
return loctable_->declare_struct_type(n, module_->getContext());
return loctable_->declare_struct_type(n, module_->getContext(), loc);
}
else
{
return globtable_->declare_struct_type(n, module_->getContext());
return globtable_->declare_struct_type(n, module_->getContext(), loc);
}
}
CKStructTypeObs CKContext::define_struct_type_open(const CIName& n, loc_t loc)
{
CKStructTypeObs tp;
if (!!loctable_)
{
return loctable_->declare_struct_type_here(n, module_->getContext());
tp = loctable_->declare_struct_type_here(n, module_->getContext(), loc);
}
else
{
return globtable_->declare_struct_type_here(n, module_->getContext());
tp = globtable_->declare_struct_type_here(n, module_->getContext(), loc);
}
tp->set_def_loc(loc); // !!! DUPLICITE DEFINITION ???
return tp;
}
void CKContext::define_struct_type_close(CKStructTypeObs type, const CKStructItemArray& items)
{
......@@ -517,24 +535,27 @@ namespace cecko {
CKEnumTypeObs CKContext::declare_enum_type(const CIName& n, loc_t loc)
{
CKEnumTypeObs tp;
if (!!loctable_)
{
return loctable_->declare_enum_type(n, get_int_type());
tp = loctable_->declare_enum_type(n, get_int_type(), loc);
}
else
{
return globtable_->declare_enum_type(n, get_int_type());
tp = globtable_->declare_enum_type(n, get_int_type(), loc);
}
tp->set_def_loc(loc); // !!! DUPLICITE DEFINITION ???
return tp;
}
CKEnumTypeObs CKContext::define_enum_type_open(const CIName& n, loc_t loc)
{
if (!!loctable_)
{
return loctable_->declare_enum_type_here(n, get_int_type());
return loctable_->declare_enum_type_here(n, get_int_type(), loc);
}
else
{
return globtable_->declare_enum_type_here(n, get_int_type());
return globtable_->declare_enum_type_here(n, get_int_type(), loc);
}
}
void CKContext::define_enum_type_close(CKEnumTypeObs type, CKConstantObsVector items)
......@@ -546,33 +567,33 @@ namespace cecko {
{
if (!!loctable_)
{
return loctable_->declare_typedef(name, type_pack);
return loctable_->declare_typedef(name, type_pack, loc);
}
else
{
return globtable_->declare_typedef(name, type_pack);
return globtable_->declare_typedef(name, type_pack, loc);
}
}
CKConstantConstObs CKContext::define_constant(const std::string& name, CKIRConstantIntObs value, loc_t loc)
{
if (!!loctable_)
{
return loctable_->declare_constant(name, get_int_type(), value);
return loctable_->declare_constant(name, get_int_type(), value, loc);
}
else
{
return globtable_->declare_constant(name, get_int_type(), value);
return globtable_->declare_constant(name, get_int_type(), value, loc);
}
}
void CKContext::define_var(const std::string& name, const CKTypeRefPack& type_pack, loc_t loc)
{
if (!!loctable_)
{
loctable_->varDefine(alloca_builder_, name, type_pack);
loctable_->varDefine(alloca_builder_, name, type_pack, loc);
}
else
{
globtable_->varDefine(module_, name, type_pack);
globtable_->varDefine(module_, name, type_pack, loc);
}
}
CKNamedObs CKContext::find(const CIName& n)
......@@ -621,9 +642,9 @@ namespace cecko {
auto t_ptr_char = typetable_.get_pointer_type({ t_char, false });
auto t_cptr_char = typetable_.get_pointer_type({ t_char, true });
auto t_file_s = globtable_.declare_struct_type("_file_s", module_->getContext());
auto t_file_s = globtable_.declare_struct_type("_file_s", module_->getContext(), 0);
globtable_.declare_typedef("FILE", { t_file_s, false });
globtable_.declare_typedef("FILE", { t_file_s, false }, 0);
globtable_.declare_function("printf", module_, typetable_.get_function_type(t_int, { t_cptr_char }, true), "ckrt_printf");
globtable_.declare_function("scanf", module_, typetable_.get_function_type(t_int, { t_cptr_char }, true), "ckrt_scanf");
......
......@@ -187,8 +187,8 @@ namespace cecko {
class CINamePtr {
public:
/// @cond INTERNAL
CINamePtr()
: name_ptr_(nullptr)
CINamePtr(loc_t def_loc)
: name_ptr_(nullptr), def_loc_(def_loc)
{}
/// @endcond
......@@ -198,6 +198,10 @@ namespace cecko {
assert(!!name_ptr_);
return *name_ptr_;
}
/// @cond INTERNAL
std::string get_dump_name() const;
void set_def_loc(loc_t def_loc) { def_loc_ = def_loc; }
/// @endcond
private:
void set_name_ptr(const CIName* p)
{
......@@ -205,6 +209,7 @@ namespace cecko {
}
const CIName* name_ptr_;
loc_t def_loc_;
template< typename T>
friend class CINamedStorage;
......@@ -444,8 +449,8 @@ namespace cecko {
class CKStructElement : public CINamePtr, CIImmovable {
public:
/// @cond INTERNAL
explicit CKStructElement(const CKTypeRefPack& pack, unsigned int idx)
: pack_(pack), idx_(idx)
explicit CKStructElement(const CKTypeRefPack& pack, unsigned int idx, loc_t def_loc)
: CINamePtr(def_loc), pack_(pack), idx_(idx)
{}
/// @endcond
/// The (optionally const) type of a struct element
......@@ -462,13 +467,15 @@ namespace cecko {
/// Temporary struct element descriptor
struct CKStructItem {
/// Construct from arguments
CKStructItem(const CKTypeRefPack& p, CIName nm)
: pack(p), name(std::move(nm))
CKStructItem(const CKTypeRefPack& p, CIName nm, loc_t l)
: pack(p), name(std::move(nm)), loc(l)
{}
/// The (optionally const) type of a struct element
CKTypeRefPack pack;
/// Name of a struct element
CIName name;
/// Definition line number
loc_t loc;
};
/// A temporary array of struct element descriptors
......@@ -478,8 +485,8 @@ namespace cecko {
class CKStructType : public CIAbstractType, public CINamePtr {
public:
/// @cond INTERNAL
CKStructType(CKIRContextRef Context, const CIName& n)
: defined_(false), irt_(CKCreateStructType(Context, n))
CKStructType(CKIRContextRef Context, const CIName& n, loc_t decl_loc)
: CINamePtr(0), decl_loc_(decl_loc), defined_(false), irt_(CKCreateStructType(Context, n))
{}
void finalize(const CKStructItemArray& items);
......@@ -504,6 +511,7 @@ namespace cecko {
/// @endcond
private:
using element_storage_type = CINamedStorage< CKStructElement>;
loc_t decl_loc_;
bool defined_;
element_storage_type elements_;
std::vector< CKStructElementObs> elements_ordered_;
......@@ -522,8 +530,8 @@ namespace cecko {
class CKEnumType : public CIAbstractType, public CINamePtr {
public:
/// @cond INTERNAL
CKEnumType(CKTypeObs base_type)
: defined_(false), base_type_(base_type)
CKEnumType(CKTypeObs base_type, loc_t decl_loc)
: CINamePtr(0), decl_loc_(decl_loc), defined_(false), base_type_(base_type)
{}
void finalize(CKConstantObsVector items);
......@@ -541,6 +549,7 @@ namespace cecko {
void dump(CIOStream& os, const std::string& indent) const;
/// @endcond
private:
loc_t decl_loc_;
bool defined_;
CKTypeObs base_type_;
CKConstantObsVector elements_ordered_;
......@@ -625,6 +634,9 @@ namespace cecko {
class CKAbstractNamed : public CINamePtr, CIImmovable {
public:
/// @cond INTERNAL
CKAbstractNamed(loc_t def_loc)
: CINamePtr(def_loc)
{}
virtual ~CKAbstractNamed() {}
/// @endcond
/// @name Determining the kind of the object
......@@ -665,8 +677,8 @@ namespace cecko {
class CKTypedef : public CINamePtr, CIImmovable {
public:
/// @cond INTERNAL
CKTypedef(CKTypeRefPack type_pack)
: type_pack_(type_pack)
CKTypedef(CKTypeRefPack type_pack, loc_t def_loc)
: CINamePtr(def_loc), type_pack_(type_pack)
{}
/// @endcond
//virtual bool is_typedef() const { return true; }
......@@ -690,8 +702,8 @@ namespace cecko {
class CKConstant : public CKAbstractNamed {
public:
/// @cond INTERNAL
CKConstant(CKTypeObs type, CKIRConstantIntObs value)
: type_pack_(type, true), value_(value)
CKConstant(CKTypeObs type, CKIRConstantIntObs value, loc_t def_loc)
: CKAbstractNamed(def_loc), type_pack_(type, true), value_(value)
{}
virtual bool is_constant() const override { return true; }
virtual CKTypeObs get_type() const override { return type_pack_.type; }
......@@ -714,8 +726,8 @@ namespace cecko {
class CKVar : public CKAbstractNamed {
public:
/// @cond INTERNAL
CKVar(CKTypeRefPack type_pack)
: type_pack_(type_pack)
CKVar(CKTypeRefPack type_pack, loc_t def_loc)
: CKAbstractNamed(def_loc), type_pack_(type_pack)
{}
/// @endcond
virtual bool is_var() const { return true; }
......@@ -733,8 +745,8 @@ namespace cecko {
class CKGlobalVar : public CKVar {
public:
/// @cond INTERNAL
CKGlobalVar(CKTypeRefPack type_pack, CKIRConstantObs address)
: CKVar(type_pack), address_(address)
CKGlobalVar(CKTypeRefPack type_pack, CKIRConstantObs address, loc_t def_loc)
: CKVar(type_pack, def_loc), address_(address)
{}
virtual CKIRValueObs get_ir() const { return address_; }
CKIRConstantObs get_address() const { return address_; }
......@@ -753,13 +765,15 @@ namespace cecko {
/// Temporary additional function argument descriptor
struct CKFunctionFormalPack {
/// Construct from arguments
CKFunctionFormalPack(CINameOpt nm, bool c)
: name(std::move(nm)), is_const(c)
CKFunctionFormalPack(CINameOpt nm, bool c, loc_t loc)
: name(std::move(nm)), is_const(c), loc( loc)
{}
/// Optional name of the argument
CINameOpt name;
/// Optional "const" flag
bool is_const;
/// Definition line number
loc_t loc;
};
/// @cond INTERNAL
......@@ -788,8 +802,8 @@ namespace cecko {
class CKFunction : public CKAbstractNamed {
public:
/// @cond INTERNAL
CKFunction(CKIRModuleObs M, CKFunctionTypeObs type, const CIName& irname)
: type_(type), irf_(CKCreateFunction(type->get_function_ir(), irname, M))
CKFunction(CKIRModuleObs M, CKFunctionTypeObs type, const CIName& irname, loc_t def_loc)
: CKAbstractNamed(def_loc), type_(type), irf_(CKCreateFunction(type->get_function_ir(), irname, M))
{}
virtual bool is_function() const override { return true; }
......@@ -814,18 +828,18 @@ namespace cecko {
/// @cond INTERNAL
class CKUniversalTable : public CKAbstractScope {
public:
CKStructTypeObs declare_struct_type_here(const CIName& n, CKIRContextRef Context)
CKStructTypeObs declare_struct_type_here(const CIName& n, CKIRContextRef Context, loc_t decl_loc)
{
return strts_.try_emplace(n, Context, n);
return strts_.try_emplace(n, Context, n, decl_loc);
}
CKStructTypeObs find_struct_type_here(const CIName& n) { return strts_.find(n); }
CKEnumTypeObs declare_enum_type_here(const CIName& n, CKTypeObs base_type)
CKEnumTypeObs declare_enum_type_here(const CIName& n, CKTypeObs base_type, loc_t decl_loc)
{
return enmts_.try_emplace(n, base_type);
return enmts_.try_emplace(n, base_type, decl_loc);
}
CKEnumTypeObs find_enum_type_here(const CIName& n) { return enmts_.find(n); }
CKTypedefConstObs declare_typedef(const CIName& name, const CKTypeRefPack& type_pack);
CKConstantConstObs declare_constant(const CIName& name, CKTypeObs type, CKIRConstantIntObs value);
CKTypedefConstObs declare_typedef(const CIName& name, const CKTypeRefPack& type_pack, loc_t def_loc);
CKConstantConstObs declare_constant(const CIName& name, CKTypeObs type, CKIRConstantIntObs value, loc_t def_loc);
CKTypedefConstObs find_typedef_here(const CIName& n) const;
CKNamedObs find_constant_here(const CIName& n);
void dump_universal(CIOStream& os, const std::string& indent) const;
......@@ -847,19 +861,19 @@ namespace cecko {
public:
CKGlobalTable()
{}
CKGlobalVarObs varDefine(CKIRModuleObs M, const CIName& name, const CKTypeRefPack& type_pack);
CKGlobalVarObs varDefine(CKIRModuleObs M, const CIName& name, const CKTypeRefPack& type_pack, loc_t def_loc);
CKGlobalVarObs declare_extern_variable(CKIRModuleObs M, const CIName& name, const CKTypeRefPack& type_pack);
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context)
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context, loc_t decl_loc)
{
return declare_struct_type_here(n, Context);
return declare_struct_type_here(n, Context, decl_loc);
}
virtual CKStructTypeObs find_struct_type(const CIName& n) override { return find_struct_type_here(n); }
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type)
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type, loc_t decl_loc)
{
return declare_enum_type_here(n, base_type);
return declare_enum_type_here(n, base_type, decl_loc);
}
virtual CKEnumTypeObs find_enum_type(const CIName& n) override { return find_enum_type_here(n); }
CKFunctionObs declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type);
CKFunctionObs declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type, loc_t decl_loc);
CKFunctionObs declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type, const CIName& irname);
CKFunctionObs find_function(const CIName& n);
CKFunctionConstObs find_function(const CIName& n) const;
......@@ -877,8 +891,8 @@ namespace cecko {
class CKLocalVar : public CKVar {
public:
/// @cond INTERNAL
CKLocalVar(CKTypeRefPack type_pack, CKIRAllocaInstObs address, bool is_arg = false)
: CKVar(type_pack), address_(address), is_arg_(is_arg)
CKLocalVar(CKTypeRefPack type_pack, CKIRAllocaInstObs address, loc_t def_loc, bool is_arg)
: CKVar(type_pack, def_loc), address_(address), is_arg_(is_arg)
{}
virtual CKIRValueObs get_ir() const { return address_; }
CKIRAllocaInstObs get_address() const { return address_; }
......@@ -898,14 +912,14 @@ namespace cecko {
: parent_scope_(parent)
{}
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context);
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context, loc_t decl_loc);
virtual CKStructTypeObs find_struct_type(const CIName& n) override;
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type);
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type, loc_t decl_loc);
virtual CKEnumTypeObs find_enum_type(const CIName& n) override;
void varsFromArgs(CKIRBuilderRef builder, CKFunctionObs f, const CKFunctionFormalPackArray& formal_packs);
CKLocalVarObs varDefine(CKIRBuilderRef builder, const CIName& name, const CKTypeRefPack& type_pack);
CKLocalVarObs varDefine(CKIRBuilderRef builder, const CIName& name, const CKTypeRefPack& type_pack, loc_t def_loc);
virtual CKTypedefConstObs find_typedef(const CIName& n) const;
virtual CKNamedObs find(const CIName& n);
......@@ -1071,7 +1085,7 @@ namespace cecko {
/// Declare a function (with or without body)
CKFunctionObs declare_function(const CIName& n, CKFunctionTypeObs type, loc_t loc)
{
return globtable_->declare_function(n, module_, type);
return globtable_->declare_function(n, module_, type, loc);
}
/// @}
......
......@@ -20,8 +20,12 @@ int main(int argc, char** argv)
struct god_str {
struct mighty_str ims_;
} gs;