diff --git a/hscript/Error.hx b/hscript/Error.hx index ba45c87..f2aef36 100644 --- a/hscript/Error.hx +++ b/hscript/Error.hx @@ -62,7 +62,7 @@ enum Error_ EInvalidEscape( s : String ); } -enum abstract ErrorMessage(Int) from Int to Int { +enum abstract ErrorMessage(Expr.UInt8) from Expr.UInt8 to Expr.UInt8 { final INVALID_CHAR_CODE_MULTI; final FROM_CHAR_CODE_NON_INT; final EMPTY_INTERPOLATION; diff --git a/hscript/Expr.hx b/hscript/Expr.hx index 3fd2e84..dba62b1 100644 --- a/hscript/Expr.hx +++ b/hscript/Expr.hx @@ -21,6 +21,16 @@ */ package hscript; +typedef Int8 = #if cpp cpp.Int8 #else Int #end; +typedef Int16 = #if cpp cpp.Int16 #else Int #end; +typedef Int32 = #if cpp cpp.Int32 #else Int #end; +typedef Int64 = #if cpp cpp.Int64 #else Int #end; + +typedef UInt8 = #if cpp cpp.UInt8 #else Int #end; +typedef UInt16 = #if cpp cpp.UInt16 #else Int #end; +typedef UInt32 = #if cpp cpp.UInt32 #else Int #end; +typedef UInt64 = #if cpp cpp.UInt64 #else Int #end; + enum Const { CInt( v : Int ); CFloat( f : Float ); @@ -30,12 +40,13 @@ enum Const { #end } -enum MapType { - IntMap; - StringMap; - EnumMap; - ObjectMap; - UnknownMap; +enum abstract MapType(UInt8) { + var Null; + var IntMap; + var StringMap; + var EnumMap; + var ObjectMap; + var UnknownMap; } typedef Error = hscript.Error.Error_; @@ -224,7 +235,7 @@ enum Binop { OpNullCoal; } -enum abstract Unop(Int) { +enum abstract Unop(UInt8) { /** `++` **/ @@ -352,13 +363,13 @@ typedef FieldDecl = { var access : Array; } -enum FieldAccess { - APublic; - APrivate; - AInline; - AOverride; - AStatic; - AMacro; +enum abstract FieldAccess(UInt8) { + var APublic; + var APrivate; + var AInline; + var AOverride; + var AStatic; + var AMacro; } enum FieldKind { diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 85872cd..02b6e99 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -45,7 +45,7 @@ private enum Stop { SReturn; } -enum abstract ScriptObjectType(Int) { +enum abstract ScriptObjectType(UInt8) { var SClass; var SObject; var SStaticClass; diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 6b75dab..8fc997c 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -674,14 +674,14 @@ class Parser { var t = b2i(isKeyString) + b2i(isKeyInt) + b2i(isKeyObject) + b2i(isKeyEnum); - var type:MapType = null; + var type:MapType = Null; if(t != 1) type = UnknownMap; else if(isKeyInt) type = IntMap; else if(isKeyString) type = StringMap; else if(isKeyEnum) type = EnumMap; else if(isKeyObject) type = ObjectMap; - if(type == null) + if(type == Null) error(EPreset(UNKNOWN_MAP_TYPE), p1, p1); return parseExprNext(mk(EMapDecl(type, keys, values), p1)); diff --git a/hscript/Printer.hx b/hscript/Printer.hx index f12393c..9ae6d9e 100644 --- a/hscript/Printer.hx +++ b/hscript/Printer.hx @@ -314,6 +314,7 @@ class Printer { case EnumMap: add("EnumValue"); case IntMap: add("Int"); case UnknownMap: add("?"); + case Null: add("Null"); } add(", Dynamic>"); default: