51 lines
1.4 KiB
Markdown
51 lines
1.4 KiB
Markdown
# The Core Language
|
|
|
|
A compiled language with Go like type system, Jai like syntax, order indepent declarations using Ion algorithm. Made to practice language development. It has lot's of ideas from modern programming languages that you would not find in any compiler book.
|
|
|
|
## Language example code
|
|
|
|
``` C
|
|
#import "Windows.kl"
|
|
#import "base.kl"
|
|
|
|
PAGE_SIZE :: 4096
|
|
Memory :: struct
|
|
commit : SizeU
|
|
reserve: SizeU
|
|
data : *U8
|
|
|
|
reserve :: (size: SizeU): Memory
|
|
result := Memory{reserve=align_up(size, PAGE_SIZE)}
|
|
result.data = VirtualAlloc(
|
|
flProtect = PAGE_READWRITE,
|
|
dwSize = result.reserve,
|
|
flAllocationType = MEM_RESERVE,
|
|
lpAddress = 0)->*U8
|
|
return result
|
|
|
|
commit :: (m: *Memory, size: SizeU): Bool
|
|
commit_size := align_up(size, PAGE_SIZE)
|
|
total_commit := m.commit + commit_size
|
|
clamped_commit := clamp_top_sizeu(total_commit, m.reserve)
|
|
adjusted_commit := clamped_commit - m.commit
|
|
if adjusted_commit != 0
|
|
result := VirtualAlloc(
|
|
lpAddress = (m.data + m.commit)->*void,
|
|
dwSize = adjusted_commit,
|
|
flAllocationType = MEM_COMMIT,
|
|
flProtect = PAGE_READWRITE,
|
|
)
|
|
m.commit += adjusted_commit
|
|
return true
|
|
return false
|
|
|
|
```
|
|
|
|
### Actual examples that explain language features can be found in /examples
|
|
|
|
|
|
# Building
|
|
|
|
1. Requires *Windows*, *Visual Studio* and *Clang* to be installed
|
|
1. Run *build.bat*
|
|
1. They lived happily ever after |