Skip to content

Commit 38fdb46

Browse files
committed
fix refactor function call WIP
1 parent c84885b commit 38fdb46

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

examples/400-subrange.pas

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
Type
1010
UpperCaseLetter = 'A'..'Z';
11-
TDay = 1..31; // 1..31 doesn't work for now as it is interpreted as an incorrect real value
1211
TMonth = 1..12;
12+
TDay = 1..31;
13+
TYear = -9999..9999;
1314

1415
Procedure TestInnerType;
1516
Type
@@ -43,7 +44,7 @@
4344
// WriteLn('I = ', I, ' J = ', J, ' K = ', K);
4445
L := 'L';
4546
WriteLn('L = ''', L, '''');
46-
// // { this should/will cause a runtime error because 'a'' is out of range for 'A'..'Z' }
47+
// { this should/will cause a runtime error because 'a'' is out of range for 'A'..'Z' }
4748
// L := 'a';
4849
// WriteLn('L = ''', L, '''');
4950
TestInnerType;

src/pascalscript.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "ps_symbol_table.h"
2121
#include "ps_version.h"
2222

23-
#define DEBUGGER_SOURCE "examples/031-array1.pas"
23+
#define DEBUGGER_SOURCE "examples/400-subrange.pas"
2424
// #define DEBUGGER_SOURCE "examples/005-first.pas"
2525

2626
// Runtime options

src/ps_visit_expression.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,23 @@ bool ps_visit_function_call_random(ps_interpreter *interpreter, ps_interpreter_m
512512
VISIT_END("OK")
513513
}
514514

515-
bool ps_visit_function_call_low_high(ps_interpreter *interpreter, ps_interpreter_mode mode, ps_symbol *symbol)
515+
bool ps_visit_function_call_low_high(ps_interpreter *interpreter, ps_interpreter_mode mode, ps_symbol **symbol)
516516
{
517-
VISIT_BEGIN("FUNCTION_CALL", "LOW_HIGH");
517+
VISIT_BEGIN("FUNCTION_CALL", "LOW_HIGH")
518518

519519
// Low and High functions have one "symbolic" argument, i.e. Low(Days) or High(Day)
520-
EXPECT_TOKEN(PS_TOKEN_LEFT_PARENTHESIS);
520+
EXPECT_TOKEN(PS_TOKEN_LEFT_PARENTHESIS)
521521
READ_NEXT_TOKEN
522522
if (lexer->current_token.type != PS_TOKEN_IDENTIFIER && lexer->current_token.type != PS_TOKEN_INTEGER &&
523523
lexer->current_token.type != PS_TOKEN_UNSIGNED && lexer->current_token.type != PS_TOKEN_CHAR)
524524
RETURN_ERROR(PS_ERROR_UNEXPECTED_TOKEN)
525525
ps_identifier identifier = {0};
526526
COPY_IDENTIFIER(identifier)
527-
symbol = ps_interpreter_find_symbol(interpreter, identifier, false);
528-
if (symbol == NULL)
529-
RETURN_ERROR(PS_ERROR_SYMBOL_NOT_FOUND);
527+
*symbol = ps_interpreter_find_symbol(interpreter, identifier, false);
528+
if (*symbol == NULL)
529+
RETURN_ERROR(PS_ERROR_SYMBOL_NOT_FOUND)
530530
READ_NEXT_TOKEN
531-
EXPECT_TOKEN(PS_TOKEN_RIGHT_PARENTHESIS);
531+
EXPECT_TOKEN(PS_TOKEN_RIGHT_PARENTHESIS)
532532
READ_NEXT_TOKEN
533533

534534
VISIT_END("OK")
@@ -591,7 +591,7 @@ bool ps_visit_function_call_system(ps_interpreter *interpreter, ps_interpreter_m
591591
else if (function == &ps_system_function_low || function == &ps_system_function_high)
592592
{
593593
arg_count = -1;
594-
if (!ps_visit_function_call_low_high(interpreter, mode, symbol))
594+
if (!ps_visit_function_call_low_high(interpreter, mode, &symbol))
595595
TRACE_ERROR("LOW_HIGH")
596596
}
597597
else if (function == &ps_system_function_power)

0 commit comments

Comments
 (0)