Mercurial > repos > tabletprog
diff modules/llcompile.tp @ 361:06dceff348ea
llcompile now has Hacky support for calling C functions using dl to lookup symbols and almost has support string constants
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 23 Apr 2015 19:24:20 -0700 |
parents | 0b83f15e819d |
children |
line wrap: on
line diff
--- a/modules/llcompile.tp Tue Apr 21 09:00:56 2015 -0700 +++ b/modules/llcompile.tp Thu Apr 23 19:24:20 2015 -0700 @@ -24,11 +24,20 @@ _ilFun <- :_name { _buff <- #[] + _data <- #[] _blockStack <- [] + _labelDefs <- dict hash _nextReg <- 0 #{ name <- { _name } add <- :inst { _buff append: inst } + addData <- :data { + lbl <- il label + dataPos <- _data length + _labelDefs set: dataPos lbl + _data append: data + lbl reference + } getReg <- { r <- il reg: _nextReg _nextReg <- _nextReg + 1 @@ -45,6 +54,12 @@ res } buffer <- { _buff } + finalize <- { + foreach: _data :idx data { + _buff append: (_labelDefs get: idx else: { false }) + _buff append: (il data: data) + } + } } } @@ -159,7 +174,18 @@ } } _compileString <- :expr syms ilf assignTo { - + lbl <- ilf addData: (expr val) + v <- assignTo value: :asn { + asn + } none: { + lbl + } + #{ + val <- v + //TODO: Asbstract pointer size + size <- il q + signed? <- false + } } _compileInt <- :expr syms ilf assignTo { sz <- il sizeFromBytes: (expr size) @@ -441,6 +467,7 @@ } none: { ilf add: (il return: 0 (il l)) } + ilf finalize ilf } else: { argErrors