00001
00002 #include <basix/int.hpp>
00003 #include <basix/vector.hpp>
00004 #include <basix/port.hpp>
00005 #include <basix/literal.hpp>
00006 #include <basix/compound.hpp>
00007 #include <basix/mmx_syntax.hpp>
00008 #include <basix/tuple.hpp>
00009 #include <basix/glue.hpp>
00010
00011 #define int_literal(x) as_int (as_string (x))
00012 #define is_generic_literal is<literal>
00013 #define gen_literal_apply(f,v) gen (as<generic> (f), v)
00014 #define gen_literal_access(f,v) access (as<generic> (f), v)
00015 #define is_generic_compound is<compound>
00016 #define compound_arguments(x) cdr (as_vector (x))
00017 #define gen_compound_apply(f,v) gen (as<generic> (f), v)
00018
00019 namespace mmx {
00020 static bool
00021 GLUE_1 (const generic &arg_1) {
00022 return is_generic_compound (arg_1);
00023 }
00024
00025 static generic
00026 GLUE_2 (const compound &arg_1, const tuple<generic> &arg_2) {
00027 return gen_compound_apply (arg_1, as_vector (arg_2));
00028 }
00029
00030 static compound
00031 GLUE_3 (const tuple<generic> &arg_1) {
00032 return compound (as_vector (arg_1));
00033 }
00034
00035 static compound
00036 GLUE_4 (const vector<generic> &arg_1) {
00037 return compound (arg_1);
00038 }
00039
00040 static vector<generic>
00041 GLUE_5 (const compound &arg_1) {
00042 return as_vector (arg_1);
00043 }
00044
00045 static int
00046 GLUE_6 (const compound &arg_1) {
00047 return N (arg_1);
00048 }
00049
00050 static generic
00051 GLUE_7 (const compound &arg_1, const int &arg_2) {
00052 return arg_1[arg_2];
00053 }
00054
00055 static vector<generic>
00056 GLUE_8 (const compound &arg_1) {
00057 return as_vector (arg_1);
00058 }
00059
00060 static vector<generic>
00061 GLUE_9 (const compound &arg_1) {
00062 return compound_arguments (arg_1);
00063 }
00064
00065 void
00066 glue_compound () {
00067 static bool done = false;
00068 if (done) return;
00069 done = true;
00070 call_glue (string ("glue_literal"));
00071 call_glue (string ("glue_basix_vector_generic"));
00072 define ("compound?", GLUE_1);
00073 define (".()", GLUE_2);
00074 define ("compound", GLUE_3);
00075 define ("as_compound", GLUE_4);
00076 define ("as_vector", GLUE_5);
00077 define ("#", GLUE_6);
00078 define (".[]", GLUE_7);
00079 define ("components", GLUE_8);
00080 define ("arguments", GLUE_9);
00081 }
00082 }