forked from zeotrope/anicca
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Conversion between numeric types - Scalar functions working TODO + Change noun parsing to use numeric conversions
- Loading branch information
Showing
18 changed files
with
159 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdlib.h> | ||
|
||
#include "anicca.h" | ||
#include "memory.h" | ||
#include "convert.h" | ||
|
||
A convert(I t, A y) { | ||
I yt = AT(y), yr = AR(y), yn = AN(y), *ys = AS(y); | ||
I k = type_size(t), *iv; B *bv; D *dv; | ||
A z = gen_array(t, yr, yn, ys); | ||
|
||
switch(k = CNVCASE(yt, t)) { | ||
case BtI: bv=BAV(y); iv=IAV(z); DO(yn, iv[i] = (I)bv[i]); break; | ||
case BtD: bv=BAV(y); dv=DAV(z); DO(yn, dv[i] = (D)bv[i]); break; | ||
case ItD: iv=IAV(y); dv=DAV(z); DO(yn, dv[i] = (D)iv[i]); break; | ||
} | ||
return z; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef _CONVERT_H | ||
|
||
/* | ||
Conversion vector: | ||
lowest 8 bits: argument type. | ||
highest 8 bits: result type. | ||
ItD: 0 0 0 0 1 0 0 0 | 0 0 0 0 0 1 0 0 | ||
FLT INT | ||
*/ | ||
|
||
#define CNVCASE(a,b) ((a)+(VERB*(b))) | ||
#define BtI CNVCASE(BOOL, INT) | ||
#define BtD CNVCASE(BOOL, FLT) | ||
#define BtZ CNVCASE(BOOL, CMPX) | ||
#define ItD CNVCASE(INT, FLT) | ||
#define ItZ CNVCASE(INT, CMPX) | ||
#define DtZ CNVCASE(FLT, CMPX) | ||
|
||
A convert(I t, A y); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
VO print(A y); | ||
VO println(A y); | ||
VO a_init(VO); | ||
C *strndup(const C *s, UI n); | ||
A eval(const C *str); | ||
|
||
#endif |
Oops, something went wrong.