Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #3197
| From | antispam@math.uni.wroc.pl |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Implementing built-in functions with LLVM, help needed |
| Date | 2022-10-13 14:08 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <22-10-027@comp.compilers> (permalink) |
| References | <22-10-019@comp.compilers> <22-10-022@comp.compilers> |
Christopher F Clark <christopher.f.clark@compiler-resources.com> wrote:
> I'm surprised no one has chimed in yet, so I will.
>
> > How should I implement functions like writeln, read, etc?
>
> I presume you have a design for "user defined" functions and
> procedures. If not, you need that first. That is roughly how you pass
> in parameters and receive return values. Usually there is a convention
> (often defined by the OS or these days the C compiler) that one
> follows to do that.
>
> But once you have that, you can call functions. And, if it is a
> convention suitable for C, it specifies how you handle variadic
> functions, functions that take a variable number of arguments like
> writeln.
Treating writeln via variable argument call is wrong. Compiler
is supposed to split writeln into separate simpler statements.
This leads to subtle difference, folks trying to implement
Pascal via C-like approach at some moment learn the difference
and fix their compilers, but it is better to get it right the
first time.
> Now, you may need some Pascal specific wrinkles because the
> Pascal language supports things like variables from the parent scope
> (a subset of the closure concept) and for writeln knowing the type of
> the variable passed so that you can format it properly
> ("descriptors").
Syntax of buitins is different that normal calls, that is easy
to handle in parser but must be done before call. And builtins
are overloaded, in dialects with many builtins handling of
overloading may take most of implementation.
> Still, the ability to call functions is the key thing you need to do.
Sure.
--
Waldek Hebisch
Back to comp.compilers | Previous | Next — Previous in thread | Find similar
Implementing built-in functions with LLVM, help needed Ivan Espinosa <ivanmtze96@gmail.com> - 2022-10-03 15:13 -0700
Re: Implementing built-in functions with LLVM, help needed antispam@math.uni.wroc.pl - 2022-10-06 15:15 +0000
Implementing built-in functions with LLVM, help needed Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-10-07 08:56 +0300
Re: Implementing built-in functions with LLVM, help needed Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-10-07 20:59 +0200
Re: Implementing built-in functions with LLVM, help needed antispam@math.uni.wroc.pl - 2022-10-13 14:08 +0000
csiph-web