Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 016f47f

Browse files
committed
Oprava, volanie len deklarovanej funkcie
1 parent a42e811 commit 016f47f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

builtin.c

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ int addBuiltTable(st_globalTable_t *GlobalTable){
2828
if ((BuiltinFunc = st_add_func(GlobalTable, &funcName)) == NULL){
2929
return INTERNAL_ERROR;
3030
}
31+
BuiltinFunc->defined = true;
3132
//Set parameters
3233
if (strCopyConst(&VariableName, "s")){
3334
return INTERNAL_ERROR;
@@ -79,6 +80,7 @@ int addBuiltTable(st_globalTable_t *GlobalTable){
7980

8081
//Return value of function
8182
BuiltinFunc->func_type = st_string;
83+
BuiltinFunc->defined = true;
8284

8385

8486
/** ADD FUNCTION asc **/
@@ -110,6 +112,7 @@ int addBuiltTable(st_globalTable_t *GlobalTable){
110112

111113
//Return value of function
112114
BuiltinFunc->func_type = st_integer;
115+
BuiltinFunc->defined = true;
113116

114117

115118
/** ADD FUNCTION chr **/
@@ -132,6 +135,7 @@ int addBuiltTable(st_globalTable_t *GlobalTable){
132135

133136
//Return value of function
134137
BuiltinFunc->func_type = st_string;
138+
BuiltinFunc->defined = true;
135139

136140
strFree(&funcName);
137141
strFree(&VariableName);

parser.c

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ int program(token_t *CurrentToken, struct check ToCheck, st_globalTable_t *Globa
175175
return SYN_ERROR; //Je to syntakticky error?
176176
}
177177

178+
//Check if all declared functions was defined
179+
for(int ii = 0; ii < GlobalTable->global_size; ii++){
180+
st_localTable_t *PrechadzaniePomoc = GlobalTable->functions[ii];
181+
while (PrechadzaniePomoc != NULL){
182+
printf("%s\n", PrechadzaniePomoc->key.str);
183+
if (!PrechadzaniePomoc->defined){
184+
return SEM_ERROR_FUNC;
185+
}
186+
PrechadzaniePomoc = PrechadzaniePomoc->next;
187+
}
188+
}
189+
178190
//Scope in HashTable represented as #Scope
179191
char *name = "Scope";
180192
strClear(&FunctionID);

0 commit comments

Comments
 (0)