int ident() { int Typecast = Tok.TOK_VOID; if (io.getNextChar() == '(') { io.Message(tok + "[Ident]"); Var e = call_construct(tok.getValue()); Typecast = e.getTypeId(); if (Typecast == Tok.TOK_VOID) { io.Abort("PL0147: using void function where expecting a value"); } emit.Call(e); tok.scan(); } else { if (currenttree.FindByName(tok.getValue()) == null) { io.Abort("PL0105: undeclared variable"); } Typecast = currenttree.FindByName(tok.getValue()).getTypeId(); emit.Load(currenttree.FindByName(tok.getValue())); io.Message(tok + "[Ident]"); tok.scan(); } return(Typecast); }
void ret_stmt(String ilabel, String olabel) { int gotType = Tok.TOK_VOID; if (ilabel == null) { io.Abort("PL0128: illegal RETURN to nowhere"); } io.Message(tok + "[RETURN]"); tok.scan(); if (tok.getId() != Tok.TOK_1_SEMI) { gotType = bool_expr(0); Var e = tree.FindByName(ilabel); if (e != null) { typeCheckAssign(gotType, e.getTypeId()); } if (tok.getFirstChar() != ';') { io.Abort("PL0129: ';' expected"); } } emit.Ret(); }
private String genDataTypeSig(Var e) { if (e == null) { return(null); } StringBuilder sb = new StringBuilder(Io.MAXSTR); if (e.getSign() == Tok.T_UNSIGNED) { sb.Append("unsigned "); } sb.Append(ilSType(e.getTypeId())); return(sb.ToString()); }
/* * common routine to construct a signature string for a given varlist item * requires a destination ptr, will return the updated dest ptr */ private Type genDataTypeSig(Var e) { bool sign = true; if (e == null) { return(null); } if (e.getSign() == Tok.T_UNSIGNED) /* if var is unsigned, put it in sig */ { sign = false; } Type sig = ilSType(sign, e.getTypeId()); /* get the datatype */ return(sig); }
private string genFieldRef(Var e) { if (e == null) { return(null); } StringBuilder sb = new StringBuilder(Io.MAXSTR); if (e.getSign() == Tok.T_UNSIGNED) { sb.Append("unsigned "); } sb.Append(ilSType(e.getTypeId())); sb.Append(" "); sb.Append("Class" + io.GetClassname()); sb.Append("."); sb.Append(e.getName()); return(sb.ToString()); }
void call_stmt(VarList curtree) { io.Message(tok + "[CALL]"); tok.scan(); if (tok.getId() != Tok.TOK_IDENT) { io.Abort("PL0131: ident after CALL expected"); } io.Message(tok + "[Ident]"); Var e = call_construct(tok.getValue()); emit.Call(e); if (e.getTypeId() != Tok.TOK_VOID) { emit.Insn("pop"); } tok.scan(); }
public void LocalVars(VarList v) { StringBuilder sb = new StringBuilder(Io.MAXSTR); sb.Append("\t.locals ("); int max = v.Length(); for (int i = 0; i < max; i++) { Var e = v.FindByIndex(i); String stype = ""; switch (e.getTypeId()) { case Tok.TOK_FIXED: stype = "int32"; break; case Tok.TOK_FLOAT: stype = "float32"; break; case Tok.TOK_COMPLEX: stype = "float64"; break; case Tok.TOK_REAL: stype = "float32"; break; case Tok.TOK_BINARY: stype = "int16"; break; case Tok.TOK_DECIMAL: stype = "int32"; break; default: io.Abort("PL0406: could not find type for local"); break; } sb.Append(stype); if (i < max - 1) { sb.Append(","); } } sb.Append(")\r\n"); io.Out(sb.ToString()); }
public void mergeNodes(VarList p) { int i; for (i = 0; i < p.Length(); i++) { Var varSrc = p.FindByIndex(i); Var varTrg = FindByName(varSrc.getName()); if ((varTrg != null) && (varTrg.getType() != Var.VAR_PARAM)) { add(varSrc); } else if (varTrg == null) { add(varSrc); } else { FindByName(varSrc.getName()).setTypeId(varSrc.getTypeId()); FindByName(varSrc.getName()).setGranularity(varSrc.getGranularity()); } } }
private string genFieldRef(Var e) { if (e == null) return null; StringBuilder sb = new StringBuilder(Io.MAXSTR); if (e.getSign() == Tok.T_UNSIGNED) sb.Append("unsigned "); sb.Append(ilSType(e.getTypeId())); sb.Append(" "); sb.Append("Class" + io.GetClassname()); sb.Append("."); sb.Append(e.getName()); return (sb.ToString()); }
private String genDataTypeSig(Var e) { if (e == null) return null; StringBuilder sb = new StringBuilder(Io.MAXSTR); if (e.getSign() == Tok.T_UNSIGNED) sb.Append("unsigned "); sb.Append(ilSType(e.getTypeId())); return (sb.ToString()); }
/* common routine to construct a signature string for a given varlist item requires a destination ptr, will return the updated dest ptr */ private Type genDataTypeSig(Var e) { bool sign = true; if (e == null) return null; if (e.getSign() == Tok.T_UNSIGNED) /* if var is unsigned, put it in sig */ sign = false; Type sig = ilSType(sign, e.getTypeId()); /* get the datatype */ return (sig); }