<commit_before>/*
Copyright (c) 2011, 2012 <NAME> <<EMAIL>>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package llvm

import (
    "path"
    "reflect"
)

///////////////////////////////////////////////////////////////////////////////
// Common types and constants.

const (
    LLVMDebugVersion = (11 << 16)
)

type DwarfTag uint32
const (
    DW_TAG_compile_unit     DwarfTag = 0x11
    DW_TAG_variable         DwarfTag = 0x34
    DW_TAG_base_type        DwarfTag = 0x24
    DW_TAG_pointer_type     DwarfTag = 0x0F
    DW_TAG_structure_type   DwarfTag = 0x13
    DW_TAG_subroutine_type  DwarfTag = 0x15
    DW_TAG_file_type        DwarfTag = 0x29
    DW_TAG_subprogram       DwarfTag = 0x2E
)

type DwarfLang uint32
const (
    // http://dwarfstd.org/ShowIssue.php?issue=101014.1&type=open
    DW_LANG_Go DwarfLang = 0x0016
)

type DwarfTypeEncoding uint32
const (
    DW_ATE_address         DwarfTypeEncoding = 0x01
    DW_ATE_boolean         DwarfTypeEncoding = 0x02
    DW_ATE_complex_float   DwarfTypeEncoding = 0x03
    DW_ATE_float           DwarfTypeEncoding = 0x04
    DW_ATE_signed          DwarfTypeEncoding = 0x05
    DW_ATE_signed_char     DwarfTypeEncoding = 0x06
    DW_ATE_unsigned        DwarfTypeEncoding = 0x07
    DW_ATE_unsigned_char   DwarfTypeEncoding = 0x08
    DW_ATE_imaginary_float DwarfTypeEncoding = 0x09
    DW_ATE_packed_decimal  DwarfTypeEncoding = 0x0a
    DW_ATE_numeric_string  DwarfTypeEncoding = 0x0b
    DW_ATE_edited          DwarfTypeEncoding = 0x0c
    DW_ATE_signed_fixed    DwarfTypeEncoding = 0x0d
    DW_ATE_unsigned_fixed  DwarfTypeEncoding = 0x0e
    DW_ATE_decimal_float   DwarfTypeEncoding = 0x0f
    DW_ATE_UTF             DwarfTypeEncoding = 0x10
    DW_ATE_lo_user         DwarfTypeEncoding = 0x80
    DW_ATE_hi_user         DwarfTypeEncoding = 0xff
)

type DebugInfo struct {
    cache map[DebugDescriptor]Value
}

type DebugDescriptor interface {
    // Tag returns the DWARF tag for this descriptor.
    Tag() DwarfTag

    // MDNode creates an LLVM metadata node.
    mdNode(i *DebugInfo) Value
}

///////////////////////////////////////////////////////////////////////////////
// Utility functions.

func constInt1(v bool) Value {
    if v {return ConstAllOnes(Int1Type())}
    return ConstNull(Int1Type())
}

func (info *DebugInfo) MDNode(d DebugDescriptor) Value {
    // A nil pointer assigned to an interface does not result in a nil
    // interface. Instead, we must check the innards.
    if d == nil || reflect.ValueOf(d).IsNil() {return Value{nil}}

    println(d)
    if info.cache == nil {info.cache = make(map[DebugDescriptor]Value)}<commit_msg>Remove stray debug statement<commit_after>/*
Copyright (c) 2011, 2012 <NAME> <<EMAIL>>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package llvm

import (
    "path"
    "reflect"
)

///////////////////////////////////////////////////////////////////////////////
// Common types and constants.

const (
    LLVMDebugVersion = (11 << 16)
)

type DwarfTag uint32
const (
    DW_TAG_compile_unit     DwarfTag = 0x11
    DW_TAG_variable         DwarfTag = 0x34
    DW_TAG_base_type        DwarfTag = 0x24
    DW_TAG_pointer_type     DwarfTag = 0x0F
    DW_TAG_structure_type   DwarfTag = 0x13
    DW_TAG_subroutine_type  DwarfTag = 0x15
    DW_TAG_file_type        DwarfTag = 0x29
    DW_TAG_subprogram       DwarfTag = 0x2E
)

type DwarfLang uint32
const (
    // http://dwarfstd.org/ShowIssue.php?issue=101014.1&type=open
    DW_LANG_Go DwarfLang = 0x0016
)

type DwarfTypeEncoding uint32
const (
    DW_ATE_address         DwarfTypeEncoding = 0x01
    DW_ATE_boolean         DwarfTypeEncoding = 0x02
    DW_ATE_complex_float   DwarfTypeEncoding = 0x03
    DW_ATE_float           DwarfTypeEncoding = 0x04
    DW_ATE_signed          DwarfTypeEncoding = 0x05
    DW_ATE_signed_char     DwarfTypeEncoding = 0x06
    DW_ATE_unsigned        DwarfTypeEncoding = 0x07
    DW_ATE_unsigned_char   DwarfTypeEncoding = 0x08
    DW_ATE_imaginary_float DwarfTypeEncoding = 0x09
    DW_ATE_packed_decimal  DwarfTypeEncoding = 0x0a
    DW_ATE_numeric_string  DwarfTypeEncoding = 0x0b
    DW_ATE_edited          DwarfTypeEncoding = 0x0c
    DW_ATE_signed_fixed    DwarfTypeEncoding = 0x0d
    DW_ATE_unsigned_fixed  DwarfTypeEncoding = 0x0e
    DW_ATE_decimal_float   DwarfTypeEncoding = 0x0f
    DW_ATE_UTF             DwarfTypeEncoding = 0x10
    DW_ATE_lo_user         DwarfTypeEncoding = 0x80
    DW_ATE_hi_user         DwarfTypeEncoding = 0xff
)

type DebugInfo struct {
    cache map[DebugDescriptor]Value
}

type DebugDescriptor interface {
    // Tag returns the DWARF tag for this descriptor.
    Tag() DwarfTag

    // MDNode creates an LLVM metadata node.
    mdNode(i *DebugInfo) Value
}

///////////////////////////////////////////////////////////////////////////////
// Utility functions.

func constInt1(v bool) Value {
    if v {return ConstAllOnes(Int1Type())}
    return ConstNull(Int1Type())
}

func (info *DebugInfo) MDNode(d DebugDescriptor) Value {
    // A nil pointer assigned to an interface does not result in a nil
    // interface. Instead, we must check the innards.
    if d == nil || reflect.ValueOf(d).IsNil() {return Value{nil}}

    if info.cache == nil {info.cache = make(map[DebugDescriptor]Value)}
{'fraction_non_alphanumeric': 0.09502639622117255, 'fraction_numerical': 0.028063350930814114, 'mean_word_length': 2.87668282175552, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2429424', 'n_tokens_mistral': 2328, 'n_tokens_neox': 2105, 'n_words': 707}