Beispiel #1
0
        public DataElement CreateVariablePointer(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 YksFormat.Flag:
            case YksFormat.GlobalFlag:
                variable = new DataElement.VInt(CreateScriptValue(type), CreateScriptValuePointer(id));
                break;

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

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

            Variables[key] = variable;
            return(variable);
        }
Beispiel #2
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);
        }