示例#1
0
        private string GetArgument(PyOpcode op, int arg)
        {
            var nameField = new[]
            {
                PyOpcode.STORE_NAME, PyOpcode.DELETE_NAME, PyOpcode.STORE_ATTR, PyOpcode.DELETE_ATTR,
                PyOpcode.STORE_GLOBAL, PyOpcode.DELETE_GLOBAL, PyOpcode.LOAD_NAME, PyOpcode.LOAD_ATTR,
                PyOpcode.IMPORT_NAME, PyOpcode.IMPORT_FROM, PyOpcode.LOAD_GLOBAL
            };
            var localField = new[] { PyOpcode.LOAD_FAST, PyOpcode.STORE_FAST, PyOpcode.DELETE_FAST };

            if (nameField.Contains(op))
            {
                return(_code.Names[arg].ToString());
            }
            if (localField.Contains(op))
            {
                return(_code.Variables[arg].ToString());
            }
            if (op == PyOpcode.LOAD_CONST)
            {
                return(_code.Consts[arg].ToString());
            }
            if (op == PyOpcode.LOAD_CLOSURE)
            {
                return(_code.FreeVariables[arg].ToString());
            }
            return(arg.ToString());
        }
示例#2
0
        private string GetArgument(PyOpcode op, int arg)
        {
            var nameField = new[]
                                {
                                    PyOpcode.STORE_NAME, PyOpcode.DELETE_NAME, PyOpcode.STORE_ATTR, PyOpcode.DELETE_ATTR,
                                    PyOpcode.STORE_GLOBAL, PyOpcode.DELETE_GLOBAL, PyOpcode.LOAD_NAME, PyOpcode.LOAD_ATTR,
                                    PyOpcode.IMPORT_NAME, PyOpcode.IMPORT_FROM, PyOpcode.LOAD_GLOBAL
                                };
            var localField = new[] {PyOpcode.LOAD_FAST, PyOpcode.STORE_FAST, PyOpcode.DELETE_FAST};

            if (nameField.Contains(op))
                return _code.Names[arg].ToString();
            if (localField.Contains(op))
                return _code.Variables[arg].ToString();
            if (op == PyOpcode.LOAD_CONST)
                return _code.Consts[arg].ToString();
            if (op == PyOpcode.LOAD_CLOSURE)
                return _code.FreeVariables[arg].ToString();
            return arg.ToString();
        }