public void LocalVars(VarList v) { StringBuilder sb = new StringBuilder(MyC.MAXSTR); sb.Append("\t.locals ("); int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number String stype = ""; switch (e.getTypeId()) { case Tok.T_CHAR: stype = "char"; break; case Tok.T_SHORT: stype = "int16"; break; case Tok.T_INT: case Tok.T_LONG: stype = "int32"; break; case Tok.T_FLOAT: stype = "float"; break; case Tok.T_DOUBLE: stype = "double float"; break; default: Console.WriteLine("?Could not find type for local\n"); Environment.Exit(1); break; } sb.Append(stype); // append it now if (i < max-1) sb.Append(","); // if not last, seperate with comma } sb.Append(")\r\n"); io.Out(sb.ToString()); }
/* * Emit the local declarations */ public void LocalVars(VarList v) { NextInsn(0); localvars = v; icur.setIType(IAsm.I_LOCALDEF); }
VarList paramList() { VarList v; tok.scan(); if (tok.getFirstChar() != '(') io.Abort("Expected '('"); v = new VarList(); /* init the param list */ tok.scan(); /* get the next token */ while (tok.getFirstChar() != ')') { Var e = new Var(); e.setClassId(Tok.T_PARAM); /* mark this as a parameter */ dataType(e); /* get the specified datatype */ e.setName(tok.getValue()); /* copy the variable name */ v.add(e); /* add parameter to param list */ tok.scan(); if (tok.getFirstChar() == ',') /* if more params */ tok.scan(); /* get the next token */ } tok.scan(); /* move to the next token */ return v; }
void declFunc(Var e) { #if DEBUG Console.WriteLine("declFunc token=["+tok+"]\n"); #endif CommentHolder(); // start new comment e.setName(tok.getValue()); /* value is the function name */ if (e.getName().Equals("main")) { if (Io.gendll) io.Abort("Using main entrypoint when generating a DLL"); mainseen = true; } staticvar.add(e); /* add function name to static VarList */ paramvar = paramList(); // track current param list e.setParams(paramvar); // and set it in func var localvar = new VarList(); // track new local parameters CommentFillPreTok(); emit.FuncBegin(e); if (tok.getFirstChar() != '{') io.Abort("Expected '{'"); blockOuter(null, null); emit.FuncEnd(); emit.IL(); if (Io.genlist) emit.LIST(); emit.Finish(); }
public Parse(Io i, Tok t) { io = i; tok = t; staticvar = new VarList(); // init the static variables list }
public void LocalVars(VarList v) { int max = v.Length(); for (int i = 0; i < max; i++) // loop thru the local params { Var e = v.FindByIndex(i); // indexed by number Type et = genDataTypeSig(e); // LocalToken t = emethod.DeclareLocal(et); LocalBuilder t = il.DeclareLocal(et); if (Io.gendebug) t.SetLocalSymInfo(e.getName()); e.setLocalToken(t); } localsdone = true; }
public void setParams(VarList p) { methodparams = p; }