end
redef class PExpr
- redef readable attr _is_typed: Bool = true # FIXME: Switch to false once subclasses are adapted
+ redef readable attr _is_typed: Bool = false
redef meth is_statement: Bool do return _stype == null
redef meth stype
do
+ if not is_typed then
+ print "{locate}: not is_typed"
+ abort
+ end
+ if is_statement then
+ print "{locate}: is_statement"
+ abort
+ end
return _stype
end
attr _stype: MMType
v.check_conform_expr(n_expr, va.stype)
end
else
- v.check_expr(n_expr)
+ if not v.check_expr(n_expr) then return
va.stype = n_expr.stype
end
+ _is_typed = true
end
end
super
v.variable_ctx = old_var_ctx
+ _is_typed = true
end
end
else if n_expr != null and t != null then
v.check_conform_expr(n_expr, t)
end
+ _is_typed = true
end
end
else if n_expr != null and t != null then
v.check_conform_expr(n_expr, t)
end
+ _is_typed = true
end
end
# Typing check can only be done later
bl.add(n_expr)
end
+ _is_typed = true
end
end
v.visit(n_else)
v.variable_ctx = old_var_ctx
end
+ _is_typed = true
end
end
v.check_conform_expr(n_expr, v.type_bool)
v.escapable_ctx.pop
+ _is_typed = true
end
end
v.visit(n_expr)
+ if not v.check_conform_expr(n_expr, v.type_collection) then return
var expr_type = n_expr.stype
- if not v.check_conform_expr(n_expr, v.type_collection) then
- return
- end
_meth_iterator = expr_type.local_class.select_method(once ("iterator".to_symbol))
if _meth_iterator == null then
v.error(self, "Error: Collection MUST have an iterate method")
if n_block != null then v.visit(n_block)
# pop context
- var varctx = v.variable_ctx
+ var varctx = v.variable_ctx
assert varctx isa SubVariableContext
v.variable_ctx = varctx.prev
v.escapable_ctx.pop
+ _is_typed = true
end
end
do
v.check_conform_expr(n_expr, v.type_bool)
v.use_if_true_variable_ctx(n_expr)
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.variable_ctx.stype(variable)
+ _is_typed = _stype != null
end
end
do
var t = v.variable_ctx.stype(variable)
v.check_conform_expr(n_value, t)
+ _is_typed = true
end
end
prop.global.check_visibility(v, self, v.module, false)
var psig = prop.signature_for(type_lvalue)
_assign_method = prop
- v.check_conform_expr(n_value, psig[0].not_for_self)
- v.check_conform(self, psig.return_type.not_for_self, n_value.stype)
+ if not v.check_conform_expr(n_value, psig[0].not_for_self) then return
+ if not v.check_conform(self, psig.return_type.not_for_self, n_value.stype) then return
end
# Method used through the reassigment operator (once computed)
do
var t = v.variable_ctx.stype(variable)
do_lvalue_typing(v, t)
+ _is_typed = true
end
end
do
variable = v.self_var
_stype = v.variable_ctx.stype(variable)
+ _is_typed = true
end
redef meth is_self do return true
v.check_conform_expr(n_expr, v.type_bool)
_stype = v.check_conform_multiexpr(null, [n_then, n_else])
+ _is_typed = _stype != null
end
end
redef meth after_typing(v)
do
_stype = v.type_bool
+ _is_typed = true
end
end
v.check_conform_expr(n_expr, v.type_bool)
v.check_conform_expr(n_expr2, v.type_bool)
_stype = v.type_bool
+ _is_typed = true
end
end
v.check_conform_expr(n_expr, v.type_bool)
v.check_conform_expr(n_expr2, v.type_bool)
_stype = v.type_bool
+ _is_typed = true
end
end
do
v.check_conform_expr(n_expr, v.type_bool)
_stype = v.type_bool
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.type_int
-
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.type_float
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.type_char
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.type_string
+ _is_typed = true
_meth_with_native = _stype.local_class.select_method(once "with_native".to_symbol)
if _meth_with_native == null then v.error(self, "{_stype} MUST have a with_native method.")
end
if _meth_add == null then v.error(self, "{_atype} MUST have an add method.")
_meth_to_s = v.type_object.local_class.select_method(once "to_s".to_symbol)
if _meth_to_s == null then v.error(self, "Object MUST have a to_s method.")
+ _is_typed = true
end
end
redef meth after_typing(v)
do
_stype = v.type_none
+ _is_typed = true
end
end
if _meth_with_capacity == null then v.error(self, "{_stype} MUST have a with_capacity method.")
_meth_add = _stype.local_class.select_method(once "add".to_symbol)
if _meth_add == null then v.error(self, "{_stype} MUST have an add method.")
+
+ _is_typed = true
end
end
readable attr _meth_init: MMMethod
redef meth after_typing(v)
do
+ if not v.check_expr(n_expr) or not v.check_expr(n_expr2) then return
var ntype = n_expr.stype
var ntype2 = n_expr2.stype
- if ntype == null or ntype == null then
- return
- end
if ntype < ntype2 then
ntype = ntype2
else if not ntype2 < ntype then
return
end
var dtype = v.type_discrete
- v.check_conform_expr(n_expr, dtype)
- v.check_conform_expr(n_expr2, dtype)
+ if not v.check_conform_expr(n_expr, dtype) or not v.check_conform_expr(n_expr2, dtype) then return
_stype = v.type_range(ntype)
+ _is_typed = true
end
end
var p = v.local_property
assert p isa MMSrcMethod
_prop = p
+ _is_typed = true
end
end
redef meth after_typing(v)
do
do_typing(v)
- if prop == null then
- return
- end
+ if prop == null then return
_stype = attr_type
+ _is_typed = true
end
end
redef meth after_typing(v)
do
do_typing(v)
- if prop == null then
- return
- end
- v.check_conform_expr(n_value, attr_type)
+ if prop == null then return
+ if not v.check_conform_expr(n_value, attr_type) then return
+ _is_typed = true
end
end
redef meth after_typing(v)
do
do_typing(v)
- if prop == null then
- return
- end
+ if prop == null then return
do_lvalue_typing(v, attr_type)
+ _is_typed = true
end
end
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)
+ if rtype == null and sig.return_type != null then return
_prop = prop
_prop_signature = sig
_arguments = args
if not prop.global.is_init then
v.error(self, "Error: {prop} is not a constructor.")
+ return
end
_stype = t
+ _is_typed = true
end
end
end
_stype = return_type
+ _is_typed = true
end
end
end
_arguments = old_args # FIXME: What if star parameters do not match betwen the two methods?
+ _is_typed = true
end
end
_prop_signature = sig
_arguments = args
_stype = sig.return_type
+ _is_typed = true
end
end
_if_true_variable_ctx = v.variable_ctx.sub_with(variable, n_type.stype)
end
_stype = v.type_bool
+ _is_typed = true
end
end
do
v.check_expr(n_expr)
_stype = n_type.stype
+ _is_typed = _stype != null
end
end
redef class AProxyExpr
redef meth after_typing(v)
do
+ if not n_expr.is_typed then return
+ _is_typed = true
+ if n_expr.is_statement then return
_stype = n_expr.stype
end
end