def wrapExpressionBuiltinExecCreation(source, globals, locals, source_ref): provider = node.getParentVariableProvider() # TODO: Can't really be true, can it? if provider.isExpressionFunctionBody(): provider.markAsExecContaining() if provider.isClassDictCreation(): provider.markAsUnqualifiedExecContaining( source_ref ) temp_scope = provider.allocateTempScope("exec") globals_ref, locals_ref, tried, final = wrapEvalGlobalsAndLocals( provider = provider, globals_node = globals, locals_node = locals, temp_scope = temp_scope, source_ref = source_ref ) return ExpressionTryFinally( tried = tried, final = final, expression = ExpressionBuiltinExec( source_code = source, globals_arg = globals_ref, locals_arg = locals_ref, source_ref = source_ref ), source_ref = source_ref )
def wrapExpressionBuiltinExecCreation(source, globals_arg, locals_arg, source_ref): provider = node.getParentVariableProvider() outline_body = ExpressionOutlineBody( provider = provider, name = "exec_call", source_ref = source_ref ) globals_ref, locals_ref, tried, final = wrapEvalGlobalsAndLocals( provider = provider, globals_node = globals_arg, locals_node = locals_arg, temp_scope = outline_body.getOutlineTempScope(), source_ref = source_ref ) tried = makeStatementsSequence( statements = ( tried, StatementReturn( expression = ExpressionBuiltinExec( source_code = source, globals_arg = globals_ref, locals_arg = locals_ref, source_ref = source_ref ), source_ref = source_ref ), ), allow_none = False, source_ref = source_ref ) # Hack: Allow some APIs to work already tried.parent = outline_body outline_body.setBody( makeStatementsSequenceFromStatement( statement = makeTryFinallyStatement( provider = provider, tried = tried, final = final, source_ref = source_ref ) ) ) return outline_body
def wrapExpressionBuiltinExecCreation(source, globals_arg, locals_arg, source_ref): provider = node.getParentVariableProvider() outline_body = ExpressionOutlineBody( provider=provider, name="exec_call", body=None, # later source_ref=source_ref) # TODO: Can't really be true, can it? if provider.isExpressionFunctionBody(): provider.markAsExecContaining() if provider.isExpressionClassBody(): provider.markAsUnqualifiedExecContaining(source_ref) globals_ref, locals_ref, tried, final = wrapEvalGlobalsAndLocals( provider=provider, globals_node=globals_arg, locals_node=locals_arg, temp_scope=outline_body.getOutlineTempScope(), source_ref=source_ref) tried = makeStatementsSequence(statements=( tried, StatementReturn(expression=ExpressionBuiltinExec( source_code=source, globals_arg=globals_ref, locals_arg=locals_ref, source_ref=source_ref), source_ref=source_ref), ), allow_none=False, source_ref=source_ref) # Hack: Allow some APIs to work already tried.parent = outline_body outline_body.setBody( makeStatementsSequenceFromStatement( statement=makeTryFinallyStatement(provider=provider, tried=tried, final=final, source_ref=source_ref))) return outline_body
def wrapExpressionBuiltinExecCreation(source, globals, locals, source_ref): provider = node.getParentVariableProvider() # TODO: Can't really be true, can it? if provider.isExpressionFunctionBody(): provider.markAsExecContaining() if provider.isClassDictCreation(): provider.markAsUnqualifiedExecContaining(source_ref) globals_wrap, locals_wrap = wrapEvalGlobalsAndLocals( provider=provider, globals_node=globals, locals_node=locals, exec_mode=False, source_ref=source_ref) return ExpressionBuiltinExec(source_code=source, globals_arg=globals_wrap, locals_arg=locals_wrap, source_ref=source_ref)