let methods be inline
This commit is contained in:
@@ -3623,10 +3623,20 @@ ResultType(CometOperand, ErrorMessage) visitMethodDefStatement(CometCompiler* c,
|
||||
false
|
||||
);
|
||||
|
||||
// build the functions body
|
||||
ResultType(CometOperand, ErrorMessage) bodyResult = compile(c, funcDef.program);
|
||||
if (bodyResult.error)
|
||||
return bodyResult;
|
||||
if (funcDef.inlineExpr != NULL) { // its an inline function
|
||||
// build the functions body
|
||||
ResultType(CometOperand, ErrorMessage) exprResult = compile(c, funcDef.inlineExpr);
|
||||
if (exprResult.error)
|
||||
return exprResult;
|
||||
|
||||
// then return
|
||||
buildReturn(c);
|
||||
} else {
|
||||
// build the functions body
|
||||
ResultType(CometOperand, ErrorMessage) bodyResult = compile(c, funcDef.program);
|
||||
if (bodyResult.error)
|
||||
return bodyResult;
|
||||
}
|
||||
|
||||
// return back to the parent scope
|
||||
c->env = destroyEnv(c->env);
|
||||
|
||||
27
test.comet
27
test.comet
@@ -1,27 +0,0 @@
|
||||
struct Foo {
|
||||
init() {
|
||||
|
||||
}
|
||||
|
||||
func foo() -> int {
|
||||
return 2 + 6
|
||||
}
|
||||
}
|
||||
|
||||
struct Child : Foo {
|
||||
override func foo() -> int {
|
||||
return 2 + 4
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func main() -> int {
|
||||
Child test = new Child()
|
||||
|
||||
return test.foo()
|
||||
}
|
||||
Reference in New Issue
Block a user