How to use the schema.immutable.istype function in schema

To help you get started, we’ve selected a few schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cheery / essence / seed / strikec.py View on Github external
def compile_expr(build, expr, env):
    if istype(expr, u"number:value"):
        return Constant.int(int_t, int(expr.value))
    if istype(expr, u"call:callee:arguments"):
        assert istype(expr.callee, u"variable:name")
        callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)
        env[expr.slot.name] = value
        return value
github cheery / essence / seed / strikec.py View on Github external
if istype(expr, u"number:value"):
        return Constant.int(int_t, int(expr.value))
    if istype(expr, u"call:callee:arguments"):
        assert istype(expr.callee, u"variable:name")
        callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)
        env[expr.slot.name] = value
        return value
    if istype(expr, u"return:value"):
        value = compile_expr(build, expr.value, env)
        build.ret(value)
        return value
    raise CompilationError(expr.proxy, "unknown statement")
github cheery / essence / seed / strikec.py View on Github external
def compile_expr(build, expr, env):
    if istype(expr, u"number:value"):
        return Constant.int(int_t, int(expr.value))
    if istype(expr, u"call:callee:arguments"):
        assert istype(expr.callee, u"variable:name")
        callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)
        env[expr.slot.name] = value
        return value
    if istype(expr, u"return:value"):
        value = compile_expr(build, expr.value, env)
        build.ret(value)
        return value
    raise CompilationError(expr.proxy, "unknown statement")
github cheery / essence / seed / strikec.py View on Github external
def compile_expr(build, expr, env):
    if istype(expr, u"number:value"):
        return Constant.int(int_t, int(expr.value))
    if istype(expr, u"call:callee:arguments"):
        assert istype(expr.callee, u"variable:name")
        callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)
        env[expr.slot.name] = value
        return value
    if istype(expr, u"return:value"):
        value = compile_expr(build, expr.value, env)
        build.ret(value)
        return value
    raise CompilationError(expr.proxy, "unknown statement")
github cheery / essence / seed / strikec.py View on Github external
callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)
        env[expr.slot.name] = value
        return value
    if istype(expr, u"return:value"):
        value = compile_expr(build, expr.value, env)
        build.ret(value)
        return value
    raise CompilationError(expr.proxy, "unknown statement")
github cheery / essence / seed / strikec.py View on Github external
def compile_expr(build, expr, env):
    if istype(expr, u"number:value"):
        return Constant.int(int_t, int(expr.value))
    if istype(expr, u"call:callee:arguments"):
        assert istype(expr.callee, u"variable:name")
        callee_fn = env[expr.callee.name]
        if len(callee_fn.args) != len(expr.arguments):
            raise CompilationError(expr.arguments.proxy, "incorrect argument count")
        argv = [compile_expr(build, argument, env) for argument in expr.arguments]
        return build.call(callee_fn, argv)
    if istype(expr, u"variable:name"):
        if expr.name in env:
            return env[expr.name]
        else:
            raise CompilationError(expr.proxy, "out of scope")
    if istype(expr, u"assign:slot:value"):
        assert istype(expr.slot, u"variable:name")
        value = compile_expr(build, expr.value, env)