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