コード例 #1
0
        internal bool CodeLookUp(HspDictionaryKey key, out HspDictionaryValue value)
        {
            if (codeDictionary.TryGetValue(key, out value))
            {
                return(true);
            }
            HspDictionaryKey newkey = new HspDictionaryKey(key);

            newkey.Value    = -1;
            newkey.AllValue = true;
            if (codeDictionary.TryGetValue(newkey, out value))
            {
                return(true);
            }
            if ((key.Type == 0x11) && (key.Value >= 0x1000))            //ComFunction
            {
                value.Name  = "comfunc";
                value.Type  = HspCodeType.ComFunction;
                value.Extra = HspCodeExtraFlags.NONE;
                return(true);
            }
            if (key.Type >= 0x12)            //PlugInFunction
            {
                value.Name             = "pluginFuction";
                value.OparatorPriority = key.Type - 0x12;
                value.Type             = HspCodeType.PlugInFunction;
                value.Extra            = HspCodeExtraFlags.NONE;
                return(true);
            }
            return(false);
        }
コード例 #2
0
        private PrimitiveToken ReadPrimitive(BinaryReader reader, AxData data)
        {
            PrimitiveToken ret = null;

            int theTokenOffset = tokenOffset;
            int type           = reader.ReadByte();
            int flag           = reader.ReadByte();
            int value          = 0;
            int extraValue     = -1;

            tokenOffset += 1;
            if ((flag & 0x80) == 0x80)
            {
                value        = reader.ReadInt32();
                tokenOffset += 2;
            }
            else
            {
                value        = reader.ReadUInt16();
                tokenOffset += 1;
            }

            HspDictionaryKey key = new HspDictionaryKey();

            key.Type  = type;
            key.Value = value;
            HspDictionaryValue dicValue;

            if (dictionary.CodeLookUp(key, out dicValue))
            {
                if ((dicValue.Extra & HspCodeExtraFlags.HasExtraInt16) == HspCodeExtraFlags.HasExtraInt16)
                {
                    //HSP3.0aの仕様では行頭にないif,elseはジャンプ先アドレスを持たない。
                    if ((flag & 0x20) == 0x20)
                    {
                        extraValue   = reader.ReadUInt16();
                        tokenOffset += 1;
                        ret          = createPrimitive(data, dicValue, theTokenOffset, type, flag, value, extraValue);
                    }
                    else
                    {
                        ret = createPrimitive(data, dicValue, theTokenOffset, type, flag, value, -1);
                    }
                }
                else
                {
                    ret = createPrimitive(data, dicValue, theTokenOffset, type, flag, value, -1);
                }
            }
            else
            {
                ret = createPrimitive(data, new HspDictionaryValue(), theTokenOffset, type, flag, value, -1);
            }
            ret.SetName();

            return(ret);
        }
コード例 #3
0
        private void loadCodeDictionary(TextFieldParser stream)
        {
            while (!stream.EndOfData)
            {
                string[] tokens = stream.ReadFields();
                if (tokens.Length == 0)
                {
                    continue;
                }
                if (tokens[0] == "$End")
                {
                    return;
                }

                if (tokens.Length >= 4)
                {
                    string[] extraFlags = new string[tokens.Length - 4];
                    Array.Copy(tokens, 4, extraFlags, 0, tokens.Length - 4);
                    HspDictionaryKey   key   = new HspDictionaryKey(tokens[0], tokens[1]);
                    HspDictionaryValue value = new HspDictionaryValue(tokens[2], tokens[3], extraFlags);
                    codeDictionary.Add(key, value);
                }
            }
        }