Browse Source

representing some objects

tcheukueppo 2 years ago
parent
commit
38ae229631
4 changed files with 190 additions and 19 deletions
  1. 2 19
      src/ma_conf.h
  2. 20 0
      src/ma_maat.h
  3. 56 0
      src/ma_obj.c
  4. 112 0
      src/ma_obj.h

+ 2 - 19
src/ma_conf.h

@@ -19,24 +19,7 @@
 #define <limits.h>
 #define <stddef.h>
 
-/* $$Version and authors */
-
-/* Maat version components */
-#define MA_MAJOR_VERSION  1
-#define MA_MINOR_VERSION  0
-#define MA_PATCH_VERSION  0
-
-/* String form of the version */
-#define MA_VERSION  MA_MAJOR_VERSION "." MA_MINOR_VERSION
-
-/* Some patches after releasing Maat version $MA_VERSION$ */
-#define MA_PATCH      MA_VERSION "." MA_PATCH_VERSION
-#define MA_PATCH_NUM  ((10 * MA_MAJOR_VERSION + MA_MINOR_VERSION) * 100 + MA_PATCH_VERSION)
-
-#define MA_COPYRIGHT  "Maat " MA_PATCH  " Copyright (C) 2023 Maat.cm, PanLab.africa"
-#define MA_AUTHORS    "Kueppo Tcheukam J. W."
-
-/* Bin file name */
+/* $$Executable interpreter name */
 #define MAAT  maat MA_VERSION
 
 /*
@@ -184,7 +167,7 @@
 
 #define ma_sinline  static ma_inline
 
-/* $$NAN_TAGGING to optimize value representation */
+/* $$NAN_BOXING to optimize value representation */
 
 #if !defined(MA_NAN_TAGGING)
 #define MA_NAN_TAGGING

+ 20 - 0
src/ma_maat.h

@@ -1,6 +1,26 @@
+/*
+ *
+ */
 #ifndef ma_maat_h
 #define ma_maat_h
 
+/* $$Version and authors */
+
+/* Maat version components */
+#define MA_MAJOR_VERSION  1
+#define MA_MINOR_VERSION  0
+#define MA_PATCH_VERSION  0
+
+/* String form of the version */
+#define MA_VERSION  MA_MAJOR_VERSION "." MA_MINOR_VERSION
+
+/* Some patches after releasing Maat version $MA_VERSION$ */
+#define MA_PATCH      MA_VERSION "." MA_PATCH_VERSION
+#define MA_PATCH_NUM  ((10 * MA_MAJOR_VERSION + MA_MINOR_VERSION) * 100 + MA_PATCH_VERSION)
+
+#define MA_COPYRIGHT  "Maat " MA_PATCH  " Copyright (C) 2023 Maat.cm, PanLab.africa"
+#define MA_AUTHORS    "Kueppo Tcheukam J. W."
+
 
 
 #endif

+ 56 - 0
src/ma_obj.c

