Browse Source

added String.code

Nicolas Cannasse 17 years ago
parent
commit
6b1df169fc
2 changed files with 4 additions and 0 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 3 0
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -41,6 +41,7 @@
 	fixed binary resources for Flash, JS and PHP outputs
 	fixed compiler bug with inline + optional arguments
 	fixed Type.createInstance and createEmptyInstance with Array for flash6-8
+	added "c".code for compiletime UTF8 charcodes
 
 2008-07-28: 2.0
 	fixed current package bug in inherited constructor type

+ 3 - 0
typer.ml

@@ -981,6 +981,9 @@ and type_access ctx e p get =
 
 and type_expr ctx ?(need_val=true) (e,p) =
 	match e with
+	| EField ((EConst (String s),p),"code") ->
+		if UTF8.length s <> 1 then error "String must be a single UTF8 char" p;
+		mk (TConst (TInt (Int32.of_int (UChar.code (UTF8.get s 0))))) ctx.api.tint p
 	| EField _
 	| EType _
 	| EArray _