summaryrefslogtreecommitdiffstats
path: root/src/CodeParser/CParser
diff options
context:
space:
mode:
Diffstat (limited to 'src/CodeParser/CParser')
-rw-r--r--src/CodeParser/CParser/CParser.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/CodeParser/CParser/CParser.ts b/src/CodeParser/CParser/CParser.ts
index 6de9ae0..942b65f 100644
--- a/src/CodeParser/CParser/CParser.ts
+++ b/src/CodeParser/CParser/CParser.ts
@@ -240,13 +240,27 @@ export default class CParser implements ICodeParser {
returnArg.Type.nodes = [];
}
+ // Check if return type is a pointer
+ const ptrReturnIndex = returnArg.Type.nodes
+ .findIndex((n) => n instanceof Token && n.Type === TokenType.Pointer);
+
+ // Special case for void functions.
+ const voidReturnIndex = returnArg.Type.nodes
+ .findIndex((n) => n instanceof Token && n.Type === TokenType.Symbol && n.Value === "void");
+
// Special case for bool return type.
const boolReturnIndex: number = returnArg.Type.nodes
.findIndex((n) => n instanceof Token && n.Type === TokenType.Symbol && n.Value === "bool");
+
if (boolReturnIndex !== -1) {
retVals.push("true");
retVals.push("false");
- } else {
+ if (ptrReturnIndex !== -1) {
+ retVals.push("null");
+ }
+ } else if (voidReturnIndex !== -1 && ptrReturnIndex !== -1) {
+ retVals.push(returnArg.Type.Yield());
+ } else if (voidReturnIndex === -1 && returnArg.Type.nodes.length > 0) {
retVals.push(returnArg.Type.Yield());
}