public static string TypeMap(IBfsType type)
        {
            if (type is BfsNamedType)
                return (type as BfsNamedType).DataBlock.Name;

            if (type is BfsPrimitiveType)
            {
                string typeString = (type as BfsPrimitiveType).PrimitiveType.ToString();
                switch (typeString)
                {
                    case "Ubyte":
                        return "Byte";
                    case "Sbyte":
                        return "Byte";
                    default:
                        return typeString;
                }
            }
            else return "/* TODO!!! */";
        }
Ejemplo n.º 2
0
        public string ReadType(IBfsType type)
        {
            //if(type.ArrayExtension != null)

            if (type is BfsNamedType)
            {
                BfsNamedType namedType = type as BfsNamedType;
                return namedType.DataBlock.Name + ".Read(file)";
            }
            if (type is BfsPrimitiveType)
            {
                BfsPrimitiveType primitiveType = type as BfsPrimitiveType;
                return "file.Read" + primitiveType.PrimitiveType.ToString() + "()";
            }
            if (type is BfsFunctionType)
            {
                BfsFunctionType functionType = type as BfsFunctionType;
                if (functionType.FunctionName == "ascii")
                {
                    //CSharpPredefinedFunctions.AddReadAsciiStringMethod(rootParser);
                    return "file.ReadASCIIString(\"" + functionType.FunctionArgument + "\")";
                }
                else return "throw new NotImplementedException()";
            }

            return "null";
        }
Ejemplo n.º 3
0
 private void AddFileLine(string data, IBfsType type, TreeNode parent)
 {
     TreeNode node = new TreeNode(data);
     node.Tag = type;
     parent.Nodes.Add(node);
 }