Esempio n. 1
0
        public static FunctionMetadataRegistry CreateRegistry()
        {
            var bytes = Encoding.UTF8.GetBytes(Resource.FunctionMetadata);

            using (var memorySteam = new MemoryStream(Encoding.UTF8.GetBytes(Resource.FunctionMetadata)))
                using (StreamReader br = new StreamReader(memorySteam)) {
                    FunctionDataBuilder fdb = new FunctionDataBuilder(400);

                    try {
                        while (true)
                        {
                            string line = br.ReadLine();
                            if (line == null)
                            {
                                break;
                            }
                            if (line.Length < 1 || line[0] == '#')
                            {
                                continue;
                            }
                            string TrimLine = line.Trim();
                            if (TrimLine.Length < 1)
                            {
                                continue;
                            }
                            ProcessLine(fdb, line);
                        }
                    }
                    catch (IOException) {
                        throw;
                    }

                    return(fdb.Build());
                }
        }
Esempio n. 2
0
        public static FunctionMetadataRegistry CreateRegistry()
        {
            using (StreamReader br = new StreamReader(typeof(FunctionMetadataReader).GetTypeInfo().Assembly.GetManifestResourceStream(METADATA_FILE_NAME)))
            {
                FunctionDataBuilder fdb = new FunctionDataBuilder(400);

                try
                {
                    while (true)
                    {
                        string line = br.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        if (line.Length < 1 || line[0] == '#')
                        {
                            continue;
                        }
                        string TrimLine = line.Trim();
                        if (TrimLine.Length < 1)
                        {
                            continue;
                        }
                        ProcessLine(fdb, line);
                    }
                }
                catch (IOException)
                {
                    throw;
                }

                return(fdb.Build());
            }
        }
Esempio n. 3
0
        private static void ProcessLine(FunctionDataBuilder fdb, string line)
        {
            Regex regex = new Regex(TAB_DELIM_PATTERN);

            string[] parts = regex.Split(line);
            if (parts.Length != 8)
            {
                throw new Exception("Bad line format '" + line + "' - expected 8 data fields");
            }
            int    functionIndex   = ParseInt(parts[0]);
            string functionName    = parts[1];
            int    minParams       = ParseInt(parts[2]);
            int    maxParams       = ParseInt(parts[3]);
            byte   returnClassCode = ParseReturnTypeCode(parts[4]);

            byte[] parameterClassCodes = ParseOperandTypeCodes(parts[5]);
            // 6 IsVolatile
            bool hasNote = parts[7].Length > 0;

            ValidateFunctionName(functionName);
            // TODO - make POI use IsVolatile
            fdb.Add(functionIndex, functionName, minParams, maxParams,
                    returnClassCode, parameterClassCodes, hasNote);
        }