Comments (3)
OPEN ... FOR INPUT has nothing to do with fb_InputByte and fb_InputInt. The latter two are part of the implementations of the INPUT and INPUT # statements, which get translated to multiple rtl calls. There are multiple INPUT/WINPUT/LINE INPUT functions and statements. FB has a lot of quirky syntax like this. See the 'See also' section at https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgInput
Because of all the quirks, the surest way to figure out what rtl functions a FB statement/expression translates to is to compile a test program and inspect the generated assembly/C. Nearly all functions in the runtime are called either only from FB code (calls generated from the compiler) which are usually but not always marked with FBCALL
, or only from other runtime functions. fb_hStr2Double
has an 'h' prefix for 'hidden', so that one is definitely called from the runtime only. I suggest you use gdb to find out the call chain to it.
But if you want to find out why a function gets called, you'll want to look at the compiler source. The AST building code makes tangled decisions about which rtl functions to call based on things like syntax and argument types.
A single FB statement is translated to an AST which may contain some calls to runtime functions. The easiest thing to do is use grep to find the relevant code. If you grep for INPUT, you'll find multiple places where INPUT tokens (FB_TK_INPUT
) can be accepted. INPUT statements are handled by cInputStmt
in parser-quirk-file.bas (called fromcQuirkStmt()
), which calls rtlFileInputGet
to generate the ASTNODE for the rtl call to read a single value from a file (including stdin).
Because there are so many different forms of INPUT, it's easier to go backwards, grepping for InputByte
instead (do a case-insensitive search and remove the fb_ prefix). In rtlFileInputGet
you'll find PROCLOOKUP( INPUTBYTE )
which is the point that a call to this specific rtl function is actually added to the AST. You'll see (both in rtl.bi, which lists the function names, and at the top of rtl-file.bas, which gives the detailed call signature for this function) that the function is called fb_InputByte.
from fbc.
Oh turns out there is one fb_h function called by the compiler: fb_hStrDelTemp
, plus also a set of fb_hPut*
blend operation functions in the graphics library.
from fbc.
@rversteegen Thanks a lot for this information!
Oh, I see what you are saying about the "open ... for input" statement. That's my fault, I am actually interested in the input # statement.
As you suggested, I dug into the .asm file generated using fbc (using the -R flag for the compiler) and I now see that input # has a call to fb_FileInput and fb_Input* (based on the data type of the dst variable). This has saved me so much time!
Thanks again
from fbc.
Related Issues (20)
- _FILE_OBJECT bug HOT 5
- The _DISPATCHER_HEADER structure is incorrect HOT 2
- _IRP Statement bugfix HOT 6
- How to modify FB code to use FB built-in functions in driver development? HOT 1
- unit-tests stuck on ascii HOT 8
- FreeBASIC support for Linux on PowerPC and PowerPC64? HOT 4
- libstdc++-related problems in log-tests HOT 10
- Support for SOURCE_DATE_EPOCH HOT 4
- Golang and FreeBasic HOT 1
- File Append Bug HOT 1
- Date Format Bug HOT 2
- Could fbc achieve the same effect as making a share section in dll HOT 1
- cannot find -ldisphelper HOT 2
- build FreeBasic on macOS 13.1 with clang HOT 1
- if statement fail on div0 HOT 6
- MOVE TO DISCUSSIONS: hdpmi32 and cwsdpmi in dosbox HOT 2
- mangled out
- mangled output windows commandline when using wstr and pipe
- Brecht Sanders MinGW-W64 refrence possibly rather excessive in compiled exe with gcc HOT 9
- fbc64 version 1.20 crashed under Windows 10 64 bit HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fbc.