constructor
constructor
constructor
enum defining all data types
reads DataType from a byte code style string
identifies the data type from the actual data keep in mind, this won't be able to identify if the data type is a reference or not
reads DataType from a string, in case of failure or bad format in string, throws Exception
converts this to a byte code style data type, which is a string
converts this DataType to string
returns true if it's an array
stores if it's an array. If type is int, it will be 0, if int[] it will be 1, if int[][], then 2 ...
stores if it's a reference to a type
the actual data type
st{ assert(DataType("int") == DataType(DataType.Type.Integer, 0)); assert(DataType("string[]") == DataType(DataType.Type.String, 1)); assert(DataType("double[][]") == DataType(DataType.Type.Double, 2)); assert(DataType("void") == DataType(DataType.Type.Void, 0)); // unittests for `fromData` import qscript.compiler.tokengen : stringToTokens; DataType dType; dType.fromData(["\"bla bla\""].stringToTokens); assert(dType == DataType("string")); dType.fromData(["20"].stringToTokens); assert(dType == DataType("int")); dType.fromData(["2.5"].stringToTokens); assert(dType == DataType("double")); dType.fromData(["[", "\"bla\"", ",", "\"bla\"", "]"].stringToTokens); assert(dType == DataType("string[]")); dType.fromData(["[", "[", "25.0", ",", "2.5", "]", ",", "[", "15.0", ",", "25.0", "]", "]"].stringToTokens); assert(dType == DataType("double[][]")
used to store data types for data at compile time