pyslc.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:PYSL 作者: sparkon 项目源码 文件源码
def PYSL_tl_decl(node: ast.AnnAssign):
    """Parses a specific top-level declaration"""
    if not isinstance(node.annotation, ast.Call) or (node.annotation.func.id != 'register' or
       len(node.annotation.args) != 2 or
       not isinstance(node.annotation.args[0], ast.Name) or
       not isinstance(node.annotation.args[1], ast.Num)):
        error(loc(node), "Invalid top level resource declaration, see docs. <name> : register(<type>, <slot>) = (...)")

    res_name = node.target.id
    res_type = node.annotation.args[0].id
    res_slot = node.annotation.args[1].n

    if res_type in pysl.Language.Sampler.TYPES:
        emitter.sampler(parse_sampler(node, res_name, res_type[7:], res_slot, node.value))
    else:
        error((node), "Unrecognized top-level resource declaration {0} : {1}".format(res_name, res_type))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号