aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gcc/elna-generic.cc27
-rw-r--r--include/elna/gcc/elna-generic.h2
-rw-r--r--source/lexer.elna6
-rw-r--r--source/main.elna12
-rw-r--r--testsuite/runnable/aggregate_argument.elna2
-rw-r--r--testsuite/runnable/aggregate_equality.elna2
-rw-r--r--testsuite/runnable/return_aggregate.elna4
7 files changed, 28 insertions, 27 deletions
diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc
index 0516f5a..ae04be9 100644
--- a/gcc/gcc/elna-generic.cc
+++ b/gcc/gcc/elna-generic.cc
@@ -60,20 +60,6 @@ namespace elna::gcc
procedure_address, vec_safe_length(argument_trees), vec_safe_address(argument_trees));
}
- void generic_visitor::build_record_call(location_t, tree symbol,
- const std::vector<boot::expression *>& arguments)
- {
- vec<constructor_elt, va_gc> *tree_arguments = nullptr;
- tree record_fields = TYPE_FIELDS(symbol);
- for (boot::expression *const argument : arguments)
- {
- argument->accept(this);
- CONSTRUCTOR_APPEND_ELT(tree_arguments, record_fields, this->current_expression);
- record_fields = TREE_CHAIN(record_fields);
- }
- this->current_expression = build_constructor(symbol, tree_arguments);
- }
-
void generic_visitor::build_assert_builtin(location_t call_location,
const std::vector<boot::expression *>& arguments)
{
@@ -139,9 +125,16 @@ namespace elna::gcc
? this->current_expression
: TREE_TYPE(this->current_expression);
- if (TREE_CODE(expression_type) == RECORD_TYPE)
+ if (TREE_CODE(expression_type) == RECORD_TYPE
+ && TYPE_NAME(expression_type) == get_identifier("String"))
{
- build_record_call(call_location, expression_type, call->arguments);
+ vec<constructor_elt, va_gc> *elms = nullptr;
+
+ call->arguments.at(0)->accept(this);
+ CONSTRUCTOR_APPEND_ELT(elms, elna_string_ptr_field_node, this->current_expression);
+ call->arguments.at(1)->accept(this);
+ CONSTRUCTOR_APPEND_ELT(elms, elna_string_length_field_node, this->current_expression);
+ this->current_expression = build_constructor(elna_string_type_node, elms);
}
else if (TREE_CODE(expression_type) == FUNCTION_TYPE)
{
@@ -155,7 +148,7 @@ namespace elna::gcc
}
else
{
- error_at(call_location, "'%s' cannot be called, it is neither a procedure nor record",
+ error_at(call_location, "'%s' cannot be called, it is not a procedure",
print_type(expression_type).c_str());
this->current_expression = error_mark_node;
}
diff --git a/include/elna/gcc/elna-generic.h b/include/elna/gcc/elna-generic.h
index 2a1425c..9dea83b 100644
--- a/include/elna/gcc/elna-generic.h
+++ b/include/elna/gcc/elna-generic.h
@@ -51,8 +51,6 @@ namespace elna::gcc
tree build_equality_operation(boot::binary_expression *expression, tree left, tree right);
void build_procedure_call(location_t call_location,
tree procedure_address, const std::vector<boot::expression *>& arguments);
- void build_record_call(location_t call_location,
- tree symbol, const std::vector<boot::expression *>& arguments);
bool build_builtin_procedures(boot::procedure_call *call);
void build_assert_builtin(location_t call_location, const std::vector<boot::expression *>& arguments);
diff --git a/source/lexer.elna b/source/lexer.elna
index c221f07..9e1db21 100644
--- a/source/lexer.elna
+++ b/source/lexer.elna
@@ -100,6 +100,8 @@ type
right_paren,
left_square,
right_square,
+ left_brace,
+ right_brace,
greater_equal,
less_equal,
greater_than,
@@ -756,8 +758,8 @@ begin
cursor^.start := code_pointer;
cursor^.finish := code_pointer;
cursor^.token := nil;
- cursor^.position.start_location := ElnaLocation(1u, 1u);
- cursor^.position.end_location := ElnaLocation(1u, 1u)
+ cursor^.position.start_location := ElnaLocation{ line: 1u, column: 1u };
+ cursor^.position.end_location := ElnaLocation{ line: 1u, column: 1u }
return
(**
diff --git a/source/main.elna b/source/main.elna
index fdfc49f..8f0250b 100644
--- a/source/main.elna
+++ b/source/main.elna
@@ -445,6 +445,14 @@ begin
current_token := malloc(#size(ElnaLexerToken));
current_token^.kind := ElnaLexerKind.right_paren;
source_code_advance(@source_code)
+ elsif first_char = '{' then
+ current_token := malloc(#size(ElnaLexerToken));
+ current_token^.kind := ElnaLexerKind.left_brace;
+ source_code_advance(@source_code)
+ elsif first_char = '}' then
+ current_token := malloc(#size(ElnaLexerToken));
+ current_token^.kind := ElnaLexerKind.right_brace;
+ source_code_advance(@source_code)
elsif first_char = '\'' then
source_code_advance(@source_code);
@@ -585,7 +593,7 @@ var
token_buffer: StringBuffer
lexer: Tokenizer
begin
- lexer := Tokenizer(0u, nil);
+ lexer := Tokenizer{ length: 0u, data: nil };
token_buffer := string_buffer_new();
lexer_spaces(@source_code);
@@ -801,7 +809,7 @@ begin
fclose(source_file^.handle)
end;
- source_code.position := ElnaLocation(1u, 1u);
+ source_code.position := ElnaLocation{line: 1u, column: 1u};
source_code.input := source_file;
source_code.empty := source_file_empty;
source_code.head := source_file_head;
diff --git a/testsuite/runnable/aggregate_argument.elna b/testsuite/runnable/aggregate_argument.elna
index 89059db..4a36c74 100644
--- a/testsuite/runnable/aggregate_argument.elna
+++ b/testsuite/runnable/aggregate_argument.elna
@@ -8,5 +8,5 @@ proc f(r: R): Bool
return r.a = 1 & r.b = 2
begin
- assert(f(R(1, 2)))
+ assert(f(R{a: 1, b: 2}))
end.
diff --git a/testsuite/runnable/aggregate_equality.elna b/testsuite/runnable/aggregate_equality.elna
index 9cd9ab5..592d411 100644
--- a/testsuite/runnable/aggregate_equality.elna
+++ b/testsuite/runnable/aggregate_equality.elna
@@ -5,7 +5,7 @@ type
end
proc f(): Bool
-return R(1, 2) = R(1, 2)
+return R{a: 1, b: 2} = R{a: 1, b: 2}
begin
assert(f())
diff --git a/testsuite/runnable/return_aggregate.elna b/testsuite/runnable/return_aggregate.elna
index 820f72f..e162498 100644
--- a/testsuite/runnable/return_aggregate.elna
+++ b/testsuite/runnable/return_aggregate.elna
@@ -5,8 +5,8 @@ type
end
proc f(): R
-return R(1, 2)
+return R{a: 1, b: 2}
begin
- assert(f() = R(1, 2))
+ assert(f() = R{a: 1, b: 2})
end.