Rename the frontend binary name to gelna

This commit is contained in:
Eugen Wissner 2025-01-11 23:20:23 +01:00
parent 0fcf29c17e
commit 7985704981
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
3 changed files with 57 additions and 34 deletions

View File

@ -5,8 +5,6 @@ type
y: Int
end;
const t = 5;
proc test_string();
var s: String;
begin
@ -57,25 +55,47 @@ begin
writei(r.y)
end;
var x_1: Int, y: Bool, z: Float, c: Char;
proc test_primitive();
var c: Char, z: Float;
begin
z := 8.2;
x_1 := t;
y := false;
c := 'x';
z := 8.2;
if y then
z := z + 3.0
else
z := z + 2.0;
writei(z);
writei(x_1);
writei("");
writei("Test primitives:");
writei(c);
writei(z)
end;
proc test_const();
const t = 5;
var x_1: Int;
begin
x_1 := t;
writei("");
writei("Test const:");
writei(x_1)
end;
proc test_if();
var y: Bool;
begin
y := false;
writei("");
if y then
writei("Test if: True")
else
writei("Test if: False")
end;
begin
test_primitive();
test_string();
test_array();
test_pointer();
test_record()
test_record();
test_const();
test_if()
end.

View File

@ -1,5 +1,5 @@
GCCELNA_INSTALL_NAME := $(shell echo gccelna|sed '$(program_transform_name)')
GCCELNA_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccelna|sed '$(program_transform_name)')
ELNA_INSTALL_NAME := $(shell echo gelna|sed '$(program_transform_name)')
ELNA_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gelna|sed '$(program_transform_name)')
elna: elna1$(exeext)
@ -7,14 +7,14 @@ elna: elna1$(exeext)
# Driver
GCCELNA_OBJS = \
ELNA_OBJS = \
$(GCC_OBJS) \
elna/elna-spec.o \
$(END)
gccelna$(exeext): $(GCCELNA_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
gelna$(exeext): $(ELNA_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(GCCELNA_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
$(ELNA_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
$(EXTRA_GCC_LIBS) $(LIBS)
# The compiler proper
@ -39,18 +39,18 @@ elna1$(exeext): attribs.o $(elna_OBJS) $(BACKEND) $(LIBDEPS)
elna.all.cross:
elna.start.encap: gccelna$(exeext)
elna.start.encap: gelna$(exeext)
elna.rest.encap:
# No elna-specific selftests.
selftest-elna:
elna.install-common: installdirs
-rm -f $(DESTDIR)$(bindir)/$(GCCELNA_INSTALL_NAME)$(exeext)
$(INSTALL_PROGRAM) gccelna$(exeext) $(DESTDIR)$(bindir)/$(GCCELNA_INSTALL_NAME)$(exeext)
rm -f $(DESTDIR)$(bindir)/$(GCCELNA_TARGET_INSTALL_NAME)$(exeext); \
-rm -f $(DESTDIR)$(bindir)/$(ELNA_INSTALL_NAME)$(exeext)
$(INSTALL_PROGRAM) gelna$(exeext) $(DESTDIR)$(bindir)/$(ELNA_INSTALL_NAME)$(exeext)
rm -f $(DESTDIR)$(bindir)/$(ELNA_TARGET_INSTALL_NAME)$(exeext); \
( cd $(DESTDIR)$(bindir) && \
$(LN) $(GCCELNA_INSTALL_NAME)$(exeext) $(GCCELNA_TARGET_INSTALL_NAME)$(exeext) ); \
$(LN) $(ELNA_INSTALL_NAME)$(exeext) $(ELNA_TARGET_INSTALL_NAME)$(exeext) ); \
# Required goals, they still do nothing
elna.install-man:
@ -70,7 +70,7 @@ elna.maintainer-clean:
# make uninstall
elna.uninstall:
-rm -f gccelna$(exeext) elna1$(exeext)
-rm -f gelna$(exeext) elna1$(exeext)
-rm -f $(elna_OBJS)
# Used for handling bootstrap

View File

@ -17,6 +17,8 @@ namespace gcc
{
void generic_visitor::visit(source::call_statement *statement)
{
auto symbol = this->symbol_map.find(statement->name());
if (statement->name() == "writei")
{
if (statement->arguments().size() != 1)
@ -78,23 +80,21 @@ namespace gcc
append_to_statement_list(stmt, &this->current_statements);
this->current_expression = NULL_TREE;
}
else
else if (symbol != this->symbol_map.end())
{
tree fndecl_type = build_function_type_list(integer_type_node, NULL_TREE);
tree printf_fn_decl = build_fn_decl(statement->name().c_str(), fndecl_type);
DECL_EXTERNAL(printf_fn_decl) = 1;
tree printf_fn = build1(ADDR_EXPR, build_pointer_type(fndecl_type), printf_fn_decl);
tree printf_fn = build1(ADDR_EXPR, build_pointer_type(fndecl_type), symbol->second);
tree stmt = build_call_nary(integer_type_node, printf_fn, 0);
append_to_statement_list(stmt, &this->current_statements);
this->current_expression = NULL_TREE;
/*
}
else
{
error_at(get_location(&statement->position()),
"procedure '%s' not declared",
statement->name().c_str()); */
statement->name().c_str());
}
}
@ -152,6 +152,9 @@ namespace gcc
tree declaration_type = build_function_type_array(void_type_node,
definition->parameters().size(), parameter_types);
this->main_fndecl = build_fn_decl(definition->identifier().c_str(), declaration_type);
this->symbol_map.insert({ definition->identifier(), this->main_fndecl });
tree resdecl = build_decl(UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, integer_type_node);
DECL_CONTEXT(resdecl) = this->main_fndecl;
DECL_RESULT(this->main_fndecl) = resdecl;