def __init__(self, this, context, include_native_frames=True): frames = [] caller_context = context while True: if not caller_context: break frame = compose_stack_frame(caller_context) frames.append(frame) caller_context = helpers.get_caller_context(caller_context) frames.reverse() frames.pop() if include_native_frames: native_frames = [] for frame in inspect.trace()[1:]: location = dsl_types.ExpressionFilePosition( os.path.abspath(frame[1]), frame[2], -1, frame[2], -1) method = frame[3] native_frames.append({ 'instruction': frame[4][0].strip(), 'location': location, 'methodName': method, 'typeName': None }) frames.extend(native_frames) this.properties.frames = frames
def _insert_instruction(): context = helpers.get_context() if context: frame = inspect.stack()[2] location = dsl_types.ExpressionFilePosition( os.path.abspath(frame[1]), frame[2], -1, frame[2], -1) context[constants.CTX_CURRENT_INSTRUCTION] = NativeInstruction( frame[4][0].strip(), location)
def build_position(node): return dsl_types.ExpressionFilePosition(file_id, node.start_mark.line + 1, node.start_mark.column + 1, node.end_mark.line + 1, node.end_mark.column + 1)