diff options
-rw-r--r-- | combined.js | 60 | ||||
-rw-r--r-- | js/Sinks/CLKOUTV_f.js | 60 | ||||
-rwxr-xr-x | sci2jsyacc.py | 83 |
3 files changed, 184 insertions, 19 deletions
diff --git a/combined.js b/combined.js index 3ec3ed41..b52bbe00 100644 --- a/combined.js +++ b/combined.js @@ -15321,6 +15321,66 @@ function CLKOUTV_f() { } return new EventOutBlock(this.x); } + CLKOUTV_f.prototype.getinputs = function CLKOUTV_f() { + orig = arg1.graphics.orig; + sz = arg1.graphics.sz; + this.x = orig[1-1]+sz[1-1]/2; + y = orig[2-1]+sz[2-1]; + typ = -ones(this.x); + } + CLKOUTV_f.prototype.getorigin = function CLKOUTV_f() { + [this.x,y] = this.standard_origin[arg1-1]; + } + CLKOUTV_f.prototype.getoutputs = function CLKOUTV_f() { + this.x = []; + y = []; + typ = []; + } + CLKOUTV_f.prototype.plot = function CLKOUTV_f() { + xf = 60; + yf = 40; + orig = arg1.graphics.orig; + sz = arg1.graphics.sz; + orient = arg1.graphics.flip; + this.prt = arg1.model.ipar; + pat = xget("pattern"); + xset("pattern",this.default_color[-1-1]); + thick = xget("thickness"); + xset("thickness",2); + this.x = orig[1-1]+sz[1-1]*[[1/2],[1],[1],[0],[0]]; + y = orig[2-1]+sz[2-1]*[[0],[1/3],[1],[1],[1/3]]; + xo = orig[1-1]; + yo = orig[2-1]+sz[2-1]/3; + gr_i = arg1.graphics.gr_i; + if (this.type[gr_i-1]==15) { + coli = gr_i[2-1]; + pcoli = xget("pattern"); + xfpolys(this.x,y,coli); + xset("pattern",coli); + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + xset("pattern",pcoli); + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + } else { + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + xpoly(this.x,y,"lines",1); + } + in1 = [-1/14,1/7,0,0,1/14,1/7,-1/14,1/7]*this.diag[[xf,yf]-1]; + xfpoly(in1.slice()[1-1]+ones(4,1)*(orig[1-1]+sz[1-1]/2),in1.slice()[2-1]+ones(4,1)*(orig[2-1]+sz[2-1]),1); + xset("thickness",thick); + xset("pattern",pat); + ident = arg1.graphics.id; + if (ident!=[]&&ident!="") { + font = xget("font"); + xset("font",this.options.ID[1-1][1-1],this.options.ID[1-1][2-1]); + rectangle = xstringl(orig[1-1],orig[2-1],ident); + w = rectangle[3-1]; + h = rectangle[4-1]; + xstringb(orig[1-1]+sz[1-1]/2-w/2,orig[2-1]-3*h/2,ident,w,h); + xset("font",font[1-1],font[2-1]); + } + this.x = []; + y = []; + } } /* autogenerated from "macros/Sinks/CLKOUT_f.sci" */ function CLKOUT_f() { diff --git a/js/Sinks/CLKOUTV_f.js b/js/Sinks/CLKOUTV_f.js index 84fe7ade..024abf7d 100644 --- a/js/Sinks/CLKOUTV_f.js +++ b/js/Sinks/CLKOUTV_f.js @@ -42,4 +42,64 @@ function CLKOUTV_f() { } return new EventOutBlock(this.x); } + CLKOUTV_f.prototype.getinputs = function CLKOUTV_f() { + orig = arg1.graphics.orig; + sz = arg1.graphics.sz; + this.x = orig[1-1]+sz[1-1]/2; + y = orig[2-1]+sz[2-1]; + typ = -ones(this.x); + } + CLKOUTV_f.prototype.getorigin = function CLKOUTV_f() { + [this.x,y] = this.standard_origin[arg1-1]; + } + CLKOUTV_f.prototype.getoutputs = function CLKOUTV_f() { + this.x = []; + y = []; + typ = []; + } + CLKOUTV_f.prototype.plot = function CLKOUTV_f() { + xf = 60; + yf = 40; + orig = arg1.graphics.orig; + sz = arg1.graphics.sz; + orient = arg1.graphics.flip; + this.prt = arg1.model.ipar; + pat = xget("pattern"); + xset("pattern",this.default_color[-1-1]); + thick = xget("thickness"); + xset("thickness",2); + this.x = orig[1-1]+sz[1-1]*[[1/2],[1],[1],[0],[0]]; + y = orig[2-1]+sz[2-1]*[[0],[1/3],[1],[1],[1/3]]; + xo = orig[1-1]; + yo = orig[2-1]+sz[2-1]/3; + gr_i = arg1.graphics.gr_i; + if (this.type[gr_i-1]==15) { + coli = gr_i[2-1]; + pcoli = xget("pattern"); + xfpolys(this.x,y,coli); + xset("pattern",coli); + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + xset("pattern",pcoli); + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + } else { + xstringb(xo,yo,string(this.prt),sz[1-1],sz[2-1]/1.5); + xpoly(this.x,y,"lines",1); + } + in1 = [-1/14,1/7,0,0,1/14,1/7,-1/14,1/7]*this.diag[[xf,yf]-1]; + xfpoly(in1.slice()[1-1]+ones(4,1)*(orig[1-1]+sz[1-1]/2),in1.slice()[2-1]+ones(4,1)*(orig[2-1]+sz[2-1]),1); + xset("thickness",thick); + xset("pattern",pat); + ident = arg1.graphics.id; + if (ident!=[]&&ident!="") { + font = xget("font"); + xset("font",this.options.ID[1-1][1-1],this.options.ID[1-1][2-1]); + rectangle = xstringl(orig[1-1],orig[2-1],ident); + w = rectangle[3-1]; + h = rectangle[4-1]; + xstringb(orig[1-1]+sz[1-1]/2-w/2,orig[2-1]-3*h/2,ident,w,h); + xset("font",font[1-1],font[2-1]); + } + this.x = []; + y = []; + } } diff --git a/sci2jsyacc.py b/sci2jsyacc.py index 54eeffc0..4ed123b9 100755 --- a/sci2jsyacc.py +++ b/sci2jsyacc.py @@ -15,7 +15,7 @@ import sys import pickle import ply.yacc as yacc -from sci2jslex import tokens +from sci2jslex import tokens, JOBTYPES precedence = ( ('left', 'COLON'), @@ -62,17 +62,29 @@ def p_jobfunctionblock_jobfunctionstatement_statementblock_endfunction(p): INDENT_LEVEL += 1 blocktype = getblocktype(fname) - jdefine = JOB_BLOCKS['"define"'] if '"define"' in JOB_BLOCKS else '' + jdefine = JOB_BLOCKS['"define"'] + jget = JOB_BLOCKS['"get"'] + jgetinputs = JOB_BLOCKS['"getinputs"'] + jgetorigin = JOB_BLOCKS['"getorigin"'] + jgetoutputs = JOB_BLOCKS['"getoutputs"'] + jplot = JOB_BLOCKS['"plot"'] + jset = JOB_BLOCKS['"set"'] + jdefine = '%s%s.prototype.define = function %s() {\n%s%*sreturn new %s(this.x);\n%s}\n' % (indent, fname, fname, jdefine, INDENT_LEVEL * INDENT_SIZE, ' ', blocktype, indent) - jdetails = JOB_BLOCKS['"details"'] if '"details"' in JOB_BLOCKS else '' - jdetails = '%s%s.prototype.details = function %s() {\n%s%*sreturn this.x;\n%s}\n' % (indent, fname, fname, jdetails, INDENT_LEVEL * INDENT_SIZE, ' ', indent) - jget = JOB_BLOCKS['"get"'] if '"get"' in JOB_BLOCKS else '' + jdetails = '%s%s.prototype.details = function %s() {\n%*sreturn this.x;\n%s}\n' % (indent, fname, fname, INDENT_LEVEL * INDENT_SIZE, ' ', indent) jget = '%s%s.prototype.get = function %s() {\n%s%s}\n' % (indent, fname, fname, jget, indent) - jset = JOB_BLOCKS['"set"'] if '"set"' in JOB_BLOCKS else '' + if jgetinputs != '': + jgetinputs = '%s%s.prototype.getinputs = function %s() {\n%s%s}\n' % (indent, fname, fname, jgetinputs, indent) + if jgetorigin != '': + jgetorigin = '%s%s.prototype.getorigin = function %s() {\n%s%s}\n' % (indent, fname, fname, jgetorigin, indent) + if jgetoutputs != '': + jgetoutputs = '%s%s.prototype.getoutputs = function %s() {\n%s%s}\n' % (indent, fname, fname, jgetoutputs, indent) + if jplot != '': + jplot = '%s%s.prototype.plot = function %s() {\n%s%s}\n' % (indent, fname, fname, jplot, indent) jset = '%s%s.prototype.set = function %s() {\n%s%*sreturn new %s(this.x);\n%s}\n' % (indent, fname, fname, jset, INDENT_LEVEL * INDENT_SIZE, ' ', blocktype, indent) INDENT_LEVEL -= 1 - p[0] = 'function %s() {\n%s%s%s%s}' % (fname, jdefine, jdetails, jget, jset) + p[0] = 'function %s() {\n%s%s%s%s%s%s%s%s}' % (fname, jdefine, jdetails, jget, jset, jgetinputs, jgetorigin, jgetoutputs, jplot) def p_functionblock_functionstatement_statementblock_endfunction(p): 'functionblock : functionstatement statementblock ENDFUNCTION EOL' @@ -318,6 +330,9 @@ def p_selectstatement_select(p): def p_selectjobstatement_select(p): 'selectjobstatement : SELECT JOB EOL' + JOB_BLOCKS['"get"'] = '' + for t in JOBTYPES.keys(): + JOB_BLOCKS[t] = '' p[0] = '' def p_casestatement_case(p): @@ -330,18 +345,48 @@ def p_casestatement_case(p): def p_casejobstatement_case(p): '''casejobstatement : CASE expression THEN EOL - | CASE expression EOL - | CASE JOB_DEFINE THEN EOL - | CASE JOB_DEFINE EOL - | CASE JOB_GETINPUTS THEN EOL - | CASE JOB_GETINPUTS EOL - | CASE JOB_GETORIGIN THEN EOL - | CASE JOB_GETORIGIN EOL - | CASE JOB_GETOUTPUTS THEN EOL - | CASE JOB_GETOUTPUTS EOL - | CASE JOB_PLOT THEN EOL - | CASE JOB_PLOT EOL - | CASE JOB_SET THEN EOL + | CASE expression EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_define(p): + '''casejobstatement : CASE JOB_DEFINE THEN EOL + | CASE JOB_DEFINE EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_getinputs(p): + '''casejobstatement : CASE JOB_GETINPUTS THEN EOL + | CASE JOB_GETINPUTS EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_getorigin(p): + '''casejobstatement : CASE JOB_GETORIGIN THEN EOL + | CASE JOB_GETORIGIN EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_getoutputs(p): + '''casejobstatement : CASE JOB_GETOUTPUTS THEN EOL + | CASE JOB_GETOUTPUTS EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_plot(p): + '''casejobstatement : CASE JOB_PLOT THEN EOL + | CASE JOB_PLOT EOL''' + LOCAL_VARS.clear() + LOCAL_VARS.update(FUNCTION_VARS) + p[0] = '%s' % (p[2]) + +def p_casejobstatement_case_job_set(p): + '''casejobstatement : CASE JOB_SET THEN EOL | CASE JOB_SET EOL''' LOCAL_VARS.clear() LOCAL_VARS.update(FUNCTION_VARS) |