Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L LangOptum
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Nuclaer
  • LangOptum
  • Wiki
  • Builtins

Builtins · Changes

Page history
Update Builtins - add section for strings, input, and some conversion functions authored Apr 19, 2020 by Nuclaer's avatar Nuclaer
Hide whitespace changes
Inline Side-by-side
Showing with 57 additions and 2 deletions
+57 -2
  • Builtins.md Builtins.md +57 -2
  • No files found.
Builtins.md
View page @ 54f065cc
# Builtin Types
## String
This is compiled as a C string, but differs from a `uint8*` or `int8*` in that it has utilities for simple string manipulation, and looks more like a class in code.
### Creation
```
"String literals are String \"objects\""
// TODO: add more examples, if they apply later
```
String literals are String objects.
### Concatination
```
String my_str = "Hello ";
println(my_str + "world!"); // prints "Hello world!"
```
Use a plus sign like Python or Java!
### Substring
```
String my_str = "Hello World!dfghgfdfghj";
println(my_str[0:12]);
```
# Builtin Functions
Builtin functions are compiled as special symbols before assembly generation, so they can be optimized for the target architecture. They are NOT normal functions (in fact technically they are not functions at all...)
......@@ -19,6 +50,30 @@ These functions write to stdout and take any type of argument. println will add
With `int8` and `uint8`, they will print the argument as a character. For all other integer types the argument is printed as a number in base 10.
`int8*`s are printed as C strings.
`int8*`s are printed as C strings. Same goes for `String` objects.
All other pointers are printed in lowercase hexadecimal, without any preceding '0x' (you can add this yourself very easily).
## input
```
String input(uint8* str = null);
```
Gets the next line from stdin. If `str` is not null, then it is printed without a newline first.
## tostring, toint64, touint64
```
String tostring(any);
int64 toint64(String num);
int64 toint64(uint8* num);
int64 toint64(int8* num);
int64 touint64(String num);
int64 touint64(uint8* num);
int64 touint64(int8* num);
```
All other pointers are printed in lowercase hexadecimal, without any preceding '0x' (you can add this yourself very easily).
\ No newline at end of file
`tostring` will take any primitive type and convert it to a string.
`toint64` will parse any string to a signed integer, skipping preceding whitespace and stopping at any non-digit.
`touint64` will parse any string to an unsigned integer, skipping preceding whitespace and stopping at any non-digit.
\ No newline at end of file
Clone repository
  • Builtins
  • Compiler Mechanics
  • Compiler Structure
  • Desired Builtin Libraries
  • File Inclusion
  • Home
  • OOP
  • Operator Notes
  • Preprocessor
  • Program Control
  • Variable Types
  • language
  • lort (LO RunTime)