]> git.mdlowis.com Git - proto/obnc.git/commitdiff
sketched out new ssa-based API
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Jul 2021 20:37:45 +0000 (16:37 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Jul 2021 20:37:45 +0000 (16:37 -0400)
cerise/src/ast.c

index ac1c78ab28f644493a457273cfa44a62f9fcfd08..559b7663e6750a34b2ac2e1a1b54c4a6eec27625 100644 (file)
 
 */
 
+/* Node Variants
+
+    <TYP>   <VAL>               Literal Value
+    <IDENT> <ID> <VER>          Identifier Reference
+    <OP>    <D>  <L>   <R>      Binary Operation
+    <OP>    <D>  <R>            Unary Operation
+    <RET>   <V?> <B>            Procedure Return
+    <IF>    <C>  <B1>  <B2>     If Statement
+    <BLK>   <PL> <H>   <T>      Basic Block
+
+*/
+#if 0
+AstNode* ast_bool(AstNode* block, bool val);
+AstNode* ast_int(AstNode* block, long long val);
+AstNode* ast_real(AstNode* block, double val);
+AstNode* ast_ident(AstNode* block, Parser* p, long long index);
+AstNode* ast_op(AstNode* block, int op, AstNode* left, AstNode* right);
+AstNode* ast_store(AstNode* block, AstNode* dest, AstNode* offset, AstNode* value);
+AstNode* ast_return(AstNode* block, AstNode* expr, AstNode* dest);
+AstNode* ast_if(AstNode* block, AstNode* cond, AstNode* dest1, AstNode* dest2);
+// while
+// foreach
+// case
+
+/* identifier references and literal values */
 typedef struct {
     AstNodeHeader hdr;
     union {
@@ -35,6 +60,33 @@ typedef struct {
     long long tag;
 } AstValue;
 
+typedef struct {
+    AstNodeHeader hdr;
+    AstNode* dest;
+    AstNode* left;
+    AstNode* right;
+} AstOp;
+
+typedef struct {
+    AstNodeHeader hdr;
+    AstNode* head;
+    AstNode* tail;
+} AstBlock;
+
+#else
+
+typedef struct {
+    AstNodeHeader hdr;
+    union {
+        long long i;
+        double f;
+        char* s;
+    } val;
+    long long tag;
+} AstValue;
+
+#endif
+
 bool ast_isconst(AstNode* node)
 {
     bool ret;