Make booleans a character to 1-byte types
This commit is contained in:
+53
-99
@@ -124,7 +124,7 @@ type
|
|||||||
ElnaTreeCharacterLiteral = record
|
ElnaTreeCharacterLiteral = record
|
||||||
kind: ElnaTreeKind;
|
kind: ElnaTreeKind;
|
||||||
type_decoration: ^ElnaType;
|
type_decoration: ^ElnaType;
|
||||||
value: Word;
|
value: ^Char;
|
||||||
length: Word
|
length: Word
|
||||||
end;
|
end;
|
||||||
ElnaTreeNilLiteral = record
|
ElnaTreeNilLiteral = record
|
||||||
@@ -719,14 +719,12 @@ begin
|
|||||||
|
|
||||||
.add_string_loop;
|
.add_string_loop;
|
||||||
current_byte := _load_byte(contents);
|
current_byte := _load_byte(contents);
|
||||||
(* if current_byte <> '"' then *)
|
if current_byte <> '"' then
|
||||||
if current_byte <> 34 then
|
|
||||||
_store_byte(current_byte, compiler_strings_position);
|
_store_byte(current_byte, compiler_strings_position);
|
||||||
compiler_strings_position := compiler_strings_position + 1;
|
compiler_strings_position := compiler_strings_position + 1;
|
||||||
contents := contents + 1;
|
contents := contents + 1;
|
||||||
|
|
||||||
(* if current_byte <> '\\' then *)
|
if current_byte <> '\\' then
|
||||||
if current_byte <> 92 then
|
|
||||||
compiler_strings_length := compiler_strings_length + 1
|
compiler_strings_length := compiler_strings_length + 1
|
||||||
end;
|
end;
|
||||||
goto add_string_loop
|
goto add_string_loop
|
||||||
@@ -1566,17 +1564,14 @@ var
|
|||||||
begin
|
begin
|
||||||
operand_type := instruction^.operands[n].kind;
|
operand_type := instruction^.operands[n].kind;
|
||||||
|
|
||||||
(* _write_c(' '); *)
|
_write_c(' ');
|
||||||
_write_c(32);
|
|
||||||
if operand_type = ElnaRtlKind.register then
|
if operand_type = ElnaRtlKind.register then
|
||||||
elna_riscv_register(instruction^.operands[n].value)
|
elna_riscv_register(instruction^.operands[n].value)
|
||||||
elsif operand_type = ElnaRtlKind.memory then
|
elsif operand_type = ElnaRtlKind.memory then
|
||||||
_write_i(instruction^.operands[n].offset);
|
_write_i(instruction^.operands[n].offset);
|
||||||
(* _write_c('('); *)
|
_write_c('(');
|
||||||
_write_c(40);
|
|
||||||
elna_riscv_register(instruction^.operands[n].value);
|
elna_riscv_register(instruction^.operands[n].value);
|
||||||
(* _write_c(')') *)
|
_write_c(')')
|
||||||
_write_c(41)
|
|
||||||
elsif operand_type = ElnaRtlKind.data then
|
elsif operand_type = ElnaRtlKind.data then
|
||||||
if instruction^.operands[n].length = 0 then
|
if instruction^.operands[n].length = 0 then
|
||||||
_write_label(instruction^.operands[n].value, 0)
|
_write_label(instruction^.operands[n].value, 0)
|
||||||
@@ -1601,8 +1596,7 @@ begin
|
|||||||
if pseudo_symbol = nil then
|
if pseudo_symbol = nil then
|
||||||
goto elna_alloc_variable_end
|
goto elna_alloc_variable_end
|
||||||
end;
|
end;
|
||||||
(* pseudo_symbol^.allocated = false *)
|
if pseudo_symbol^.allocated = false then
|
||||||
if pseudo_symbol^.allocated = 0 then
|
|
||||||
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
|
if pseudo_symbol^.rtl_type^.kind = ElnaRtlTypeKind.byte_array then
|
||||||
pseudo_type := pseudo_symbol^.rtl_type;
|
pseudo_type := pseudo_symbol^.rtl_type;
|
||||||
|
|
||||||
@@ -1616,7 +1610,7 @@ begin
|
|||||||
type_size := 4
|
type_size := 4
|
||||||
end;
|
end;
|
||||||
temporary_variable_counter := pseudo_symbol^.counter + type_size;
|
temporary_variable_counter := pseudo_symbol^.counter + type_size;
|
||||||
pseudo_symbol^.allocated := 1 (* true *)
|
pseudo_symbol^.allocated := true
|
||||||
end;
|
end;
|
||||||
.elna_alloc_variable_end;
|
.elna_alloc_variable_end;
|
||||||
return pseudo_symbol
|
return pseudo_symbol
|
||||||
@@ -2598,14 +2592,11 @@ begin
|
|||||||
operator := 0;
|
operator := 0;
|
||||||
|
|
||||||
if token^.kind = ElnaLexerKind.at then
|
if token^.kind = ElnaLexerKind.at then
|
||||||
(* operator := '@' *)
|
operator := '@'
|
||||||
operator := 64
|
|
||||||
elsif token^.kind = ElnaLexerKind.minus then
|
elsif token^.kind = ElnaLexerKind.minus then
|
||||||
(* operator := '-' *)
|
operator := '-'
|
||||||
operator := 45
|
|
||||||
elsif token^.kind = ElnaLexerKind.not then
|
elsif token^.kind = ElnaLexerKind.not then
|
||||||
(* operator := '~' *)
|
operator := '~'
|
||||||
operator := 126
|
|
||||||
end;
|
end;
|
||||||
if operator <> 0 then
|
if operator <> 0 then
|
||||||
elna_lexer_read(cursor)
|
elna_lexer_read(cursor)
|
||||||
@@ -2670,20 +2661,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
elna_tac_designator(instructions, unary_operand, symbol_table, @operand_result, @base);
|
elna_tac_designator(instructions, unary_operand, symbol_table, @operand_result, @base);
|
||||||
|
|
||||||
(* if operator = '@' then *)
|
if operator = '@' then
|
||||||
if operator = 64 then
|
|
||||||
elna_tac_make_variable(operand, symbol_table, word_type);
|
elna_tac_make_variable(operand, symbol_table, word_type);
|
||||||
elna_tac_copy_address(instructions, @operand_result, @base, operand)
|
elna_tac_copy_address(instructions, @operand_result, @base, operand)
|
||||||
(* elsif operator = '-' then *)
|
elsif operator = '-' then
|
||||||
elsif operator = 45 then
|
|
||||||
elna_tac_make_variable(operand, symbol_table, parser_node^.type_decoration);
|
elna_tac_make_variable(operand, symbol_table, parser_node^.type_decoration);
|
||||||
|
|
||||||
instruction := elna_tac_instruction_create(ElnaTacOperator.negate);
|
instruction := elna_tac_instruction_create(ElnaTacOperator.negate);
|
||||||
elna_tac_instruction_set_operand(instruction, 1, base.kind, base.value, base.length);
|
elna_tac_instruction_set_operand(instruction, 1, base.kind, base.value, base.length);
|
||||||
elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length);
|
elna_tac_instruction_set_operand(instruction, 2, operand^.kind, operand^.value, operand^.length);
|
||||||
elna_list_append(instructions, instruction)
|
elna_list_append(instructions, instruction)
|
||||||
(* elsif operator = '~' then *)
|
elsif operator = '~' then
|
||||||
elsif operator = 126 then
|
|
||||||
elna_tac_make_variable(operand, symbol_table, parser_node^.type_decoration);
|
elna_tac_make_variable(operand, symbol_table, parser_node^.type_decoration);
|
||||||
|
|
||||||
instruction := elna_tac_instruction_create(ElnaTacOperator.complement);
|
instruction := elna_tac_instruction_create(ElnaTacOperator.complement);
|
||||||
@@ -3572,8 +3560,7 @@ end;
|
|||||||
proc _write_register(register_character: Word, register_number: Word);
|
proc _write_register(register_character: Word, register_number: Word);
|
||||||
begin
|
begin
|
||||||
_write_c(register_character);
|
_write_c(register_character);
|
||||||
(* _write_c(register_number + '0') *)
|
_write_c(register_number + '0')
|
||||||
_write_c(register_number + 48)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc elna_parser_record_type_expression(cursor: ^ElnaLexerCursor) -> ^ElnaTreeRecordTypeExpression;
|
proc elna_parser_record_type_expression(cursor: ^ElnaLexerCursor) -> ^ElnaTreeRecordTypeExpression;
|
||||||
@@ -4141,7 +4128,7 @@ begin
|
|||||||
buffer := malloc(7);
|
buffer := malloc(7);
|
||||||
|
|
||||||
sprintf(buffer, "$b%i\0", pseudo_counter);
|
sprintf(buffer, "$b%i\0", pseudo_counter);
|
||||||
pseudo_symbol^.allocated := 0; (* false *)
|
pseudo_symbol^.allocated := false;
|
||||||
|
|
||||||
operand^.value := buffer;
|
operand^.value := buffer;
|
||||||
operand^.length := strlen(buffer);
|
operand^.length := strlen(buffer);
|
||||||
@@ -4215,7 +4202,7 @@ begin
|
|||||||
variable_info := current_entry^.symbol_info;
|
variable_info := current_entry^.symbol_info;
|
||||||
|
|
||||||
pseudo_symbol := malloc(#size(ElnaRtlObjectInfo));
|
pseudo_symbol := malloc(#size(ElnaRtlObjectInfo));
|
||||||
pseudo_symbol^.allocated := 0; (* false *)
|
pseudo_symbol^.allocated := false;
|
||||||
pseudo_symbol^.kind := ElnaRtlInfoKind.object_info;
|
pseudo_symbol^.kind := ElnaRtlInfoKind.object_info;
|
||||||
pseudo_symbol^.rtl_type := elna_rtl_symbol_type(variable_info^.variable_type);
|
pseudo_symbol^.rtl_type := elna_rtl_symbol_type(variable_info^.variable_type);
|
||||||
|
|
||||||
@@ -5699,14 +5686,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
(* Returns true or false depending whether two strings are equal. *)
|
(* Returns true or false depending whether two strings are equal. *)
|
||||||
proc string_compare(lhs_pointer: Word, lhs_length: Word, rhs_pointer: Word, rhs_length: Word) -> Word;
|
proc string_compare(lhs_pointer: Word, lhs_length: Word, rhs_pointer: Word, rhs_length: Word) -> Bool;
|
||||||
var
|
var
|
||||||
result: Word;
|
result: Bool;
|
||||||
begin
|
begin
|
||||||
if lhs_length = rhs_length then
|
if lhs_length = rhs_length then
|
||||||
result := memcmp(lhs_pointer, rhs_pointer, lhs_length) = 0
|
result := memcmp(lhs_pointer, rhs_pointer, lhs_length) = 0
|
||||||
else
|
else
|
||||||
result := 0 (* false *)
|
result := false
|
||||||
end;
|
end;
|
||||||
return result
|
return result
|
||||||
end;
|
end;
|
||||||
@@ -5730,8 +5717,7 @@ begin
|
|||||||
result^.start := position_start;
|
result^.start := position_start;
|
||||||
result^.length := position_end - position_start;
|
result^.length := position_end - position_start;
|
||||||
|
|
||||||
(* if _load_byte(position_start) = '#' then *)
|
if _load_byte(position_start) = '#' then
|
||||||
if _load_byte(position_start) = 35 then
|
|
||||||
result^.kind := ElnaLexerKind.trait
|
result^.kind := ElnaLexerKind.trait
|
||||||
elsif string_compare(position_start, result^.length, "const", 5) then
|
elsif string_compare(position_start, result^.length, "const", 5) then
|
||||||
result^.kind := ElnaLexerKind._const
|
result^.kind := ElnaLexerKind._const
|
||||||
@@ -5788,23 +5774,17 @@ var
|
|||||||
begin
|
begin
|
||||||
character := _load_byte(start_position);
|
character := _load_byte(start_position);
|
||||||
|
|
||||||
(* if character = ':' then *)
|
if character = ':' then
|
||||||
if character = 58 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.colon, position)
|
result := elna_lexer_token_create(ElnaLexerKind.colon, position)
|
||||||
(* elsif character = '.' then *)
|
elsif character = '.' then
|
||||||
elsif character = 46 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.dot, position)
|
result := elna_lexer_token_create(ElnaLexerKind.dot, position)
|
||||||
(* elsif character = '(' then *)
|
elsif character = '(' then
|
||||||
elsif character = 40 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.left_paren, position)
|
result := elna_lexer_token_create(ElnaLexerKind.left_paren, position)
|
||||||
(* elsif character = '-' then *)
|
elsif character = '-' then
|
||||||
elsif character = 45 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.minus, position)
|
result := elna_lexer_token_create(ElnaLexerKind.minus, position)
|
||||||
(* elsif character = '<' then *)
|
elsif character = '<' then
|
||||||
elsif character = 60 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.less_than, position)
|
result := elna_lexer_token_create(ElnaLexerKind.less_than, position)
|
||||||
(* elsif character = '>' then *)
|
elsif character = '>' then
|
||||||
elsif character = 62 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.greater_than, position)
|
result := elna_lexer_token_create(ElnaLexerKind.greater_than, position)
|
||||||
end;
|
end;
|
||||||
return result
|
return result
|
||||||
@@ -5818,53 +5798,37 @@ begin
|
|||||||
result := malloc(#size(ElnaLexerToken));
|
result := malloc(#size(ElnaLexerToken));
|
||||||
character := _load_byte(start_position);
|
character := _load_byte(start_position);
|
||||||
|
|
||||||
(* if character = ';' then *)
|
if character = ';' then
|
||||||
if character = 59 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.semicolon, position)
|
result := elna_lexer_token_create(ElnaLexerKind.semicolon, position)
|
||||||
(* elsif character = ',' then *)
|
elsif character = ',' then
|
||||||
elsif character = 44 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.comma, position)
|
result := elna_lexer_token_create(ElnaLexerKind.comma, position)
|
||||||
(* elsif character = ')' then *)
|
elsif character = ')' then
|
||||||
elsif character = 41 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.right_paren, position)
|
result := elna_lexer_token_create(ElnaLexerKind.right_paren, position)
|
||||||
(* elsif character = '@' then *)
|
elsif character = '@' then
|
||||||
elsif character = 64 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.at, position)
|
result := elna_lexer_token_create(ElnaLexerKind.at, position)
|
||||||
(* elsif character = '~' then *)
|
elsif character = '~' then
|
||||||
elsif character = 126 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.not, position)
|
result := elna_lexer_token_create(ElnaLexerKind.not, position)
|
||||||
(* elsif character = '&' then *)
|
elsif character = '&' then
|
||||||
elsif character = 38 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.and, position)
|
result := elna_lexer_token_create(ElnaLexerKind.and, position)
|
||||||
(* elsif character = '+' then *)
|
elsif character = '+' then
|
||||||
elsif character = 43 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.plus, position)
|
result := elna_lexer_token_create(ElnaLexerKind.plus, position)
|
||||||
(* elsif character = '*' then *)
|
elsif character = '*' then
|
||||||
elsif character = 42 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.multiplication, position)
|
result := elna_lexer_token_create(ElnaLexerKind.multiplication, position)
|
||||||
(* elsif character = '=' then *)
|
elsif character = '=' then
|
||||||
elsif character = 61 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.equals, position)
|
result := elna_lexer_token_create(ElnaLexerKind.equals, position)
|
||||||
(* elsif character = '%' then *)
|
elsif character = '%' then
|
||||||
elsif character = 37 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.remainder, position)
|
result := elna_lexer_token_create(ElnaLexerKind.remainder, position)
|
||||||
(* elsif character = '/' then *)
|
elsif character = '/' then
|
||||||
elsif character = 47 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.division, position)
|
result := elna_lexer_token_create(ElnaLexerKind.division, position)
|
||||||
(* elsif character = '.' then *)
|
elsif character = '.' then
|
||||||
elsif character = 46 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.dot, position)
|
result := elna_lexer_token_create(ElnaLexerKind.dot, position)
|
||||||
(* elsif character = '^' then *)
|
elsif character = '^' then
|
||||||
elsif character = 94 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.hat, position)
|
result := elna_lexer_token_create(ElnaLexerKind.hat, position)
|
||||||
(* elsif character = '[' then *)
|
elsif character = '[' then
|
||||||
elsif character = 91 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.left_square, position)
|
result := elna_lexer_token_create(ElnaLexerKind.left_square, position)
|
||||||
(* elsif character = ']' then *)
|
elsif character = ']' then
|
||||||
elsif character = 93 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.right_square, position)
|
result := elna_lexer_token_create(ElnaLexerKind.right_square, position)
|
||||||
(* elsif character = '|' then *)
|
elsif character = '|' then
|
||||||
elsif character = 124 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.pipe, position)
|
result := elna_lexer_token_create(ElnaLexerKind.pipe, position)
|
||||||
end;
|
end;
|
||||||
return result
|
return result
|
||||||
@@ -5879,26 +5843,19 @@ begin
|
|||||||
first_character := _load_byte(start_position);
|
first_character := _load_byte(start_position);
|
||||||
last_character := _load_byte(one_before_last);
|
last_character := _load_byte(one_before_last);
|
||||||
|
|
||||||
(* if first_character = ':' then *)
|
if first_character = ':' then
|
||||||
if first_character = 58 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.assignment, position)
|
result := elna_lexer_token_create(ElnaLexerKind.assignment, position)
|
||||||
(* elsif first_character = '<' then *)
|
elsif first_character = '<' then
|
||||||
elsif first_character = 60 then
|
if last_character = '=' then
|
||||||
(* if last_character = '=' then *)
|
|
||||||
if last_character = 61 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.less_equal, position)
|
result := elna_lexer_token_create(ElnaLexerKind.less_equal, position)
|
||||||
(* elsif last_character = '>' then *)
|
elsif last_character = '>' then
|
||||||
elsif last_character = 62 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.not_equal, position)
|
result := elna_lexer_token_create(ElnaLexerKind.not_equal, position)
|
||||||
end
|
end
|
||||||
(* elsif first_character = '>' then *)
|
elsif first_character = '>' then
|
||||||
elsif first_character = 62 then
|
if last_character = '=' then
|
||||||
(* if last_character = '=' then *)
|
|
||||||
if last_character = 61 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.greater_equal, position)
|
result := elna_lexer_token_create(ElnaLexerKind.greater_equal, position)
|
||||||
end
|
end
|
||||||
(* elsif first_character = '-' then *)
|
elsif first_character = '-' then
|
||||||
elsif first_character = 45 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.arrow, position)
|
result := elna_lexer_token_create(ElnaLexerKind.arrow, position)
|
||||||
end;
|
end;
|
||||||
return result
|
return result
|
||||||
@@ -5911,14 +5868,11 @@ var
|
|||||||
begin
|
begin
|
||||||
delimiter := _load_byte(start_position);
|
delimiter := _load_byte(start_position);
|
||||||
|
|
||||||
(* if delimiter = '(' then *)
|
if delimiter = '(' then
|
||||||
if delimiter = 40 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.comment, position)
|
result := elna_lexer_token_create(ElnaLexerKind.comment, position)
|
||||||
(* elsif delimiter = '\'' then *)
|
elsif delimiter = '\'' then
|
||||||
elsif delimiter = 39 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.character, position)
|
result := elna_lexer_token_create(ElnaLexerKind.character, position)
|
||||||
(* elsif delimiter = '"' then *)
|
elsif delimiter = '"' then
|
||||||
elsif delimiter = 34 then
|
|
||||||
result := elna_lexer_token_create(ElnaLexerKind.string, position)
|
result := elna_lexer_token_create(ElnaLexerKind.string, position)
|
||||||
end;
|
end;
|
||||||
result^.start := start_position;
|
result^.start := start_position;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user