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))
评论列表
文章目录