吐槽 2 mins

我们国产语言木兰

16-03-20 / 612 Words

……出门看火伴,火伴皆惊忙:同行十二年,不知木兰是素贞。

没错,我们国产语言木兰上线发布了,真好!

你看这完美的图标!

再看这美妙的手感!

我准备为之惊呼!

等下,这个图标……

这不是Pyinstaller打包完的图标吗?!

我们掏出PyInstaller Extractorhttps://github.com/NeoTim/PyInstallerExtractorhttps://sourceforge.net/projects/pyinstallerextractor/)。

进行解包……

$ python pyinstxtractor.py ulang-0.2.2.exe

不愧是敢用Pyinstaller的语言

你好歹也加个图标啊!

让我们看看ulang.runtime.env节选

return {
    "print"             : local_print,
    "println"           : lambda *objs: local_print(*objs, **{"end":"\n"}),
    "assert"            : local_assert,
    "len"               : len,
    "enumerate"         : enumerate,
    "all"               : all,
    "any"               : any,
    "range"             : range,
    "round"             : round,
    "input"             : input,
    "reverse"           : reversed,
    "super"             : super,
    "locals"            : lambda: locals(),
    "bool"              : bool,
    "float"             : float,
    "int"               : int,
    "str"               : str,
    "list"              : list,
    "dict"              : dict,
    "set"               : set,
    "tuple"             : lambda *args: args,
    "char"              : chr,
    "ord"               : ord,
    "bytes"             : lambda s, encoding="ascii":bytes(s, encoding),
    "typeof"            : lambda x: x.__class__.__name__,
    "isa"               : lambda x, t: isinstance(x, t),
    "max"               : max,
    "min"               : min,
    "map"               : map,
    "filter"            : filter,
    "zip"               : zip,
    "staticmethod"      : staticmethod,
    "property"          : property,
    "ceil"              : math.ceil,
    "floor"             : math.floor,
    "fabs"              : math.fabs,
    "sqrt"              : math.sqrt,
    "log"               : math.log,
    "log10"             : math.log10,
    "exp"               : math.exp,
    "pow"               : math.pow,
    "sin"               : math.sin,
    "cos"               : math.cos,
    "tan"               : math.tan,
    "asin"              : math.asin,
    "acos"              : math.acos,
    "atan"              : math.atan,
    "spawn"             : builtin_spawn,
    "kill"              : builtin_kill,
    "self"              : builtin_self,
    "quit"              : sys.exit,
    "open"              : open,
    "install"           : pip_install,
    "time"              : time.time,
    "year"              : lambda: datetime.now().year,
    "month"             : lambda: datetime.now().month,
    "day"               : lambda: datetime.now().day,
    "hour"              : lambda: datetime.now().hour,
    "minute"            : lambda: datetime.now().minute,
    "second"            : lambda: datetime.now().second,
    "microsecond"       : lambda: datetime.now().microsecond,
    "sleep"             : time.sleep,
    "delay"             : lambda ms: time.sleep(ms / 1000),
    "delayMicroseconds" : lambda us: time.sleep(us / 1000000),
    "PI"                : math.pi,
    "ARGV"              : argv,
    "__builtins__"      : fix_builtins(
        {
            "__import__"      : local_import,
            "__build_class__" : __build_class__,
            "__name__"        : "__main__",
            "__file__"        : fname,
            "__print__"       : eval_print,
            "___"             : None,
            "__div__"         : __builtin_div,
            "__rem__"         : __builtin_rem,
        }
    ),
}

不愧是国产大项目

graph TD; 获取指令-->替换成Python代码; 替换成Python代码-->exec;

参考: