glados-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

AST.Semantics.CheckCall

Synopsis

Documentation

checkCall :: CheckExprFn -> CheckEnv -> Ast -> [Ast] -> Either String Type Source #

Main entry point for checking calls and operators.

Dispatches the call to the appropriate handler. It first checks if the function is a built-in operator (Math, Logic, Special). If not, it attempts to resolve it as a user-defined function.

param CheckExprFn The callback to verify arguments. param CheckEnv The current semantic environment. param Ast The function node (usually ASymbol). param [Ast] The list of arguments. @return Either String Type The return type of the call or an error message.

checkEqualityOp :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates equality checks (==).

Unlike other binary ops, equality allows any type as long as both operands have compatible types (e.g. int==int, bool==bool).

checkTypeof :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'typeof(arg)'.

Introspection function that returns the type of the argument as a string. It accepts any valid expression type.

param arg: Any expression. return: String (TyList TyInt) representing the type name (e.g., "int", "bool").

checkFFRead :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'ffread(path)'.

High-level File Read: Reads the entire content of a file.

param path: String (TyList TyInt) representing the file path. return: [String] (TyList (TyList TyInt)), where each element is a line.

checkFFWrite :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'ffwrite(path, content)'.

High-level File Write: Writes a list of strings to a file.

param path: String (TyList TyInt) representing the file path. param content: [String] (TyList (TyList TyInt)) the lines to write. @return: Bool (TyBool) indicating success or failure.

checkOpen :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'open(path, mode)'.

Low-level Open: Opens a file and returns a file descriptor.

param path: String (TyList TyInt) representing the file path. param mode: Int (TyInt) representing the access mode (e.g., 0 for read, 1 for write). @return: Int (TyInt) the file descriptor (FD).

checkClose :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'close(fd)'.

Low-level Close: Closes an open file descriptor.

param fd: Int (TyInt) the file descriptor to close. return: Int (TyInt) usually 0 for success.

checkRead :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'read(fd, size)'.

Low-level Read: Reads a specific number of bytes/characters from a file descriptor.

param fd: Int (TyInt) the file descriptor to read from. param size: Int (TyInt) the number of characters to read. @return: String (TyList TyInt) containing the read data.

checkInput :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'input(fd)'.

Stream Input: Reads a line from a file descriptor (often used with 0 for stdin).

param fd: Int (TyInt) the file descriptor to read from. return: String (TyList TyInt) containing the input line.

checkSizeof :: CheckExprFn -> CheckEnv -> [Ast] -> Either String Type Source #

Validates 'sizeof(arg)'.

Returns the size (or length) of the argument. Accepts any type. Returns an Integer.

param arg: Any expression. return: Int (TyInt).