(SOC) Storage Only Commit

(ADD) Name, NameScope, Catlog, Object, String, Attribute, Char, Registry, Utils, Type, <Platform Support>, <Global Constants>, README

(MOD) Array, Var, Status, MemMan, <Common>
This commit is contained in:
William
2024-05-16 00:04:42 +08:00
parent 989e512f8f
commit 5f7a6c6f93
32 changed files with 1694 additions and 195 deletions

18
Stack/include/stack.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef STACK_H
# define STACK_H
# include <Compound/var.h>
# include <Compound/status.h>
typedef struct {
Var *members;
int len;
} Stack;
Status Stack_Create(Stack *inst, int len);
Status Stack_CopyOf(Stack *inst, Stack *other);
Status Stack_Push(Stack *inst, Var *item);
Status Stack_Pop(Stack *inst);
bool Stack_IsEmpty(Stack *inst);
#endif /* STACK_H */

28
Stack/src/stack.c Normal file
View File

@@ -0,0 +1,28 @@
#include <Compound/stack.h>
Status Stack_Create(Stack *inst, int len)
{
// /* Skip once len is negative. */
// state((len < 0), InvalidParameter);
// /* Initialise before access. */
// if (inst == NULL) {
// *inst = (Stack) {
// .members = NULL,
// .len = len
// };
// /* Assign for each member. */
// inst->members = malloc(len * sizeof(Var));
// for (register int i = 0; i < len; i++) {
// inst->members[i] = (Var) {
// .addr = NULL,
// .sz = 0
// };
// }
// }
}
Status Stack_CopyOf(Stack *inst, Stack *other);
Status Stack_Push(Stack *inst, Var *item);
Status Stack_Pop(Stack *inst);
bool Stack_IsEmpty(Stack *inst);