private class AutoSuperInitPhase
super Phase
- redef fun process_npropdef(npropdef) do if npropdef isa AConcreteMethPropdef then npropdef.do_auto_super_init(toolcontext.modelbuilder)
+ redef fun process_npropdef(npropdef) do if npropdef isa AMethPropdef then npropdef.do_auto_super_init(toolcontext.modelbuilder)
end
private class AutoSuperInitVisitor
end
-redef class AConcreteMethPropdef
+redef class AMethPropdef
# In case of constructor, the list of implicit auto super init constructors invoked (if needed)
var auto_super_inits: nullable Array[CallSite] = null
# Do some validity checks and print errors if the annotation is used incorrectly
var modelbuilder = toolcontext.modelbuilder
- if not npropdef isa AConcreteMethPropdef then
+ if not npropdef isa AMethPropdef then
modelbuilder.error(npropdef, "Syntax error: only a function can be cached.")
return
end
var real_mpropdef = new MMethodDef(mclassdef, new MMethod(mclassdef, "{name}<real>", private_visibility), location)
real_mpropdef.msignature = mpropdef.msignature
# FIXME: Again, if the engine require a real propdef even if it is empty
- var real_npropdef = toolcontext.parse_propdef("fun real do end").as(AConcreteMethPropdef)
+ var real_npropdef = toolcontext.parse_propdef("fun real do end").as(AMethPropdef)
associate_propdef(real_mpropdef, real_npropdef)
# Note: the body is set at the last line of this function
class ExternCFunction
super CFunction
- var method: AExternPropdef
+ var method: AMethPropdef
- init (method: AExternPropdef, mmodule: MModule)
+ init (method: AMethPropdef, mmodule: MModule)
do
self.method = method
end
end
-redef class AExternPropdef
+redef class AMethPropdef
private var ffi_has_been_compiled = false
# Compile the necessary wrapper around this extern method or constructor
redef fun process_npropdef(npropdef)
do
- if npropdef isa AExternPropdef then
+ if npropdef isa AMethPropdef then
var code_block = npropdef.n_extern_code_block
if code_block != null then
verify_foreign_code_on_node( code_block )
fun compile_module_block(block: AExternCodeBlock, ecc: CCompilationUnit, nmodule: AModule) is abstract
# Generate wrapper code for this extern method
- fun compile_extern_method(block: AExternCodeBlock, m: AExternPropdef,
+ fun compile_extern_method(block: AExternCodeBlock, m: AMethPropdef,
ecc: CCompilationUnit, nmodule: AModule) is abstract
# Generate wrapper code for this extern class
if self.modelbuilder.mpropdef2npropdef.has_key(mpropdef) then
var npropdef = self.modelbuilder.mpropdef2npropdef[mpropdef]
self.parameter_check(npropdef, mpropdef, args)
- if npropdef isa AConcreteMethPropdef then
+ if npropdef isa AMethPropdef then
return npropdef.rt_call(self, mpropdef, args)
else
print "Error, invalid propdef to call at runtime !"
end
-redef class AConcreteMethPropdef
+redef class AMethPropdef
# Same as call except it will copy local variables of the parent frame to the frame defined in this call.
# Not supposed to be used by anyone else than the Debugger.
redef class AExternCall
# Verify this explicit declaration of call from C and collect all relevant callbacks
- fun verify_and_collect(npropdef: AExternPropdef, callback_set: ForeignCallbackSet,
+ fun verify_and_collect(npropdef: AMethPropdef, callback_set: ForeignCallbackSet,
toolcontext: ToolContext) is abstract
end
do
var mod_string = "do\n{string}\nend"
var nmodule = parse_module(mod_string)
- var nblock = nmodule.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(not null)
+ var nblock = nmodule.n_classdefs.first.n_propdefs.first.as(AMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(not null)
return nblock
end
do
var mod_string = "var dummy = \n{string}"
var nmodule = parse_module(mod_string)
- var nexpr = nmodule.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_expr.as(not null)
+ var nexpr = nmodule.n_classdefs.first.n_propdefs.first.as(AMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_expr.as(not null)
return nexpr
end
tree = (new Parser(lexer)).parse
eof = tree.n_eof
if not eof isa AError then
- var ntype = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_type.n_types.first
+ var ntype = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_type.n_types.first
return ntype
end
error = eof
tree = (new Parser(lexer)).parse
eof = tree.n_eof
if not eof isa AError then
- var nexpr = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_expr.as(AParExpr).n_expr
+ var nexpr = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(AVardeclExpr).n_expr.as(AParExpr).n_expr
return nexpr
end
if eof.location > error.location then error = eof
tree = (new Parser(lexer)).parse
eof = tree.n_eof
if not eof isa AError then
- var nblock = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMainMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(not null)
+ var nblock = tree.n_base.n_classdefs.first.n_propdefs.first.as(AMethPropdef).n_block.as(ABlockExpr).n_expr.first.as(ADoExpr).n_block.as(not null)
return nblock
end
if eof.location > error.location then error = eof
var selfvariable: nullable Variable
end
-redef class AConcreteMethPropdef
+redef class AMethPropdef
redef fun do_typing(modelbuilder: ModelBuilder)
do
+ var nblock = self.n_block
+ if nblock == null then return
+
var nclassdef = self.parent.as(AClassdef)
var mpropdef = self.mpropdef.as(not null)
var v = new TypeVisitor(modelbuilder, nclassdef, mpropdef)
self.selfvariable = v.selfvariable
- var nblock = self.n_block
- if nblock == null then return
-
var mmethoddef = self.mpropdef.as(not null)
for i in [0..mmethoddef.msignature.arity[ do
var mtype = mmethoddef.msignature.mparameters[i].mtype