Skip to content

Commit 1ca7f6b

Browse files
committed
remove chemical_dir_module, make it extension function
1 parent 62e91e2 commit 1ca7f6b

File tree

5 files changed

+7
-23
lines changed

5 files changed

+7
-23
lines changed

compiler/cbi/bindings/BuildContextCBI.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ LabModule* BuildContextfiles_module(LabBuildContext* self, chem::string_view* sc
4646
return self->files_module(*scope_name, *name, path, path_len, dependencies->ptr, dependencies->size);
4747
}
4848

49-
LabModule* BuildContextchemical_dir_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view* path, ModuleSpan* dependencies) {
50-
return self->chemical_dir_module(*scope_name, *name, path, dependencies->ptr, dependencies->size);
51-
}
52-
5349
LabModule* BuildContextc_file_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view* path, ModuleSpan* dependencies) {
5450
return self->c_file_module(*scope_name, *name, path, dependencies->ptr, dependencies->size);
5551
}

compiler/cbi/bindings/BuildContextCBI.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ extern "C" {
9797

9898
LabModule* BuildContextfiles_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view** path, unsigned int path_len, ModuleSpan* dependencies);
9999

100-
LabModule* BuildContextchemical_dir_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view* path, ModuleSpan* dependencies);
101-
102100
LabModule* BuildContextc_file_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view* path, ModuleSpan* dependencies);
103101

104102
LabModule* BuildContextcpp_file_module(LabBuildContext* self, chem::string_view* scope_name, chem::string_view* name, chem::string_view* path, ModuleSpan* dependencies);

compiler/cbi/bindings/CBI.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const std::pair<chem::string_view, void*> BuildContextSymMap[] = {
2929
{ "lab_BuildContextadd_path", (void*) BuildContextadd_path },
3030
{ "lab_BuildContextadd_module", (void*) BuildContextadd_module },
3131
{ "lab_BuildContextfiles_module", (void*) BuildContextfiles_module },
32-
{ "lab_BuildContextchemical_dir_module", (void*) BuildContextchemical_dir_module },
3332
{ "lab_BuildContextc_file_module", (void*) BuildContextc_file_module },
3433
{ "lab_BuildContextcpp_file_module", (void*) BuildContextcpp_file_module },
3534
{ "lab_BuildContextobject_module", (void*) BuildContextobject_module },

compiler/lab/LabBuildContext.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,6 @@ class LabBuildContext : public BasicBuildContext {
277277
return add_with_type(LabModuleType::Directory, scope_name, module_name, nullptr, 0, dependencies, dep_len);
278278
}
279279

280-
/**
281-
* add the given module as a directory module
282-
*/
283-
LabModule* chemical_dir_module(
284-
const chem::string_view& scope_name,
285-
const chem::string_view& module_name,
286-
chem::string_view* path,
287-
LabModule** dependencies,
288-
unsigned int dep_len
289-
) {
290-
return add_with_type(LabModuleType::Directory, scope_name, module_name, &path, 1, dependencies, dep_len);
291-
}
292-
293280
/**
294281
* add the given module as a c translation unit
295282
*/

lang/libs/lab/src/lab.ch

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ public interface BuildContext {
120120
// support's paths with .o, .c and .ch extensions
121121
func files_module (&self, scope_name : &std::string_view, name : &std::string_view, paths : **std::string_view, paths_len : uint, dependencies : std::span<*Module>) : *mut Module;
122122

123-
// directory module
124-
func chemical_dir_module (&self, scope_name : &std::string_view, name : &std::string_view, path : &std::string_view, dependencies : std::span<*Module>) : *mut Module
125-
126123
// a single .c file
127124
func c_file_module (&self, scope_name : &std::string_view, name : &std::string_view, path : &std::string_view, dependencies : std::span<*Module>) : *mut Module
128125

@@ -223,6 +220,13 @@ public interface BuildContext {
223220

224221
}
225222

223+
// directory module
224+
public func (ctx : &BuildContext) chemical_dir_module (scope_name : &std::string_view, name : &std::string_view, path : &std::string_view, dependencies : std::span<*Module>) : *mut Module {
225+
const mod = ctx.new_module(scope_name, name, dependencies);
226+
ctx.add_path(mod, path);
227+
return mod;
228+
}
229+
226230
public struct ImportSymbol {
227231
var parts : std::span<std::string_view>;
228232
var alias : std::string_view;

0 commit comments

Comments
 (0)