예제 #1
0
        public DataElement CreateVariable(string type, int id)
        {
            type = type.TrimEnd(':');
            string key      = $"{type}:{id}";
            var    variable = Variables.ContainsKey(key) ? Variables[key] : null;

            if (variable != null)
            {
                return(variable);
            }

            switch (type)
            {
            case "$":
                variable = new DataElement.VLoc((uint)id);
                if (id >= MaxLocals)
                {
                    MaxLocals = (uint)id + 1;
                }
                break;

            case YksFormat.Flag:
            case YksFormat.GlobalFlag:
                variable = new DataElement.VInt(CreateScriptValue(type), CreateScriptValue(id));
                break;

            case YksFormat.String:
            case YksFormat.GlobalString:
                variable = new DataElement.VStr(CreateScriptValue(type), CreateScriptValue(id));
                break;

            case YksFormat.TempGlobalString:
            case YksFormat.主人公:
            case YksFormat.汎用文字変数:
                variable = new DataElement.SStr(CreateScriptValue(type));
                break;

            default:
                throw new FormatException($"Unrecognized variable type: '{type}'");
            }

            Variables[key] = variable;
            return(variable);
        }
예제 #2
0
 protected void FreeLocal(DataElement.VLoc local)
 {
     Debug.Assert(_usedLocals.ContainsKey(local) && _usedLocals[local]);
     _usedLocals[local] = false;
 }