@@ -0,0 +1,56 @@
+- [`Any`](./types/Any.md)
+- [`Bool`](./types/Bool.md)
+- [`Num`](./types/Num.md)
+- [`Str`](./types/Str.md)
+- [`Range`](./types/Range.md)
+- [`Array`](./types/Array.md)
+- [`Map`](./types/Map.md)
+- [`Set`](./types/Set.md)
+- [`MSet`](./types/MSet.md)
+- [`Bag`](./types/Bag.md)
+- [`MBag`](./types/MBag.md)
+- [`Lazy`](./types/Lazy.md)
+- [`Fun`](./types/Fun.md)
+- [`GFun`](./types/GFun.md)
+- [`Regex`](./types/Regex.md)
+- [`Ma`](./types/Ma.md)
+- [`Work`](./types/Work.md)
+- [`Chan`](./types/Chan.md)
+- [`Socket`](./types/Socket.md)
+- [`Socket::Work`](./types/Socket::Work.md)
+- [`Proc`](./types/Proc.md)
+- [`Proc::Work`](./types/Proc::Work.md)
+- [`Pipe`](./types/Pipe.md)
+- [`File`](./types/File.md)
+- [`Dir`](./types/Dir.md)
+- [`Date`](./types/Date.md)
+- [`Sys`](./types/Sys.md)
+- [`Term`](./types/Term.md)
+- [`Any`](./types/Any.md)
+- [`Bool`](./types/Bool.md)
+- [`Num`](./types/Num.md)
+- [`Str`](./types/Str.md)
+- [`Range`](./types/Range.md)
+- [`Array`](./types/Array.md)
+- [`Map`](./types/Map.md)
+- [`Set`](./types/Set.md)
+- [`MSet`](./types/MSet.md)
+- [`Bag`](./types/Bag.md)
+- [`MBag`](./types/MBag.md)
+- [`Lazy`](./types/Lazy.md)
+- [`Fun`](./types/Fun.md)
+- [`GFun`](./types/GFun.md)
+- [`Regex`](./types/Regex.md)
+- [`Ma`](./types/Ma.md)
+- [`Work`](./types/Work.md)
+- [`Chan`](./types/Chan.md)
+- [`Socket`](./types/Socket.md)
+- [`Socket::Work`](./types/Socket::Work.md)
+- [`Proc`](./types/Proc.md)
+- [`Proc::Work`](./types/Proc::Work.md)
+- [`Pipe`](./types/Pipe.md)
+- [`File`](./types/File.md)
+- [`Dir`](./types/Dir.md)
+- [`Date`](./types/Date.md)
+- [`Sys`](./types/Sys.md)
+- [`Term`](./types/Term.md)

+ 112 - 0
src/ma_obj.h

@@ -0,0 +1,112 @@
+/*
+ * Abstract: Type definitions for Maat objects
+ * Lisenced under AGL, see LICENSE file for copyright and license details.
+ */
+
+#ifndef ma_obj_h
+#define ma_obj_h
+
+#define unsigned char u_byte
+
+typedef enum {
+   Bool, Num, Str,
+   Range, Array, Map,
+   Set, MSet, Bag,
+   MBag, Fun, GFun,
+   Regex, Ma, Chan,
+   Pipe, File, Dir,
+   Date, Sys, Socket,
+   Proc, Term,
+} type;
+
+#define isBool
+#define isNum
+#define isStr
+#define isRange
+#define isArray
+#define isMap
+#define isSet
+#define isMSet
+#define isBag
+#define isMBag
+#define isFun
+#define isGFun
+#define isRegex
+#define isMa
+#define isChan
+#define isPipe
+#define isFile
+#define isDir
+#define isDate
+#define isSys
+#define isSocket
+#define isProc
+#define isTerm
+
+
+
+/*
+ * Header of all objects
+ * $type: type of the object
+ * $obj_class: class to which the object belongs
+ * $next: next obj to keep track of all objects
+ * $class: the object's class
+ * $marked: object marked for collection?
+ */
+typedef struct {
+   u_byte type;
+   struct Class *class;
+   struct Header *next;
+} Header;
+
+/*
+ * $obj: header
+ * $hash: hash value of $str
+ * $length: length of $str
+ * $str: the string itself
+ */
+typedef struct {
+   Header obj;
+   unsigned int hash;
+   size_t length;
+   char str[1];
+} Str;
+
+/*
+ * $obj: header
+ * $from: from (inclusive)
+ * $to: to (inclusive)
+ */
+typedef struct {
+   Header obj;
+   double from;
+   double to;
+} Range;
+
+typedef struct {
+   Header obj;
+   
+} Map;
+
+/*
+ * $obj: header
+ * $sup: class' superclasses (C3 mro)
+ * $name: class name
+ * $nfields: number of fields
+ * $attributes: attributes
+ * $methods: a map for methods
+ */
+typedef struct {
+   Header obj;
+   struct Class **sup;
+   Str *name;
+   int nfields;
+   Map **methods;
+   Value *attributes;
+} Class;
+
+
+
+
+#endif
+