Mercurial > repos > tabletprog
changeset 142:833624457b81
Merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 09 Aug 2013 01:37:09 -0700 |
parents | 15aac5334b64 (diff) 5bcaddff29f5 (current diff) |
children | 282b8056b702 |
files | cbackend.js |
diffstat | 4 files changed, 99 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/cbackend.js Thu Aug 08 22:31:41 2013 -0700 +++ b/cbackend.js Fri Aug 09 01:37:09 2013 -0700 @@ -423,7 +423,24 @@ cObject.prototype.addInit = function(statement) { this.init.push(statement); -} +}; + +cObject.prototype.addImport = function(symbols, source) { + this.imported.push(source); + var importNum = imported.length - 1; + if (symbols) { + each(symbols, function(i, sym) { + this.addMessage(sym.name, { + vars: {}, + lines: [ + 'return self->import_' + importNum + '->meta->meth_lookup[method_id & 0xF](method_id, num_args, self->import_' + importNum + ', args);' + ] + }); + }); + } else { + //TODO: handle proxying for unimplemented methods + } +}; cObject.prototype.checkInitMsg = function() { if (!this.initmsgadded && this.init.length) { @@ -515,8 +532,6 @@ object.prototype.toCObject = function() { var messages = this.messages; - var values = []; - var imports = []; if (!this.name) { this.name = 'object_' + nextobject++; } @@ -532,16 +547,16 @@ for (var i in messages) { if (messages[i] instanceof funcall) { if (messages[i].name == 'import:' && messages[i].args.length == 1) { - imports.push({symbols: false, src: messages[i].args[0]}); + me.addImport(false, messages[i].args[0]); } else if(messages[i].name == 'import:from:' && messages[i].args.length == 2) { var importsyms = []; each(messages[i].args[0].val, function(i, el) { if (!(el instanceof symbol)) { throw new Error('Names in import:from statement must be symbols'); } - importsyms.push(new strlit(el.name)); + importsyms.push(el); }); - imports.push({symbols: new listlit(importsyms), src: messages[i].args[1]}); + me.addImport(importsyms, messages[i].args[1]); } else if(messages[i].name == 'llProperty:withType:' && messages[i].args.length == 2) { me.addProperty(messages[i].args[0].name, null, messages[i].args[1].toCTypeName()) } else if(messages[i].name == 'llMessage:withVars:andCode:' && messages[i].args.length == 3) {
--- a/editor.js Thu Aug 08 22:31:41 2013 -0700 +++ b/editor.js Fri Aug 09 01:37:09 2013 -0700 @@ -350,3 +350,8 @@ el.webkitRequestFullscreen(); } } + +function create_symbol(name) +{ + return new symbol(name); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/socket.tp Fri Aug 09 01:37:09 2013 -0700 @@ -0,0 +1,67 @@ +#{ + llMessage: AF_INET withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: AF_INET + intret + } + llMessage: AF_UNIX withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: AF_UNIX + intret + } + llMessage: STREAM withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: SOCK_STREAM + intret + } + llMessage: DGRAM withVars: { + intret <- obj_int32 ptr + } andCode: { + intret <- make_object: (addr_of: obj_int32_meta) NULL 0 + intret num!: SOCK_DGRAM + intret + } + llMessage: socket withVars: { + fd <- obj_int32 ptr + domain <- obj_int32 ptr + type <- obj_int32 ptr + protocol <- obj_int32 ptr + } andCode: :domain type protocol { + fd <- make_object: (addr_of: obj_int32_meta) NULL 0 + fd num!: (socket: (domain num) (type num) (protocol num)) + fd + } + + llMessage: getaddrinfo withVars: { + + } andCode: { + } + + new <- :domain type protocol { + sfd <- socket: domain type protocol + #{ + fd <- {sfd} + llMessage: close withVars: { + sfd <- obj_int32 ptr + } andCode: { + sfd <- mcall: fd 1 self + close: (sfd num) + self + } + } + } + + connectTo:onPort <- :host :port { + + } + listenOn: <- :port { + } + listenAt:onPort <- :host :port { + } +}
--- a/src/editor.tp Thu Aug 08 22:31:41 2013 -0700 +++ b/src/editor.tp Fri Aug 09 01:37:09 2013 -0700 @@ -13,6 +13,7 @@ getEl <- foreign: :from idx {} setEl <- foreign: :to idx val {} goFullScreen <- foreign: {} +create_symbol <- foreign: :name {} //TP Parser parser <- foreign: #{ @@ -238,10 +239,14 @@ event stopPropagation: (foreign: undefined) } +replaceNode:with <- :astnode domnode :newnode { + +} + lambdaClick <- :domnode astnode event { selectNode: domnode popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { - console log: "foooobar!" + replaceNode: astnode domnode with: (create_symbol: key) } inner <- if: ((astnode args) length) > 0 { (astnode args) getEl: 0