(the) can now specify a package and unquote package/type
This commit is contained in:
@@ -265,11 +265,22 @@ class SpecialForms {
|
|||||||
|
|
||||||
// Type check syntax:
|
// Type check syntax:
|
||||||
map["the"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
map["the"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||||
wholeExp.checkNumArgs(2, 2, '(the [type] [value])');
|
wholeExp.checkNumArgs(2, 3, '(the [optional: package] [type] [value])');
|
||||||
ECheckType(k.convert(args[1]), switch (args[0].def) {
|
var pkg = "";
|
||||||
case Symbol(type): Helpers.parseComplexType(type, args[0]);
|
var whichArg = "first";
|
||||||
default: throw CompileError.fromExp(args[0], 'first argument to (the... ) should be a valid type');
|
if (args.length == 3) {
|
||||||
}).withMacroPosOf(wholeExp);
|
pkg = switch (args.shift().def) {
|
||||||
|
case Symbol(pkg): pkg;
|
||||||
|
default: throw CompileError.fromExp(args[0], '$whichArg argument to (the... ) should be a valid haxe package');
|
||||||
|
};
|
||||||
|
whichArg = "second";
|
||||||
|
}
|
||||||
|
var type = switch (args[0].def) {
|
||||||
|
case Symbol(type): type;
|
||||||
|
default: throw CompileError.fromExp(args[0], '$whichArg argument to (the... ) should be a valid type');
|
||||||
|
};
|
||||||
|
if (pkg.length > 0) type = pkg + "." + type;
|
||||||
|
ECheckType(k.convert(args[1]), Helpers.parseComplexType(type, args[0])).withMacroPosOf(wholeExp);
|
||||||
};
|
};
|
||||||
|
|
||||||
map["try"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
map["try"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||||
|
Reference in New Issue
Block a user