Rename REAMDE to README.md
[nit.git] / src / nitni / nitni_base.nit
index 69f64f3..a1f49a7 100644 (file)
@@ -30,6 +30,9 @@ redef class MMethod
 
                if nit_name == "+" then return "_plus"
                if nit_name == "-" then return "_minus"
+               if nit_name == "unary -" then return "_unary_minus"
+               if nit_name == "unary +" then return "_unary_plus"
+               if nit_name == "unary ~" then return "_unary_tilde"
                if nit_name == "*" then return "_star"
                if nit_name == "/" then return "_slash"
                if nit_name == "%" then return "_percent"
@@ -37,24 +40,23 @@ redef class MMethod
                if nit_name == "[]=" then return "_index_assign"
                if nit_name == "==" then return "_equal"
                if nit_name == "<" then return "_less"
-               if nit_name == ">" then return "_geater"
+               if nit_name == ">" then return "_greater"
                if nit_name == "<=" then return "_less_or_equal"
                if nit_name == ">=" then return "_greater_or_equal"
                if nit_name == "!=" then return "_not_equal"
                if nit_name == "<<" then return "_left"
                if nit_name == ">>" then return "_right"
                if nit_name == "<=>" then return "_starship"
+               if nit_name == "|" then return "_pipe"
+               if nit_name == "^" then return "_caret"
+               if nit_name == "&" then return "_amp"
+               if nit_name == "~" then return "_tilde"
 
-               if nit_name.last == '=' then return "{nit_name.substring(0, nit_name.length-1)}__assign"
+               if nit_name.chars.last == '=' then return "{nit_name.substring(0, nit_name.length-1)}__assign"
                return nit_name
        end
 end
 
-redef class AModule
-       # Mangled name of this module in C
-       fun cname: String do return mmodule.name
-end
-
 redef class MMethodDef
        # Name of the function to callback this method from C,
        # also used in other functions names used for this method.
@@ -89,14 +91,14 @@ redef class MClassType
                if name == "Bool" then return "int"
                if name == "Char" then return "char"
                if name == "Float" then return "double"
-               if name == "Int" then return "int"
+               if name == "Int" then return "long"
                if name == "NativeString" then return "char*"
                if mclass.kind == extern_kind then
                        var ctype = mclass.ctype
                        assert ctype != null
                        return ctype
                end
-               return mangled_cname
+               return cname_normal_class
        end
 
        redef fun cname_blind do
@@ -104,12 +106,15 @@ redef class MClassType
                if name == "Bool" then return "int"
                if name == "Char" then return "char"
                if name == "Float" then return "double"
-               if name == "Int" then return "int"
+               if name == "Int" then return "long"
                if name == "NativeString" then return "char*"
                if mclass.kind == extern_kind then return "void*"
                return "struct nitni_instance *"
        end
 
+       # Name of this type in C for normal classes (not extern and not primitive)
+       protected fun cname_normal_class: String do return mangled_cname
+
        redef fun mangled_cname do return mclass.name
 
        redef fun is_cprimitive do return mclass.kind == extern_kind or