ELENA-LANG / elena-lang

ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
https://elena-lang.github.io/
MIT License
227 stars 23 forks source link

Converting an external function return to the pointer #568

Closed arakov closed 1 year ago

arakov commented 1 year ago

Describe the bug Converting an external function return to the pointer

To Reproduce Write a snippet code

public program()
{
     pointer ptr := extern elenasm.InterpretScopeFile();
}

which generates the following byte code:

>@function program.function:#invoke
    xflush sp       :0
    open            :4, :8
    store fp        :1
    breakpoint      
    alloc           :0
    call extern     :elenasm.InterpretScopeFile, :0
    free            :0
    save dp         :-8
    ; Here - the conversion is raised between int and pointer 
    newn            :4, class:system'IntNumber
    store fp        :2
    set dp          :-8
    store sp        :0
    peek fp         :2
    copy            :4
    peek fp         :2
    store sp        :0
    peek sp         :0
    mov mssg        :typecast:#cast<system'UnsafePointer>[1]
    call vt         :0
    store fp        :3
    peek fp         :3
    load            
    save dp         :-4
    breakpoint      
    peek fp         :1
Lab00:     nop
    close           :8
    quit            
@end

Expected behavior The implicit conversion between primitive types V_INT32 and V_PTR32 should be made

arakov commented 1 year ago

fixed