diff options
Diffstat (limited to 'src/environment.c')
| -rw-r--r-- | src/environment.c | 647 |
1 files changed, 357 insertions, 290 deletions
diff --git a/src/environment.c b/src/environment.c index 3b3c6d0b..848e1269 100644 --- a/src/environment.c +++ b/src/environment.c @@ -71,6 +71,8 @@ env_t *global_env(bool source_mapping) { const char *name, *code, *type_str; } ns_entry_t; +#define MAKE_TYPE(name, type, type_name, type_info, ...) \ + {name, type, type_name, type_info, TypedList(ns_entry_t, __VA_ARGS__)} struct { const char *name; type_t *type; @@ -78,145 +80,170 @@ env_t *global_env(bool source_mapping) { Text_t typeinfo; List_t namespace; } global_types[] = { - {"Void", Type(VoidType), Text("Void_t"), Text("Void$info"), {}}, - {"Abort", Type(AbortType), Text("void"), Text("Abort$info"), {}}, - {"Memory", Type(MemoryType), Text("Memory_t"), Text("Memory$info"), {}}, - {"Bool", Type(BoolType), Text("Bool_t"), Text("Bool$info"), - TypedList(ns_entry_t, {"parse", "Bool$parse", "func(text:Text, remainder:&Text? = none -> Bool?)"}, )}, - {"Byte", Type(ByteType), Text("Byte_t"), Text("Byte$info"), - TypedList(ns_entry_t, {"get_bit", "Byte$get_bit", "func(x:Byte, bit_index:Int -> Bool)"}, - {"hex", "Byte$hex", "func(byte:Byte, uppercase=yes, prefix=no -> Text)"}, - {"is_between", "Byte$is_between", "func(x:Byte, low:Byte, high:Byte -> Bool)"}, - {"max", "Byte$max", "Byte"}, {"min", "Byte$min", "Byte"}, - {"parse", "Byte$parse", "func(text:Text, remainder:&Text? = none -> Byte?)"}, - {"to", "Byte$to", "func(first:Byte, last:Byte, step:Int8?=none -> func(->Byte?))"}, )}, - {"Int", Type(BigIntType), Text("Int_t"), Text("Int$info"), - TypedList( - ns_entry_t, {"abs", "Int$abs", "func(x:Int -> Int)"}, {"bit_and", "Int$bit_and", "func(x,y:Int -> Int)"}, - {"bit_or", "Int$bit_or", "func(x,y:Int -> Int)"}, {"bit_xor", "Int$bit_xor", "func(x,y:Int -> Int)"}, - {"choose", "Int$choose", "func(x,y:Int -> Int)"}, - {"clamped", "Int$clamped", "func(x,low,high:Int -> Int)"}, - {"divided_by", "Int$divided_by", "func(x,y:Int -> Int)"}, - {"factorial", "Int$factorial", "func(x:Int -> Int)"}, {"gcd", "Int$gcd", "func(x,y:Int -> Int)"}, - {"get_bit", "Int$get_bit", "func(x,bit_index:Int -> Bool)"}, - {"hex", "Int$hex", "func(i:Int, digits=0, uppercase=yes, prefix=yes -> Text)"}, - {"is_between", "Int$is_between", "func(x:Int,low:Int,high:Int -> Bool)"}, - {"is_prime", "Int$is_prime", "func(x:Int,reps=50 -> Bool)"}, - {"left_shifted", "Int$left_shifted", "func(x,y:Int -> Int)"}, - {"minus", "Int$minus", "func(x,y:Int -> Int)"}, {"modulo", "Int$modulo", "func(x,y:Int -> Int)"}, - {"modulo1", "Int$modulo1", "func(x,y:Int -> Int)"}, {"negated", "Int$negated", "func(x:Int -> Int)"}, - {"negative", "Int$negative", "func(x:Int -> Int)"}, {"next_prime", "Int$next_prime", "func(x:Int -> Int)"}, - {"octal", "Int$octal", "func(i:Int, digits=0, prefix=yes -> Text)"}, - {"onward", "Int$onward", "func(first:Int,step=1 -> func(->Int?))"}, - {"parse", "Int$parse", "func(text:Text, remainder:&Text? = none -> Int?)"}, - {"plus", "Int$plus", "func(x,y:Int -> Int)"}, {"power", "Int$power", "func(base:Int,exponent:Int -> Int)"}, + MAKE_TYPE("Void", Type(VoidType), Text("Void_t"), Text("Void$info")), + MAKE_TYPE("Abort", Type(AbortType), Text("void"), Text("Abort$info")), + MAKE_TYPE("Memory", Type(MemoryType), Text("Memory_t"), Text("Memory$info")), + MAKE_TYPE( // + "Bool", Type(BoolType), Text("Bool_t"), Text("Bool$info"), + {"parse", "Bool$parse", "func(text:Text, remainder:&Text? = none -> Bool?)"}), + MAKE_TYPE( // + "Byte", Type(ByteType), Text("Byte_t"), Text("Byte$info"), + {"get_bit", "Byte$get_bit", "func(x:Byte, bit_index:Int -> Bool)"}, // + {"hex", "Byte$hex", "func(byte:Byte, uppercase=yes, prefix=no -> Text)"}, // + {"is_between", "Byte$is_between", "func(x:Byte, low:Byte, high:Byte -> Bool)"}, // + {"max", "Byte$max", "Byte"}, // + {"min", "Byte$min", "Byte"}, // + {"parse", "Byte$parse", "func(text:Text, remainder:&Text? = none -> Byte?)"}, // + {"to", "Byte$to", "func(first:Byte, last:Byte, step:Int8?=none -> func(->Byte?))"}), + MAKE_TYPE( // + "Int", Type(BigIntType), Text("Int_t"), Text("Int$info"), {"abs", "Int$abs", "func(x:Int -> Int)"}, // + {"bit_and", "Int$bit_and", "func(x,y:Int -> Int)"}, // + {"bit_or", "Int$bit_or", "func(x,y:Int -> Int)"}, // + {"bit_xor", "Int$bit_xor", "func(x,y:Int -> Int)"}, // + {"choose", "Int$choose", "func(x,y:Int -> Int)"}, // + {"clamped", "Int$clamped", "func(x,low,high:Int -> Int)"}, // + {"divided_by", "Int$divided_by", "func(x,y:Int -> Int)"}, // + {"factorial", "Int$factorial", "func(x:Int -> Int)"}, // + {"gcd", "Int$gcd", "func(x,y:Int -> Int)"}, // + {"get_bit", "Int$get_bit", "func(x,bit_index:Int -> Bool)"}, // + {"hex", "Int$hex", "func(i:Int, digits=0, uppercase=yes, prefix=yes -> Text)"}, // + {"is_between", "Int$is_between", "func(x:Int,low:Int,high:Int -> Bool)"}, // + {"is_prime", "Int$is_prime", "func(x:Int,reps=50 -> Bool)"}, // + {"left_shifted", "Int$left_shifted", "func(x,y:Int -> Int)"}, // + {"minus", "Int$minus", "func(x,y:Int -> Int)"}, // + {"modulo", "Int$modulo", "func(x,y:Int -> Int)"}, // + {"modulo1", "Int$modulo1", "func(x,y:Int -> Int)"}, // + {"negated", "Int$negated", "func(x:Int -> Int)"}, // + {"negative", "Int$negative", "func(x:Int -> Int)"}, // + {"next_prime", "Int$next_prime", "func(x:Int -> Int)"}, // + {"octal", "Int$octal", "func(i:Int, digits=0, prefix=yes -> Text)"}, // + {"onward", "Int$onward", "func(first:Int,step=1 -> func(->Int?))"}, // + {"parse", "Int$parse", "func(text:Text, remainder:&Text? = none -> Int?)"}, // + {"plus", "Int$plus", "func(x,y:Int -> Int)"}, // + {"power", "Int$power", "func(base:Int,exponent:Int -> Int)"}, // #if __GNU_MP_VERSION >= 6 #if __GNU_MP_VERSION_MINOR >= 3 - {"prev_prime", "Int$prev_prime", "func(x:Int -> Int?)"}, + {"prev_prime", "Int$prev_prime", "func(x:Int -> Int?)"}, // #endif #endif - {"right_shifted", "Int$right_shifted", "func(x,y:Int -> Int)"}, - {"sqrt", "Int$sqrt", "func(x:Int -> Int?)"}, {"times", "Int$times", "func(x,y:Int -> Int)"}, - {"to", "Int$to", "func(first:Int,last:Int,step:Int?=none -> func(->Int?))"}, )}, - {"Int64", Type(IntType, .bits = TYPE_IBITS64), Text("Int64_t"), Text("Int64$info"), - TypedList(ns_entry_t, {"abs", "labs", "func(i:Int64 -> Int64)"}, - {"bits", "Int64$bits", "func(x:Int64 -> [Bool])"}, - {"clamped", "Int64$clamped", "func(x,low,high:Int64 -> Int64)"}, - {"divided_by", "Int64$divided_by", "func(x,y:Int64 -> Int64)"}, - {"gcd", "Int64$gcd", "func(x,y:Int64 -> Int64)"}, - {"parse", "Int64$parse", "func(text:Text, remainder:&Text? = none -> Int64?)"}, - {"get_bit", "Int64$get_bit", "func(x:Int64, bit_index:Int -> Bool)"}, - {"hex", "Int64$hex", "func(i:Int64, digits=0, uppercase=yes, prefix=yes -> Text)"}, - {"is_between", "Int64$is_between", "func(x:Int64,low:Int64,high:Int64 -> Bool)"}, - {"max", "Int64$max", "Int64"}, {"min", "Int64$min", "Int64"}, - {"modulo", "Int64$modulo", "func(x,y:Int64 -> Int64)"}, - {"modulo1", "Int64$modulo1", "func(x,y:Int64 -> Int64)"}, - {"octal", "Int64$octal", "func(i:Int64, digits=0, prefix=yes -> Text)"}, - {"onward", "Int64$onward", "func(first:Int64,step=Int64(1) -> func(->Int64?))"}, - {"to", "Int64$to", "func(first:Int64,last:Int64,step:Int64?=none -> func(->Int64?))"}, - {"unsigned_left_shifted", "Int64$unsigned_left_shifted", "func(x:Int64,y:Int64 -> Int64)"}, - {"unsigned_right_shifted", "Int64$unsigned_right_shifted", "func(x:Int64,y:Int64 -> Int64)"}, - {"wrapping_minus", "Int64$wrapping_minus", "func(x:Int64,y:Int64 -> Int64)"}, - {"wrapping_plus", "Int64$wrapping_plus", "func(x:Int64,y:Int64 -> Int64)"}, )}, - {"Int32", Type(IntType, .bits = TYPE_IBITS32), Text("Int32_t"), Text("Int32$info"), - TypedList(ns_entry_t, {"abs", "abs", "func(i:Int32 -> Int32)"}, - {"bits", "Int32$bits", "func(x:Int32 -> [Bool])"}, - {"clamped", "Int32$clamped", "func(x,low,high:Int32 -> Int32)"}, - {"divided_by", "Int32$divided_by", "func(x,y:Int32 -> Int32)"}, - {"gcd", "Int32$gcd", "func(x,y:Int32 -> Int32)"}, - {"parse", "Int32$parse", "func(text:Text, remainder:&Text? = none -> Int32?)"}, - {"get_bit", "Int32$get_bit", "func(x:Int32, bit_index:Int -> Bool)"}, - {"hex", "Int32$hex", "func(i:Int32, digits=0, uppercase=yes, prefix=yes -> Text)"}, - {"is_between", "Int32$is_between", "func(x:Int32,low:Int32,high:Int32 -> Bool)"}, - {"max", "Int32$max", "Int32"}, {"min", "Int32$min", "Int32"}, - {"modulo", "Int32$modulo", "func(x,y:Int32 -> Int32)"}, - {"modulo1", "Int32$modulo1", "func(x,y:Int32 -> Int32)"}, - {"octal", "Int32$octal", "func(i:Int32, digits=0, prefix=yes -> Text)"}, - {"onward", "Int32$onward", "func(first:Int32,step=Int32(1) -> func(->Int32?))"}, - {"to", "Int32$to", "func(first:Int32,last:Int32,step:Int32?=none -> func(->Int32?))"}, - {"unsigned_left_shifted", "Int32$unsigned_left_shifted", "func(x:Int32,y:Int32 -> Int32)"}, - {"unsigned_right_shifted", "Int32$unsigned_right_shifted", "func(x:Int32,y:Int32 -> Int32)"}, - {"wrapping_minus", "Int32$wrapping_minus", "func(x:Int32,y:Int32 -> Int32)"}, - {"wrapping_plus", "Int32$wrapping_plus", "func(x:Int32,y:Int32 -> Int32)"}, )}, - {"Int16", Type(IntType, .bits = TYPE_IBITS16), Text("Int16_t"), Text("Int16$info"), - TypedList(ns_entry_t, {"abs", "abs", "func(i:Int16 -> Int16)"}, - {"bits", "Int16$bits", "func(x:Int16 -> [Bool])"}, - {"clamped", "Int16$clamped", "func(x,low,high:Int16 -> Int16)"}, - {"divided_by", "Int16$divided_by", "func(x,y:Int16 -> Int16)"}, - {"gcd", "Int16$gcd", "func(x,y:Int16 -> Int16)"}, - {"parse", "Int16$parse", "func(text:Text, remainder:&Text? = none -> Int16?)"}, - {"get_bit", "Int16$get_bit", "func(x:Int16, bit_index:Int -> Bool)"}, - {"hex", "Int16$hex", "func(i:Int16, digits=0, uppercase=yes, prefix=yes -> Text)"}, - {"is_between", "Int16$is_between", "func(x:Int16,low:Int16,high:Int16 -> Bool)"}, - {"max", "Int16$max", "Int16"}, {"min", "Int16$min", "Int16"}, - {"modulo", "Int16$modulo", "func(x,y:Int16 -> Int16)"}, - {"modulo1", "Int16$modulo1", "func(x,y:Int16 -> Int16)"}, - {"octal", "Int16$octal", "func(i:Int16, digits=0, prefix=yes -> Text)"}, - {"onward", "Int16$onward", "func(first:Int16,step=Int16(1) -> func(->Int16?))"}, - {"to", "Int16$to", "func(first:Int16,last:Int16,step:Int16?=none -> func(->Int16?))"}, - {"unsigned_left_shifted", "Int16$unsigned_left_shifted", "func(x:Int16,y:Int16 -> Int16)"}, - {"unsigned_right_shifted", "Int16$unsigned_right_shifted", "func(x:Int16,y:Int16 -> Int16)"}, - {"wrapping_minus", "Int16$wrapping_minus", "func(x:Int16,y:Int16 -> Int16)"}, - {"wrapping_plus", "Int16$wrapping_plus", "func(x:Int16,y:Int16 -> Int16)"}, )}, - {"Int8", Type(IntType, .bits = TYPE_IBITS8), Text("Int8_t"), Text("Int8$info"), - TypedList( - ns_entry_t, {"abs", "abs", "func(i:Int8 -> Int8)"}, {"bits", "Int8$bits", "func(x:Int8 -> [Bool])"}, - {"clamped", "Int8$clamped", "func(x,low,high:Int8 -> Int8)"}, - {"divided_by", "Int8$divided_by", "func(x,y:Int8 -> Int8)"}, {"gcd", "Int8$gcd", "func(x,y:Int8 -> Int8)"}, - {"parse", "Int8$parse", "func(text:Text, remainder:&Text? = none -> Int8?)"}, - {"get_bit", "Int8$get_bit", "func(x:Int8, bit_index:Int -> Bool)"}, - {"hex", "Int8$hex", "func(i:Int8, digits=0, uppercase=yes, prefix=yes -> Text)"}, - {"is_between", "Int8$is_between", "func(x:Int8,low:Int8,high:Int8 -> Bool)"}, {"max", "Int8$max", "Int8"}, - {"min", "Int8$min", "Int8"}, {"modulo", "Int8$modulo", "func(x,y:Int8 -> Int8)"}, - {"modulo1", "Int8$modulo1", "func(x,y:Int8 -> Int8)"}, - {"octal", "Int8$octal", "func(i:Int8, digits=0, prefix=yes -> Text)"}, - {"onward", "Int8$onward", "func(first:Int8,step=Int8(1) -> func(->Int8?))"}, - {"to", "Int8$to", "func(first:Int8,last:Int8,step:Int8?=none -> func(->Int8?))"}, - {"unsigned_left_shifted", "Int8$unsigned_left_shifted", "func(x:Int8,y:Int8 -> Int8)"}, - {"unsigned_right_shifted", "Int8$unsigned_right_shifted", "func(x:Int8,y:Int8 -> Int8)"}, - {"wrapping_minus", "Int8$wrapping_minus", "func(x:Int8,y:Int8 -> Int8)"}, - {"wrapping_plus", "Int8$wrapping_plus", "func(x:Int8,y:Int8 -> Int8)"}, )}, + {"right_shifted", "Int$right_shifted", "func(x,y:Int -> Int)"}, // + {"sqrt", "Int$sqrt", "func(x:Int -> Int?)"}, // + {"times", "Int$times", "func(x,y:Int -> Int)"}, // + {"to", "Int$to", "func(first:Int,last:Int,step:Int?=none -> func(->Int?))"}), + MAKE_TYPE( // + "Int64", Type(IntType, .bits = TYPE_IBITS64), Text("Int64_t"), Text("Int64$info"), + {"abs", "labs", "func(i:Int64 -> Int64)"}, // + {"bits", "Int64$bits", "func(x:Int64 -> [Bool])"}, // + {"clamped", "Int64$clamped", "func(x,low,high:Int64 -> Int64)"}, // + {"divided_by", "Int64$divided_by", "func(x,y:Int64 -> Int64)"}, // + {"gcd", "Int64$gcd", "func(x,y:Int64 -> Int64)"}, // + {"parse", "Int64$parse", "func(text:Text, remainder:&Text? = none -> Int64?)"}, // + {"get_bit", "Int64$get_bit", "func(x:Int64, bit_index:Int -> Bool)"}, // + {"hex", "Int64$hex", "func(i:Int64, digits=0, uppercase=yes, prefix=yes -> Text)"}, // + {"is_between", "Int64$is_between", "func(x:Int64,low:Int64,high:Int64 -> Bool)"}, // + {"max", "Int64$max", "Int64"}, // + {"min", "Int64$min", "Int64"}, // + {"modulo", "Int64$modulo", "func(x,y:Int64 -> Int64)"}, // + {"modulo1", "Int64$modulo1", "func(x,y:Int64 -> Int64)"}, // + {"octal", "Int64$octal", "func(i:Int64, digits=0, prefix=yes -> Text)"}, // + {"onward", "Int64$onward", "func(first:Int64,step=Int64(1) -> func(->Int64?))"}, // + {"to", "Int64$to", "func(first:Int64,last:Int64,step:Int64?=none -> func(->Int64?))"}, // + {"unsigned_left_shifted", "Int64$unsigned_left_shifted", "func(x:Int64,y:Int64 -> Int64)"}, // + {"unsigned_right_shifted", "Int64$unsigned_right_shifted", "func(x:Int64,y:Int64 -> Int64)"}, // + {"wrapping_minus", "Int64$wrapping_minus", "func(x:Int64,y:Int64 -> Int64)"}, // + {"wrapping_plus", "Int64$wrapping_plus", "func(x:Int64,y:Int64 -> Int64)"}), + MAKE_TYPE( // + "Int32", Type(IntType, .bits = TYPE_IBITS32), Text("Int32_t"), Text("Int32$info"), // + {"abs", "abs", "func(i:Int32 -> Int32)"}, // + {"bits", "Int32$bits", "func(x:Int32 -> [Bool])"}, // + {"clamped", "Int32$clamped", "func(x,low,high:Int32 -> Int32)"}, // + {"divided_by", "Int32$divided_by", "func(x,y:Int32 -> Int32)"}, // + {"gcd", "Int32$gcd", "func(x,y:Int32 -> Int32)"}, // + {"parse", "Int32$parse", "func(text:Text, remainder:&Text? = none -> Int32?)"}, // + {"get_bit", "Int32$get_bit", "func(x:Int32, bit_index:Int -> Bool)"}, // + {"hex", "Int32$hex", "func(i:Int32, digits=0, uppercase=yes, prefix=yes -> Text)"}, // + {"is_between", "Int32$is_between", "func(x:Int32,low:Int32,high:Int32 -> Bool)"}, // + {"max", "Int32$max", "Int32"}, // + {"min", "Int32$min", "Int32"}, // + {"modulo", "Int32$modulo", "func(x,y:Int32 -> Int32)"}, // + {"modulo1", "Int32$modulo1", "func(x,y:Int32 -> Int32)"}, // + {"octal", "Int32$octal", "func(i:Int32, digits=0, prefix=yes -> Text)"}, // + {"onward", "Int32$onward", "func(first:Int32,step=Int32(1) -> func(->Int32?))"}, // + {"to", "Int32$to", "func(first:Int32,last:Int32,step:Int32?=none -> func(->Int32?))"}, // + {"unsigned_left_shifted", "Int32$unsigned_left_shifted", "func(x:Int32,y:Int32 -> Int32)"}, // + {"unsigned_right_shifted", "Int32$unsigned_right_shifted", "func(x:Int32,y:Int32 -> Int32)"}, // + {"wrapping_minus", "Int32$wrapping_minus", "func(x:Int32,y:Int32 -> Int32)"}, // + {"wrapping_plus", "Int32$wrapping_plus", "func(x:Int32,y:Int32 -> Int32)"}), + MAKE_TYPE( // + "Int16", Type(IntType, .bits = TYPE_IBITS16), Text("Int16_t"), Text("Int16$info"), + {"abs", "abs", "func(i:Int16 -> Int16)"}, // + {"bits", "Int16$bits", "func(x:Int16 -> [Bool])"}, // + {"clamped", "Int16$clamped", "func(x,low,high:Int16 -> Int16)"}, // + {"divided_by", "Int16$divided_by", "func(x,y:Int16 -> Int16)"}, // + {"gcd", "Int16$gcd", "func(x,y:Int16 -> Int16)"}, // + {"parse", "Int16$parse", "func(text:Text, remainder:&Text? = none -> Int16?)"}, // + {"get_bit", "Int16$get_bit", "func(x:Int16, bit_index:Int -> Bool)"}, // + {"hex", "Int16$hex", "func(i:Int16, digits=0, uppercase=yes, prefix=yes -> Text)"}, // + {"is_between", "Int16$is_between", "func(x:Int16,low:Int16,high:Int16 -> Bool)"}, // + {"max", "Int16$max", "Int16"}, // + {"min", "Int16$min", "Int16"}, // + {"modulo", "Int16$modulo", "func(x,y:Int16 -> Int16)"}, // + {"modulo1", "Int16$modulo1", "func(x,y:Int16 -> Int16)"}, // + {"octal", "Int16$octal", "func(i:Int16, digits=0, prefix=yes -> Text)"}, // + {"onward", "Int16$onward", "func(first:Int16,step=Int16(1) -> func(->Int16?))"}, // + {"to", "Int16$to", "func(first:Int16,last:Int16,step:Int16?=none -> func(->Int16?))"}, // + {"unsigned_left_shifted", "Int16$unsigned_left_shifted", "func(x:Int16,y:Int16 -> Int16)"}, // + {"unsigned_right_shifted", "Int16$unsigned_right_shifted", "func(x:Int16,y:Int16 -> Int16)"}, // + {"wrapping_minus", "Int16$wrapping_minus", "func(x:Int16,y:Int16 -> Int16)"}, // + {"wrapping_plus", "Int16$wrapping_plus", "func(x:Int16,y:Int16 -> Int16)"}), + MAKE_TYPE( // + "Int8", Type(IntType, .bits = TYPE_IBITS8), Text("Int8_t"), Text("Int8$info"), + {"abs", "abs", "func(i:Int8 -> Int8)"}, // + {"bits", "Int8$bits", "func(x:Int8 -> [Bool])"}, // + {"clamped", "Int8$clamped", "func(x,low,high:Int8 -> Int8)"}, // + {"divided_by", "Int8$divided_by", "func(x,y:Int8 -> Int8)"}, // + {"gcd", "Int8$gcd", "func(x,y:Int8 -> Int8)"}, // + {"parse", "Int8$parse", "func(text:Text, remainder:&Text? = none -> Int8?)"}, // + {"get_bit", "Int8$get_bit", "func(x:Int8, bit_index:Int -> Bool)"}, // + {"hex", "Int8$hex", "func(i:Int8, digits=0, uppercase=yes, prefix=yes -> Text)"}, // + {"is_between", "Int8$is_between", "func(x:Int8,low:Int8,high:Int8 -> Bool)"}, // + {"max", "Int8$max", "Int8"}, // + {"min", "Int8$min", "Int8"}, // + {"modulo", "Int8$modulo", "func(x,y:Int8 -> Int8)"}, // + {"modulo1", "Int8$modulo1", "func(x,y:Int8 -> Int8)"}, // + {"octal", "Int8$octal", "func(i:Int8, digits=0, prefix=yes -> Text)"}, // + {"onward", "Int8$onward", "func(first:Int8,step=Int8(1) -> func(->Int8?))"}, // + {"to", "Int8$to", "func(first:Int8,last:Int8,step:Int8?=none -> func(->Int8?))"}, // + {"unsigned_left_shifted", "Int8$unsigned_left_shifted", "func(x:Int8,y:Int8 -> Int8)"}, // + {"unsigned_right_shifted", "Int8$unsigned_right_shifted", "func(x:Int8,y:Int8 -> Int8)"}, // + {"wrapping_minus", "Int8$wrapping_minus", "func(x:Int8,y:Int8 -> Int8)"}, // + {"wrapping_plus", "Int8$wrapping_plus", "func(x:Int8,y:Int8 -> Int8)"}, ), #define C(name) {#name, "M_" #name, "Num"} #define F(name) {#name, #name, "func(n:Num -> Num)"} #define F_opt(name) {#name, #name, "func(n:Num -> Num?)"} #define F2(name) {#name, #name, "func(x,y:Num -> Num)"} - {"Num", Type(NumType, .bits = TYPE_NBITS64), Text("Num_t"), Text("Num$info"), - TypedList(ns_entry_t, {"near", "Num$near", "func(x,y:Num, ratio=1e-9, min_epsilon=1e-9 -> Bool)"}, - {"clamped", "Num$clamped", "func(x,low,high:Num -> Num)"}, - {"percent", "Num$percent", "func(n:Num,precision=0.01 -> Text)"}, - {"with_precision", "Num$with_precision", "func(n:Num,precision:Num -> Num)"}, - {"is_between", "Num$is_between", "func(x:Num,low:Num,high:Num -> Bool)"}, - {"isinf", "Num$isinf", "func(n:Num -> Bool)"}, {"isfinite", "Num$isfinite", "func(n:Num -> Bool)"}, - {"modulo", "Num$mod", "func(x,y:Num -> Num)"}, {"modulo1", "Num$mod1", "func(x,y:Num -> Num)"}, - C(2_SQRTPI), C(E), C(PI_2), C(2_PI), C(1_PI), C(LN10), C(LN2), C(LOG2E), C(PI), C(PI_4), C(SQRT2), - C(SQRT1_2), {"INF", "(Num_t)(INFINITY)", "Num"}, {"TAU", "(Num_t)(2.*M_PI)", "Num"}, - {"mix", "Num$mix", "func(amount,x,y:Num -> Num)"}, - {"parse", "Num$parse", "func(text:Text, remainder:&Text? = none -> Num?)"}, - {"abs", "fabs", "func(n:Num -> Num)"}, F_opt(acos), F_opt(acosh), F_opt(asin), F(asinh), F(atan), - F_opt(atanh), F(cbrt), F(ceil), F_opt(cos), F(cosh), F(erf), F(erfc), F(exp), F(exp2), F(expm1), - F(floor), F(j0), F(j1), F_opt(log), F_opt(log10), F_opt(log1p), F_opt(log2), F(logb), F(rint), - F(round), F(significand), F_opt(sin), F(sinh), F_opt(sqrt), F_opt(tan), F(tanh), F_opt(tgamma), - F(trunc), F_opt(y0), F_opt(y1), F2(atan2), F2(copysign), F2(fdim), F2(hypot), F2(nextafter), )}, + MAKE_TYPE( // + "Num", Type(NumType, .bits = TYPE_NBITS64), Text("Num_t"), Text("Num$info"), + {"near", "Num$near", "func(x,y:Num, ratio=1e-9, min_epsilon=1e-9 -> Bool)"}, // + {"clamped", "Num$clamped", "func(x,low,high:Num -> Num)"}, // + {"percent", "Num$percent", "func(n:Num,precision=0.01 -> Text)"}, // + {"with_precision", "Num$with_precision", "func(n:Num,precision:Num -> Num)"}, // + {"is_between", "Num$is_between", "func(x:Num,low:Num,high:Num -> Bool)"}, // + {"isinf", "Num$isinf", "func(n:Num -> Bool)"}, // + {"isfinite", "Num$isfinite", "func(n:Num -> Bool)"}, // + {"modulo", "Num$mod", "func(x,y:Num -> Num)"}, // + {"modulo1", "Num$mod1", "func(x,y:Num -> Num)"}, // + C(2_SQRTPI), C(E), C(PI_2), C(2_PI), C(1_PI), C(LN10), C(LN2), C(LOG2E), C(PI), C(PI_4), C(SQRT2), + C(SQRT1_2), {"INF", "(Num_t)(INFINITY)", "Num"}, // + {"TAU", "(Num_t)(2.*M_PI)", "Num"}, // + {"mix", "Num$mix", "func(amount,x,y:Num -> Num)"}, // + {"parse", "Num$parse", "func(text:Text, remainder:&Text? = none -> Num?)"}, // + {"abs", "fabs", "func(n:Num -> Num)"}, // + F_opt(acos), F_opt(acosh), F_opt(asin), F(asinh), F(atan), F_opt(atanh), F(cbrt), F(ceil), F_opt(cos), + F(cosh), F(erf), F(erfc), F(exp), F(exp2), F(expm1), F(floor), F(j0), F(j1), F_opt(log), F_opt(log10), + F_opt(log1p), F_opt(log2), F(logb), F(rint), F(round), F(significand), F_opt(sin), F(sinh), F_opt(sqrt), + F_opt(tan), F(tanh), F_opt(tgamma), F(trunc), F_opt(y0), F_opt(y1), F2(atan2), F2(copysign), F2(fdim), + F2(hypot), F2(nextafter)), #undef F2 #undef F_opt #undef F @@ -225,121 +252,132 @@ env_t *global_env(bool source_mapping) { #define F(name) {#name, #name "f", "func(n:Num32 -> Num32)"} #define F_opt(name) {#name, #name "f", "func(n:Num32 -> Num32?)"} #define F2(name) {#name, #name "f", "func(x,y:Num32 -> Num32)"} - {"Num32", Type(NumType, .bits = TYPE_NBITS32), Text("Num32_t"), Text("Num32$info"), - TypedList( - ns_entry_t, {"near", "Num32$near", "func(x,y:Num32, ratio=Num32(1e-9), min_epsilon=Num32(1e-9) -> Bool)"}, - {"clamped", "Num32$clamped", "func(x,low,high:Num32 -> Num32)"}, - {"percent", "Num32$percent", "func(n:Num32,precision=Num32(.01) -> Text)"}, - {"with_precision", "Num32$with_precision", "func(n:Num32,precision:Num32 -> Num32)"}, - {"is_between", "Num32$is_between", "func(x:Num32,low:Num32,high:Num32 -> Bool)"}, - {"isinf", "Num32$isinf", "func(n:Num32 -> Bool)"}, {"isfinite", "Num32$isfinite", "func(n:Num32 -> Bool)"}, - C(2_SQRTPI), C(E), C(PI_2), C(2_PI), C(1_PI), C(LN10), C(LN2), C(LOG2E), C(PI), C(PI_4), C(SQRT2), - C(SQRT1_2), {"INF", "(Num32_t)(INFINITY)", "Num32"}, {"TAU", "(Num32_t)(2.f*M_PI)", "Num32"}, - {"mix", "Num32$mix", "func(amount,x,y:Num32 -> Num32)"}, - {"parse", "Num32$parse", "func(text:Text, remainder:&Text? = none -> Num32?)"}, - {"abs", "fabsf", "func(n:Num32 -> Num32)"}, {"modulo", "Num32$mod", "func(x,y:Num32 -> Num32)"}, - {"modulo1", "Num32$mod1", "func(x,y:Num32 -> Num32)"}, F_opt(acos), F_opt(acosh), F_opt(asin), F(asinh), - F(atan), F_opt(atanh), F(cbrt), F(ceil), F_opt(cos), F(cosh), F(erf), F(erfc), F(exp), F(exp2), F(expm1), - F(floor), F(j0), F(j1), F_opt(log), F_opt(log10), F_opt(log1p), F_opt(log2), F(logb), F(rint), F(round), - F(significand), F_opt(sin), F(sinh), F_opt(sqrt), F_opt(tan), F(tanh), F_opt(tgamma), F(trunc), F_opt(y0), - F_opt(y1), F2(atan2), F2(copysign), F2(fdim), F2(hypot), F2(nextafter), )}, - {"CString", Type(CStringType), Text("char*"), Text("CString$info"), - TypedList(ns_entry_t, {"as_text", "Text$from_str", "func(str:CString -> Text)"}, )}, + MAKE_TYPE( // + "Num32", Type(NumType, .bits = TYPE_NBITS32), Text("Num32_t"), Text("Num32$info"), // + {"near", "Num32$near", "func(x,y:Num32, ratio=Num32(1e-9), min_epsilon=Num32(1e-9) -> Bool)"}, // + {"clamped", "Num32$clamped", "func(x,low,high:Num32 -> Num32)"}, // + {"percent", "Num32$percent", "func(n:Num32,precision=Num32(.01) -> Text)"}, // + {"with_precision", "Num32$with_precision", "func(n:Num32,precision:Num32 -> Num32)"}, // + {"is_between", "Num32$is_between", "func(x:Num32,low:Num32,high:Num32 -> Bool)"}, // + {"isinf", "Num32$isinf", "func(n:Num32 -> Bool)"}, // + {"isfinite", "Num32$isfinite", "func(n:Num32 -> Bool)"}, // + C(2_SQRTPI), C(E), C(PI_2), C(2_PI), C(1_PI), C(LN10), C(LN2), C(LOG2E), C(PI), C(PI_4), C(SQRT2), + C(SQRT1_2), // + {"INF", "(Num32_t)(INFINITY)", "Num32"}, // + {"TAU", "(Num32_t)(2.f*M_PI)", "Num32"}, // + {"mix", "Num32$mix", "func(amount,x,y:Num32 -> Num32)"}, // + {"parse", "Num32$parse", "func(text:Text, remainder:&Text? = none -> Num32?)"}, // + {"abs", "fabsf", "func(n:Num32 -> Num32)"}, // + {"modulo", "Num32$mod", "func(x,y:Num32 -> Num32)"}, // + {"modulo1", "Num32$mod1", "func(x,y:Num32 -> Num32)"}, // + F_opt(acos), F_opt(acosh), F_opt(asin), F(asinh), F(atan), F_opt(atanh), F(cbrt), F(ceil), F_opt(cos), + F(cosh), F(erf), F(erfc), F(exp), F(exp2), F(expm1), F(floor), F(j0), F(j1), F_opt(log), F_opt(log10), + F_opt(log1p), F_opt(log2), F(logb), F(rint), F(round), F(significand), F_opt(sin), F(sinh), F_opt(sqrt), + F_opt(tan), F(tanh), F_opt(tgamma), F(trunc), F_opt(y0), F_opt(y1), F2(atan2), F2(copysign), F2(fdim), + F2(hypot), F2(nextafter)), + MAKE_TYPE( // + "CString", Type(CStringType), Text("char*"), Text("CString$info"), // + {"as_text", "Text$from_str", "func(str:CString -> Text)"}), #undef F2 #undef F_opt #undef F #undef C - {"PathType", PATH_TYPE_TYPE, Text("PathType_t"), Text("PathType$info"), - TypedList(ns_entry_t, {"Relative", "((PathType_t){.$tag=PATH_RELATIVE})", "PathType"}, - {"Absolute", "((PathType_t){.$tag=PATH_ABSOLUTE})", "PathType"}, - {"Home", "((PathType_t){.$tag=PATH_HOME})", "PathType"}, )}, - {"Path", PATH_TYPE, Text("Path_t"), Text("Path$info"), - TypedList( - ns_entry_t, {"accessed", "Path$accessed", "func(path:Path, follow_symlinks=yes -> Int64?)"}, - {"append", "Path$append", "func(path:Path, text:Text, permissions=Int32(0o644))"}, - {"append_bytes", "Path$append_bytes", "func(path:Path, bytes:[Byte], permissions=Int32(0o644))"}, - {"base_name", "Path$base_name", "func(path:Path -> Text)"}, - {"by_line", "Path$by_line", "func(path:Path -> func(->Text?)?)"}, - {"can_execute", "Path$can_execute", "func(path:Path -> Bool)"}, - {"can_read", "Path$can_read", "func(path:Path -> Bool)"}, - {"can_write", "Path$can_write", "func(path:Path -> Bool)"}, - {"changed", "Path$changed", "func(path:Path, follow_symlinks=yes -> Int64?)"}, - {"child", "Path$child", "func(path:Path, child:Text -> Path)"}, - {"children", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, - {"concatenated_with", "Path$concat", "func(a,b:Path -> Path)"}, - {"create_directory", "Path$create_directory", "func(path:Path, permissions=Int32(0o755))"}, - {"current_dir", "Path$current_dir", "func(->Path)"}, {"exists", "Path$exists", "func(path:Path -> Bool)"}, - {"expand_home", "Path$expand_home", "func(path:Path -> Path)"}, - {"extension", "Path$extension", "func(path:Path, full=yes -> Text)"}, - {"files", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, - {"from_components", "Path$from_components", "func(components:[Text] -> Path)"}, - {"glob", "Path$glob", "func(path:Path -> [Path])"}, - {"group", "Path$group", "func(path:Path, follow_symlinks=yes -> Text?)"}, - {"has_extension", "Path$has_extension", "func(path:Path, extension:Text -> Bool)"}, - {"is_directory", "Path$is_directory", "func(path:Path, follow_symlinks=yes -> Bool)"}, - {"is_file", "Path$is_file", "func(path:Path, follow_symlinks=yes -> Bool)"}, - {"is_pipe", "Path$is_pipe", "func(path:Path, follow_symlinks=yes -> Bool)"}, - {"is_socket", "Path$is_socket", "func(path:Path, follow_symlinks=yes -> Bool)"}, - {"is_symlink", "Path$is_symlink", "func(path:Path -> Bool)"}, - {"modified", "Path$modified", "func(path:Path, follow_symlinks=yes -> Int64?)"}, - {"owner", "Path$owner", "func(path:Path, follow_symlinks=yes -> Text?)"}, - {"parent", "Path$parent", "func(path:Path -> Path)"}, {"read", "Path$read", "func(path:Path -> Text?)"}, - {"read_bytes", "Path$read_bytes", "func(path:Path, limit:Int?=none -> [Byte]?)"}, - {"relative_to", "Path$relative_to", "func(path:Path, relative_to:Path -> Path)"}, - {"remove", "Path$remove", "func(path:Path, ignore_missing=no)"}, - {"resolved", "Path$resolved", "func(path:Path, relative_to=(./) -> Path)"}, - {"set_owner", "Path$set_owner", - "func(path:Path, owner:Text?=none, group:Text?=none, follow_symlinks=yes)"}, - {"sibling", "Path$sibling", "func(path:Path, name:Text -> Path)"}, - {"subdirectories", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, - {"unique_directory", "Path$unique_directory", "func(path:Path -> Path)"}, - {"write", "Path$write", "func(path:Path, text:Text, permissions=Int32(0o644))"}, - {"write_bytes", "Path$write_bytes", "func(path:Path, bytes:[Byte], permissions=Int32(0o644))"}, - {"write_unique", "Path$write_unique", "func(path:Path, text:Text -> Path)"}, - {"write_unique_bytes", "Path$write_unique_bytes", "func(path:Path, bytes:[Byte] -> Path)"}, )}, - {"Text", TEXT_TYPE, Text("Text_t"), Text("Text$info"), - TypedList(ns_entry_t, {"as_c_string", "Text$as_c_string", "func(text:Text -> CString)"}, - {"at", "Text$cluster", "func(text:Text, index:Int -> Text)"}, - {"by_line", "Text$by_line", "func(text:Text -> func(->Text?))"}, - {"by_split", "Text$by_split", "func(text:Text, delimiter='' -> func(->Text?))"}, - {"by_split_any", "Text$by_split_any", "func(text:Text, delimiters=' \\t\\r\\n' -> func(->Text?))"}, - {"bytes", "Text$utf8_bytes", "func(text:Text -> [Byte])"}, - {"caseless_equals", "Text$equal_ignoring_case", "func(a,b:Text, language='C' -> Bool)"}, - {"codepoint_names", "Text$codepoint_names", "func(text:Text -> [Text])"}, - {"ends_with", "Text$ends_with", "func(text,suffix:Text, remainder:&Text? = none -> Bool)"}, - {"from", "Text$from", "func(text:Text, first:Int -> Text)"}, - {"from_bytes", "Text$from_bytes", "func(bytes:[Byte] -> Text?)"}, - {"from_c_string", "Text$from_str", "func(str:CString -> Text?)"}, - {"from_codepoint_names", "Text$from_codepoint_names", "func(codepoint_names:[Text] -> Text?)"}, - {"from_codepoints", "Text$from_codepoints", "func(codepoints:[Int32] -> Text)"}, - {"from_text", "Path$from_text", "func(text:Text -> Path)"}, - {"has", "Text$has", "func(text:Text, target:Text -> Bool)"}, - {"join", "Text$join", "func(glue:Text, pieces:[Text] -> Text)"}, - {"layout", "Text$layout", "func(text:Text -> Text)"}, - {"left_pad", "Text$left_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, - {"lines", "Text$lines", "func(text:Text -> [Text])"}, - {"lower", "Text$lower", "func(text:Text, language='C' -> Text)"}, - {"memory_size", "Text$memory_size", "func(text:Text -> Int)"}, - {"middle_pad", "Text$middle_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, - {"quoted", "Text$quoted", "func(text:Text, color=no, quotation_mark='\"' -> Text)"}, - {"repeat", "Text$repeat", "func(text:Text, count:Int -> Text)"}, - {"replace", "Text$replace", "func(text:Text, target:Text, replacement:Text -> Text)"}, - {"reversed", "Text$reversed", "func(text:Text -> Text)"}, - {"right_pad", "Text$right_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, - {"slice", "Text$slice", "func(text:Text, from=1, to=-1 -> Text)"}, - {"split", "Text$split", "func(text:Text, delimiter='' -> [Text])"}, - {"split_any", "Text$split_any", "func(text:Text, delimiters=' \\t\\r\\n' -> [Text])"}, - {"starts_with", "Text$starts_with", "func(text,prefix:Text, remainder:&Text? = none -> Bool)"}, - {"title", "Text$title", "func(text:Text, language='C' -> Text)"}, - {"to", "Text$to", "func(text:Text, last:Int -> Text)"}, - {"translate", "Text$translate", "func(text:Text, translations:{Text=Text} -> Text)"}, - {"trim", "Text$trim", "func(text:Text, to_trim=\" \t\r\n\", left=yes, right=yes -> Text)"}, - {"upper", "Text$upper", "func(text:Text, language='C' -> Text)"}, - {"utf32_codepoints", "Text$utf32_codepoints", "func(text:Text -> [Int32])"}, - {"width", "Text$width", "func(text:Text, language='C' -> Int)"}, - {"without_prefix", "Text$without_prefix", "func(text,prefix:Text -> Text)"}, - {"without_suffix", "Text$without_suffix", "func(text,suffix:Text -> Text)"}, )}, + MAKE_TYPE( // + "PathType", PATH_TYPE_TYPE, Text("PathType_t"), Text("PathType$info"), // + {"Relative", "((PathType_t){.$tag=PATH_RELATIVE})", "PathType"}, // + {"Absolute", "((PathType_t){.$tag=PATH_ABSOLUTE})", "PathType"}, // + {"Home", "((PathType_t){.$tag=PATH_HOME})", "PathType"}), + MAKE_TYPE( // + "Path", PATH_TYPE, Text("Path_t"), Text("Path$info"), // + {"accessed", "Path$accessed", "func(path:Path, follow_symlinks=yes -> Int64?)"}, // + {"append", "Path$append", "func(path:Path, text:Text, permissions=Int32(0o644))"}, // + {"append_bytes", "Path$append_bytes", "func(path:Path, bytes:[Byte], permissions=Int32(0o644))"}, // + {"base_name", "Path$base_name", "func(path:Path -> Text)"}, // + {"by_line", "Path$by_line", "func(path:Path -> func(->Text?)?)"}, // + {"can_execute", "Path$can_execute", "func(path:Path -> Bool)"}, // + {"can_read", "Path$can_read", "func(path:Path -> Bool)"}, // + {"can_write", "Path$can_write", "func(path:Path -> Bool)"}, // + {"changed", "Path$changed", "func(path:Path, follow_symlinks=yes -> Int64?)"}, // + {"child", "Path$child", "func(path:Path, child:Text -> Path)"}, // + {"children", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, // + {"concatenated_with", "Path$concat", "func(a,b:Path -> Path)"}, // + {"create_directory", "Path$create_directory", "func(path:Path, permissions=Int32(0o755))"}, // + {"current_dir", "Path$current_dir", "func(->Path)"}, // + {"exists", "Path$exists", "func(path:Path -> Bool)"}, // + {"expand_home", "Path$expand_home", "func(path:Path -> Path)"}, // + {"extension", "Path$extension", "func(path:Path, full=yes -> Text)"}, // + {"files", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, // + {"from_components", "Path$from_components", "func(components:[Text] -> Path)"}, // + {"glob", "Path$glob", "func(path:Path -> [Path])"}, // + {"group", "Path$group", "func(path:Path, follow_symlinks=yes -> Text?)"}, // + {"has_extension", "Path$has_extension", "func(path:Path, extension:Text -> Bool)"}, // + {"is_directory", "Path$is_directory", "func(path:Path, follow_symlinks=yes -> Bool)"}, // + {"is_file", "Path$is_file", "func(path:Path, follow_symlinks=yes -> Bool)"}, // + {"is_pipe", "Path$is_pipe", "func(path:Path, follow_symlinks=yes -> Bool)"}, // + {"is_socket", "Path$is_socket", "func(path:Path, follow_symlinks=yes -> Bool)"}, // + {"is_symlink", "Path$is_symlink", "func(path:Path -> Bool)"}, // + {"modified", "Path$modified", "func(path:Path, follow_symlinks=yes -> Int64?)"}, // + {"owner", "Path$owner", "func(path:Path, follow_symlinks=yes -> Text?)"}, // + {"parent", "Path$parent", "func(path:Path -> Path)"}, // + {"read", "Path$read", "func(path:Path -> Text?)"}, // + {"read_bytes", "Path$read_bytes", "func(path:Path, limit:Int?=none -> [Byte]?)"}, // + {"relative_to", "Path$relative_to", "func(path:Path, relative_to:Path -> Path)"}, // + {"remove", "Path$remove", "func(path:Path, ignore_missing=no)"}, // + {"resolved", "Path$resolved", "func(path:Path, relative_to=(./) -> Path)"}, // + {"set_owner", "Path$set_owner", // + "func(path:Path, owner:Text?=none, group:Text?=none, follow_symlinks=yes)"}, // + {"sibling", "Path$sibling", "func(path:Path, name:Text -> Path)"}, // + {"subdirectories", "Path$children", "func(path:Path, include_hidden=no -> [Path])"}, // + {"unique_directory", "Path$unique_directory", "func(path:Path -> Path)"}, // + {"write", "Path$write", "func(path:Path, text:Text, permissions=Int32(0o644))"}, // + {"write_bytes", "Path$write_bytes", "func(path:Path, bytes:[Byte], permissions=Int32(0o644))"}, // + {"write_unique", "Path$write_unique", "func(path:Path, text:Text -> Path)"}, // + {"write_unique_bytes", "Path$write_unique_bytes", "func(path:Path, bytes:[Byte] -> Path)"}), + MAKE_TYPE( // + "Text", TEXT_TYPE, Text("Text_t"), Text("Text$info"), // + {"as_c_string", "Text$as_c_string", "func(text:Text -> CString)"}, // + {"at", "Text$cluster", "func(text:Text, index:Int -> Text)"}, // + {"by_line", "Text$by_line", "func(text:Text -> func(->Text?))"}, // + {"by_split", "Text$by_split", "func(text:Text, delimiter='' -> func(->Text?))"}, // + {"by_split_any", "Text$by_split_any", "func(text:Text, delimiters=' \\t\\r\\n' -> func(->Text?))"}, // + {"bytes", "Text$utf8_bytes", "func(text:Text -> [Byte])"}, // + {"caseless_equals", "Text$equal_ignoring_case", "func(a,b:Text, language='C' -> Bool)"}, // + {"codepoint_names", "Text$codepoint_names", "func(text:Text -> [Text])"}, // + {"ends_with", "Text$ends_with", "func(text,suffix:Text, remainder:&Text? = none -> Bool)"}, // + {"from", "Text$from", "func(text:Text, first:Int -> Text)"}, // + {"from_bytes", "Text$from_bytes", "func(bytes:[Byte] -> Text?)"}, // + {"from_c_string", "Text$from_str", "func(str:CString -> Text?)"}, // + {"from_codepoint_names", "Text$from_codepoint_names", "func(codepoint_names:[Text] -> Text?)"}, // + {"from_codepoints", "Text$from_codepoints", "func(codepoints:[Int32] -> Text)"}, // + {"from_text", "Path$from_text", "func(text:Text -> Path)"}, // + {"has", "Text$has", "func(text:Text, target:Text -> Bool)"}, // + {"join", "Text$join", "func(glue:Text, pieces:[Text] -> Text)"}, // + {"layout", "Text$layout", "func(text:Text -> Text)"}, // + {"left_pad", "Text$left_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, // + {"lines", "Text$lines", "func(text:Text -> [Text])"}, // + {"lower", "Text$lower", "func(text:Text, language='C' -> Text)"}, // + {"memory_size", "Text$memory_size", "func(text:Text -> Int)"}, // + {"middle_pad", "Text$middle_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, // + {"quoted", "Text$quoted", "func(text:Text, color=no, quotation_mark='\"' -> Text)"}, // + {"repeat", "Text$repeat", "func(text:Text, count:Int -> Text)"}, // + {"replace", "Text$replace", "func(text:Text, target:Text, replacement:Text -> Text)"}, // + {"reversed", "Text$reversed", "func(text:Text -> Text)"}, // + {"right_pad", "Text$right_pad", "func(text:Text, count:Int, pad=' ', language='C' -> Text)"}, // + {"slice", "Text$slice", "func(text:Text, from=1, to=-1 -> Text)"}, // + {"split", "Text$split", "func(text:Text, delimiter='' -> [Text])"}, // + {"split_any", "Text$split_any", "func(text:Text, delimiters=' \\t\\r\\n' -> [Text])"}, // + {"starts_with", "Text$starts_with", "func(text,prefix:Text, remainder:&Text? = none -> Bool)"}, // + {"title", "Text$title", "func(text:Text, language='C' -> Text)"}, // + {"to", "Text$to", "func(text:Text, last:Int -> Text)"}, // + {"translate", "Text$translate", "func(text:Text, translations:{Text=Text} -> Text)"}, // + {"trim", "Text$trim", "func(text:Text, to_trim=\" \t\r\n\", left=yes, right=yes -> Text)"}, // + {"upper", "Text$upper", "func(text:Text, language='C' -> Text)"}, // + {"utf32_codepoints", "Text$utf32_codepoints", "func(text:Text -> [Int32])"}, // + {"width", "Text$width", "func(text:Text, language='C' -> Int)"}, // + {"without_prefix", "Text$without_prefix", "func(text,prefix:Text -> Text)"}, // + {"without_suffix", "Text$without_suffix", "func(text,suffix:Text -> Text)"}), }; +#undef MAKE_TYPE for (size_t i = 0; i < sizeof(global_types) / sizeof(global_types[0]); i++) { env_t *ns_env = NULL; @@ -371,7 +409,7 @@ env_t *global_env(bool source_mapping) { } } - // Conversion constructors: +// Conversion constructors: #define ADD_CONSTRUCTORS(type_name, ...) \ do { \ env_t *ns_env = namespace_env(env, type_name); \ @@ -387,60 +425,89 @@ env_t *global_env(bool source_mapping) { } \ } while (0) - ADD_CONSTRUCTORS("Bool", {"Bool$from_byte", "func(b:Byte -> Bool)"}, {"Bool$from_int8", "func(i:Int8 -> Bool)"}, - {"Bool$from_int16", "func(i:Int16 -> Bool)"}, {"Bool$from_int32", "func(i:Int32 -> Bool)"}, - {"Bool$from_int64", "func(i:Int64 -> Bool)"}, {"Bool$from_int", "func(i:Int -> Bool)"}); - ADD_CONSTRUCTORS("Byte", {"Byte$from_bool", "func(b:Bool -> Byte)"}, {"Byte$from_int8", "func(i:Int8 -> Byte)"}, - {"Byte$from_int16", "func(i:Int16, truncate=no -> Byte)"}, - {"Byte$from_int32", "func(i:Int32, truncate=no -> Byte)"}, - {"Byte$from_int64", "func(i:Int64, truncate=no -> Byte)"}, + ADD_CONSTRUCTORS("Bool", // + {"Bool$from_byte", "func(b:Byte -> Bool)"}, // + {"Bool$from_int8", "func(i:Int8 -> Bool)"}, // + {"Bool$from_int16", "func(i:Int16 -> Bool)"}, // + {"Bool$from_int32", "func(i:Int32 -> Bool)"}, // + {"Bool$from_int64", "func(i:Int64 -> Bool)"}, // + {"Bool$from_int", "func(i:Int -> Bool)"}); + ADD_CONSTRUCTORS("Byte", // + {"Byte$from_bool", "func(b:Bool -> Byte)"}, // + {"Byte$from_int8", "func(i:Int8 -> Byte)"}, // + {"Byte$from_int16", "func(i:Int16, truncate=no -> Byte)"}, // + {"Byte$from_int32", "func(i:Int32, truncate=no -> Byte)"}, // + {"Byte$from_int64", "func(i:Int64, truncate=no -> Byte)"}, // {"Byte$from_int", "func(i:Int, truncate=no -> Byte)"}); - ADD_CONSTRUCTORS("Int", {"Int$from_bool", "func(b:Bool -> Int)"}, {"Int$from_byte", "func(b:Byte -> Int)"}, - {"Int$from_int8", "func(i:Int8 -> Int)"}, {"Int$from_int16", "func(i:Int16 -> Int)"}, - {"Int$from_int32", "func(i:Int32 -> Int)"}, {"Int$from_int64", "func(i:Int64 -> Int)"}, - {"Int$from_num", "func(n:Num, truncate=no -> Int)"}, + ADD_CONSTRUCTORS("Int", // + {"Int$from_bool", "func(b:Bool -> Int)"}, // + {"Int$from_byte", "func(b:Byte -> Int)"}, // + {"Int$from_int8", "func(i:Int8 -> Int)"}, // + {"Int$from_int16", "func(i:Int16 -> Int)"}, // + {"Int$from_int32", "func(i:Int32 -> Int)"}, // + {"Int$from_int64", "func(i:Int64 -> Int)"}, // + {"Int$from_num", "func(n:Num, truncate=no -> Int)"}, // {"Int$from_num32", "func(n:Num32, truncate=no -> Int)"}); - ADD_CONSTRUCTORS("Int64", {"Int64$from_bool", "func(b:Bool -> Int64)"}, - {"Int64$from_byte", "func(b:Byte -> Int64)"}, {"Int64$from_int8", "func(i:Int8 -> Int64)"}, - {"Int64$from_int16", "func(i:Int16 -> Int64)"}, {"Int64$from_int32", "func(i:Int32 -> Int64)"}, - {"Int64$from_int", "func(i:Int, truncate=no -> Int64)"}, - {"Int64$from_num", "func(n:Num, truncate=no -> Int64)"}, + ADD_CONSTRUCTORS("Int64", // + {"Int64$from_bool", "func(b:Bool -> Int64)"}, // + {"Int64$from_byte", "func(b:Byte -> Int64)"}, // + {"Int64$from_int8", "func(i:Int8 -> Int64)"}, // + {"Int64$from_int16", "func(i:Int16 -> Int64)"}, // + {"Int64$from_int32", "func(i:Int32 -> Int64)"}, // + {"Int64$from_int", "func(i:Int, truncate=no -> Int64)"}, // + {"Int64$from_num", "func(n:Num, truncate=no -> Int64)"}, // {"Int64$from_num32", "func(n:Num32, truncate=no -> Int64)"}); - ADD_CONSTRUCTORS("Int32", {"Int32$from_bool", "func(b:Bool -> Int32)"}, - {"Int32$from_byte", "func(b:Byte -> Int32)"}, {"Int32$from_int8", "func(i:Int8 -> Int32)"}, - {"Int32$from_int16", "func(i:Int16 -> Int32)"}, - {"Int32$from_int64", "func(i:Int64, truncate=no -> Int32)"}, - {"Int32$from_int", "func(i:Int, truncate=no -> Int32)"}, - {"Int32$from_num", "func(n:Num, truncate=no -> Int32)"}, + ADD_CONSTRUCTORS("Int32", // + {"Int32$from_bool", "func(b:Bool -> Int32)"}, // + {"Int32$from_byte", "func(b:Byte -> Int32)"}, // + {"Int32$from_int8", "func(i:Int8 -> Int32)"}, // + {"Int32$from_int16", "func(i:Int16 -> Int32)"}, // + {"Int32$from_int64", "func(i:Int64, truncate=no -> Int32)"}, // + {"Int32$from_int", "func(i:Int, truncate=no -> Int32)"}, // + {"Int32$from_num", "func(n:Num, truncate=no -> Int32)"}, // {"Int32$from_num32", "func(n:Num32, truncate=no -> Int32)"}); - ADD_CONSTRUCTORS("Int16", {"Int16$from_bool", "func(b:Bool -> Int16)"}, - {"Int16$from_byte", "func(b:Byte -> Int16)"}, {"Int16$from_int8", "func(i:Int8 -> Int16)"}, - {"Int16$from_int32", "func(i:Int32, truncate=no -> Int16)"}, - {"Int16$from_int64", "func(i:Int64, truncate=no -> Int16)"}, - {"Int16$from_int", "func(i:Int, truncate=no -> Int16)"}, - {"Int16$from_num", "func(n:Num, truncate=no -> Int16)"}, + ADD_CONSTRUCTORS("Int16", // + {"Int16$from_bool", "func(b:Bool -> Int16)"}, // + {"Int16$from_byte", "func(b:Byte -> Int16)"}, // + {"Int16$from_int8", "func(i:Int8 -> Int16)"}, // + {"Int16$from_int32", "func(i:Int32, truncate=no -> Int16)"}, // + {"Int16$from_int64", "func(i:Int64, truncate=no -> Int16)"}, // + {"Int16$from_int", "func(i:Int, truncate=no -> Int16)"}, // + {"Int16$from_num", "func(n:Num, truncate=no -> Int16)"}, // {"Int16$from_num32", "func(n:Num32, truncate=no -> Int16)"}); - ADD_CONSTRUCTORS("Int8", {"Int8$from_bool", "func(b:Bool -> Int8)"}, {"Int8$from_byte", "func(b:Byte -> Int8)"}, - {"Int8$from_int16", "func(i:Int16, truncate=no -> Int8)"}, - {"Int8$from_int32", "func(i:Int32, truncate=no -> Int8)"}, - {"Int8$from_int64", "func(i:Int64, truncate=no -> Int8)"}, - {"Int8$from_int", "func(i:Int, truncate=no -> Int8)"}, - {"Int8$from_num", "func(n:Num, truncate=no -> Int8)"}, + ADD_CONSTRUCTORS("Int8", // + {"Int8$from_bool", "func(b:Bool -> Int8)"}, // + {"Int8$from_byte", "func(b:Byte -> Int8)"}, // + {"Int8$from_int16", "func(i:Int16, truncate=no -> Int8)"}, // + {"Int8$from_int32", "func(i:Int32, truncate=no -> Int8)"}, // + {"Int8$from_int64", "func(i:Int64, truncate=no -> Int8)"}, // + {"Int8$from_int", "func(i:Int, truncate=no -> Int8)"}, // + {"Int8$from_num", "func(n:Num, truncate=no -> Int8)"}, // {"Int8$from_num32", "func(n:Num32, truncate=no -> Int8)"}); - ADD_CONSTRUCTORS("Num", {"Num$from_bool", "func(b:Bool -> Num)"}, {"Num$from_byte", "func(b:Byte -> Num)"}, - {"Num$from_int8", "func(i:Int8 -> Num)"}, {"Num$from_int16", "func(i:Int16 -> Num)"}, - {"Num$from_int32", "func(i:Int32 -> Num)"}, - {"Num$from_int64", "func(i:Int64, truncate=no -> Num)"}, - {"Num$from_int", "func(i:Int, truncate=no -> Num)"}, {"Num$from_num32", "func(n:Num32 -> Num)"}); - ADD_CONSTRUCTORS( - "Num32", {"Num32$from_bool", "func(b:Bool -> Num32)"}, {"Num32$from_byte", "func(b:Byte -> Num32)"}, - {"Num32$from_int8", "func(i:Int8 -> Num32)"}, {"Num32$from_int16", "func(i:Int16 -> Num32)"}, - {"Num32$from_int32", "func(i:Int32, truncate=no -> Num32)"}, - {"Num32$from_int64", "func(i:Int64, truncate=no -> Num32)"}, - {"Num32$from_int", "func(i:Int, truncate=no -> Num32)"}, {"Num32$from_num", "func(n:Num -> Num32)"}); - ADD_CONSTRUCTORS("Path", {"Path$escape_text", "func(text:Text -> Path)"}, - {"Path$escape_path", "func(path:Path -> Path)"}, {"Int$value_as_text", "func(i:Int -> Path)"}); - ADD_CONSTRUCTORS("CString", {"Text$as_c_string", "func(text:Text -> CString)"}); + ADD_CONSTRUCTORS("Num", // + {"Num$from_bool", "func(b:Bool -> Num)"}, // + {"Num$from_byte", "func(b:Byte -> Num)"}, // + {"Num$from_int8", "func(i:Int8 -> Num)"}, // + {"Num$from_int16", "func(i:Int16 -> Num)"}, // + {"Num$from_int32", "func(i:Int32 -> Num)"}, // + {"Num$from_int64", "func(i:Int64, truncate=no -> Num)"}, // + {"Num$from_int", "func(i:Int, truncate=no -> Num)"}, // + {"Num$from_num32", "func(n:Num32 -> Num)"}); + ADD_CONSTRUCTORS("Num32", // + {"Num32$from_bool", "func(b:Bool -> Num32)"}, // + {"Num32$from_byte", "func(b:Byte -> Num32)"}, // + {"Num32$from_int8", "func(i:Int8 -> Num32)"}, // + {"Num32$from_int16", "func(i:Int16 -> Num32)"}, // + {"Num32$from_int32", "func(i:Int32, truncate=no -> Num32)"}, // + {"Num32$from_int64", "func(i:Int64, truncate=no -> Num32)"}, // + {"Num32$from_int", "func(i:Int, truncate=no -> Num32)"}, // + {"Num32$from_num", "func(n:Num -> Num32)"}); + ADD_CONSTRUCTORS("Path", // + {"Path$escape_text", "func(text:Text -> Path)"}, // + {"Path$escape_path", "func(path:Path -> Path)"}, // + {"Int$value_as_text", "func(i:Int -> Path)"}); + ADD_CONSTRUCTORS("CString", // + {"Text$as_c_string", "func(text:Text -> CString)"}); #undef ADD_CONSTRUCTORS set_binding(namespace_env(env, "Path"), "from_text", |
