allow defmethod without body
This commit is contained in:
@@ -90,7 +90,7 @@ class FieldForms {
|
||||
}
|
||||
|
||||
static function funcOrMethod(formName:String, wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState):Field {
|
||||
wholeExp.checkNumArgs(3, null, '($formName [optional :type] [name] [[argNames...]] [body...])');
|
||||
wholeExp.checkNumArgs(2, null, '($formName [optional :type] [name] [[argNames...]] [body...])');
|
||||
|
||||
var name = Helpers.varName(formName, args[0]);
|
||||
var access = fieldAccess(formName, name, args[0]);
|
||||
|
@@ -149,7 +149,12 @@ class Helpers {
|
||||
};
|
||||
}
|
||||
|
||||
var expr = k.convert(CallExp(Symbol("begin").withPos(body[0].pos), body).withPos(body[0].pos));
|
||||
var expr = if (body.length == 0) {
|
||||
EReturn(null).withMacroPosOf(if (name != null) name else argList);
|
||||
} else {
|
||||
k.convert(CallExp(Symbol("begin").withPos(body[0].pos), body).withPos(body[0].pos));
|
||||
}
|
||||
|
||||
if (returnsValue) {
|
||||
expr = EReturn(expr).withMacroPosOf(body[-1]);
|
||||
}
|
||||
|
@@ -1,3 +1,3 @@
|
||||
(defmethod new [] 0)
|
||||
(defnew [])
|
||||
|
||||
(defmethod loadText [filePath] (Assets.getText filePath))
|
@@ -1,3 +1,3 @@
|
||||
(defmethod new [] 0)
|
||||
(defnew [])
|
||||
|
||||
(defmethod loadText [filePath] (File.getContent filePath))
|
@@ -2,7 +2,7 @@
|
||||
(defprop &mut :Int letterHeight 0)
|
||||
(defprop &mut :Int drawCalled 0)
|
||||
|
||||
(defmethod new [] 0)
|
||||
(defnew [])
|
||||
|
||||
(defmethod :Void initialize [:String title :Int width :Int height :Int _letterWidth :Int _letterHeight]
|
||||
(set letterWidth _letterWidth)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
(defmethod new [] 0)
|
||||
(defnew [])
|
||||
|
||||
(defmethod :Void initialize [:Assets assets]
|
||||
(assets.loadSurface "laptop" AssetPaths.laptop__srf))
|
||||
|
Reference in New Issue
Block a user