Merge: compiler: Added prefix and suffix support for `Char`
authorJean Privat <jean@pryen.org>
Thu, 24 Mar 2016 13:10:47 +0000 (09:10 -0400)
committerJean Privat <jean@pryen.org>
Thu, 24 Mar 2016 13:10:47 +0000 (09:10 -0400)
As discussed in #1734, here's the PR for the support of prefixed characters.

For now only u and b are supported, respectively to get the code point as an int and the ascii code as a byte.

Pull-Request: #1991
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

1  2 
src/modelize/modelize_property.nit

@@@ -589,7 -589,7 +589,7 @@@ redef class APropde
                        var mdoc = ndoc.to_mdoc
                        mpropdef.mdoc = mdoc
                        mdoc.original_mentity = mpropdef
 -              else if mpropdef.is_intro and mpropdef.mproperty.visibility >= protected_visibility then
 +              else if mpropdef.is_intro and mpropdef.mproperty.visibility >= protected_visibility and mpropdef.name != "new" then
                        modelbuilder.advice(self, "missing-doc", "Documentation warning: Undocumented property `{mpropdef.mproperty}`")
                end
  
@@@ -1390,7 -1390,14 +1390,14 @@@ redef class AAttrPropde
                                        var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Float")
                                        if cla != null then mtype = cla.mclass_type
                                else if nexpr isa ACharExpr then
-                                       var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Char")
+                                       var cla: nullable MClass
+                                       if nexpr.is_ascii then
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Byte")
+                                       else if nexpr.is_code_point then
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Int")
+                                       else
+                                               cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Char")
+                                       end
                                        if cla != null then mtype = cla.mclass_type
                                else if nexpr isa ABoolExpr then
                                        var cla = modelbuilder.try_get_mclass_by_name(nexpr, mmodule, "Bool")