MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / format_node

Function format_node

lib/asmjit/asmjit/core/formatter.cpp:443–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441#endif
442
443Error format_node(
444 String& sb,
445 const FormatOptions& format_options,
446 const BaseBuilder* builder,
447 const BaseNode* node) noexcept {
448
449 if (node->has_position() && format_options.has_flag(FormatFlags::kPositions)) {
450 ASMJIT_PROPAGATE(sb.append_format("<%05u> ", uint32_t(node->position())));
451 }
452
453 size_t start_line_index = sb.size();
454
455 switch (node->type()) {
456 case NodeType::kInst:
457 case NodeType::kJump: {
458 const InstNode* inst_node = node->as<InstNode>();
459 ASMJIT_PROPAGATE(builder->_funcs.format_instruction(sb, format_options.flags(), builder, builder->arch(), inst_node->baseInst(), inst_node->operands()));
460 break;
461 }
462
463 case NodeType::kSection: {
464 const SectionNode* section_node = node->as<SectionNode>();
465 if (builder->_code->is_section_valid(section_node->section_id())) {
466 const Section* section = builder->_code->section_by_id(section_node->section_id());
467 ASMJIT_PROPAGATE(sb.append_format(".section %s", section->name()));
468 }
469 break;
470 }
471
472 case NodeType::kLabel: {
473 const LabelNode* label_node = node->as<LabelNode>();
474 ASMJIT_PROPAGATE(format_label(sb, format_options.flags(), builder, label_node->label_id()));
475 ASMJIT_PROPAGATE(sb.append(":"));
476 break;
477 }
478
479 case NodeType::kAlign: {
480 const AlignNode* align_node = node->as<AlignNode>();
481 ASMJIT_PROPAGATE(sb.append_format(".align %u (%s)",
482 align_node->alignment(),
483 align_node->align_mode() == AlignMode::kCode ? "code" : "data"));
484 break;
485 }
486
487 case NodeType::kEmbedData: {
488 const EmbedDataNode* embed_node = node->as<EmbedDataNode>();
489 ASMJIT_PROPAGATE(sb.append('.'));
490 ASMJIT_PROPAGATE(format_data_type(sb, format_options.flags(), builder->arch(), embed_node->type_id()));
491 ASMJIT_PROPAGATE(sb.append_format(" {Count=%zu Repeat=%zu TotalSize=%zu}", embed_node->item_count(), embed_node->repeat_count(), embed_node->data_size()));
492 break;
493 }
494
495 case NodeType::kEmbedLabel: {
496 const EmbedLabelNode* embed_node = node->as<EmbedLabelNode>();
497 ASMJIT_PROPAGATE(sb.append(".label "));
498 ASMJIT_PROPAGATE(format_label(sb, format_options.flags(), builder, embed_node->label_id()));
499 break;
500 }

Callers 4

_log_nodeFunction · 0.85
annotate_codeMethod · 0.85
format_node_listFunction · 0.85

Calls 15

format_labelFunction · 0.85
format_data_typeFunction · 0.85
format_func_retsFunction · 0.85
format_func_argsFunction · 0.85
format_operandFunction · 0.85
padding_from_optionsFunction · 0.85
has_positionMethod · 0.80
append_formatMethod · 0.80
positionMethod · 0.80
operandsMethod · 0.80
is_section_validMethod · 0.80
section_by_idMethod · 0.80

Tested by

no test coverage detected