From 987a54e2ebebbeaeab3bbd705a47d95685238c5a Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 16 Jun 2009 16:32:19 -0400 Subject: [PATCH 1/1] syntax: new class AAbsAbsSendExpr Like AAbsSendExpr but without property. AAbsSendExpr is a subclass of AAbsAbsSendExpr. Signed-off-by: Jean Privat --- src/compiling/compiling_methods.nit | 2 +- src/syntax/typing.nit | 117 ++++++++++++++++++----------------- 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/src/compiling/compiling_methods.nit b/src/compiling/compiling_methods.nit index 856934e..c8e56c0 100644 --- a/src/compiling/compiling_methods.nit +++ b/src/compiling/compiling_methods.nit @@ -1449,7 +1449,7 @@ redef class AAttrReassignExpr end end -redef class AAbsSendExpr +redef class AAbsAbsSendExpr # Compile each argument and add them to the array meth compile_arguments_in(v: CompilerVisitor, cargs: Array[String]) do diff --git a/src/syntax/typing.nit b/src/syntax/typing.nit index 904e58c..d3a196a 100644 --- a/src/syntax/typing.nit +++ b/src/syntax/typing.nit @@ -928,64 +928,13 @@ redef class AAttrReassignExpr end end -class AAbsSendExpr +class AAbsAbsSendExpr special PExpr # The signature of the called property readable attr _prop_signature: MMSignature - # Compute the called global property - private meth do_typing(v: TypingVisitor, type_recv: MMType, is_implicit_self: Bool, recv_is_self: Bool, name: Symbol, raw_args: Array[PExpr], closure_defs: Array[PClosureDef]) - do - var prop = get_property(v, type_recv, is_implicit_self, name) - if prop == null then return - var sig = get_signature(v, type_recv, prop, recv_is_self) - if sig == null then return - var args = process_signature(v, sig, prop.name, raw_args) - if args == null then return - var rtype = process_closures(v, sig, prop.name, closure_defs) - _prop = prop - _prop_signature = sig - _arguments = args - _return_type = rtype - end - - private meth get_property(v: TypingVisitor, type_recv: MMType, is_implicit_self: Bool, name: Symbol): MMMethod - do - if type_recv == null then return null - var lc = type_recv.local_class - var prop: MMMethod = null - if lc.has_global_property_by_name(name) then prop = lc.select_method(name) - if prop == null and v.local_property.global.is_init then - var props = type_recv.local_class.super_methods_named(name) - if props.length > 1 then - v.error(self, "Error: Ambigous method name '{name}' for {props.join(", ")}. Use explicit designation.") - return null - else if props.length == 1 then - var p = type_recv.local_class[props.first.global] - assert p isa MMMethod - prop = p - end - - end - if prop == null then - if is_implicit_self then - v.error(self, "Error: Method or variable '{name}' unknown in {type_recv}.") - else - v.error(self, "Error: Method '{name}' doesn't exists in {type_recv}.") - end - return null - end - return prop - end - - # Get the signature for a local property and a receiver - private meth get_signature(v: TypingVisitor, type_recv: MMType, prop: MMMethod, recv_is_self: Bool): MMSignature - do - prop.global.check_visibility(v, self, v.module, recv_is_self) - var psig = prop.signature_for(type_recv) - if not recv_is_self then psig = psig.not_for_self - return psig - end + # The real arguments used (after star transformation) (once computed) + readable attr _arguments: Array[PExpr] # Check the conformity of a set of arguments `raw_args' to a signature. private meth process_signature(v: TypingVisitor, psig: MMSignature, name: Symbol, raw_args: Array[PExpr]): Array[PExpr] @@ -1063,13 +1012,67 @@ special PExpr end return t end +end + +class AAbsSendExpr +special AAbsAbsSendExpr + # Compute the called global property + private meth do_typing(v: TypingVisitor, type_recv: MMType, is_implicit_self: Bool, recv_is_self: Bool, name: Symbol, raw_args: Array[PExpr], closure_defs: Array[PClosureDef]) + do + var prop = get_property(v, type_recv, is_implicit_self, name) + if prop == null then return + var sig = get_signature(v, type_recv, prop, recv_is_self) + if sig == null then return + var args = process_signature(v, sig, prop.name, raw_args) + if args == null then return + var rtype = process_closures(v, sig, prop.name, closure_defs) + _prop = prop + _prop_signature = sig + _arguments = args + _return_type = rtype + end + + private meth get_property(v: TypingVisitor, type_recv: MMType, is_implicit_self: Bool, name: Symbol): MMMethod + do + if type_recv == null then return null + var lc = type_recv.local_class + var prop: MMMethod = null + if lc.has_global_property_by_name(name) then prop = lc.select_method(name) + if prop == null and v.local_property.global.is_init then + var props = type_recv.local_class.super_methods_named(name) + if props.length > 1 then + v.error(self, "Error: Ambigous method name '{name}' for {props.join(", ")}. Use explicit designation.") + return null + else if props.length == 1 then + var p = type_recv.local_class[props.first.global] + assert p isa MMMethod + prop = p + end + + end + if prop == null then + if is_implicit_self then + v.error(self, "Error: Method or variable '{name}' unknown in {type_recv}.") + else + v.error(self, "Error: Method '{name}' doesn't exists in {type_recv}.") + end + return null + end + return prop + end + + # Get the signature for a local property and a receiver + private meth get_signature(v: TypingVisitor, type_recv: MMType, prop: MMMethod, recv_is_self: Bool): MMSignature + do + prop.global.check_visibility(v, self, v.module, recv_is_self) + var psig = prop.signature_for(type_recv) + if not recv_is_self then psig = psig.not_for_self + return psig + end # The invoked method (once computed) readable attr _prop: MMMethod - # The real arguments used (after star transformation) (once computed) - readable attr _arguments: Array[PExpr] - # The return type (if any) (once computed) readable attr _return_type: MMType end -- 1.7.9.5