getTypeId() public method

public getTypeId ( ) : int
return int
Exemplo n.º 1
0
/* parse a return */
        void fcReturn()
        {
            Var e = emit.GetFunc();

            CommentHolder();               /* mark the position in insn stream */
            tok.scan();                    /* get the return value */
            if (tok.getFirstChar() == ';') /* if end of statment */
            {
                if (e.getTypeId() != Tok.T_VOID)
                {
                    io.Abort("Expected value for return type");
                }
            }
            else
            {
                if (e.getTypeId() == Tok.T_VOID)
                {
                    io.Abort("Unexpected value for void return type");
                }
                boolExpr(); /* parse as expression */
            }
            emit.Ret();     /* issue the return (value is on stack) */
            CommentFill();
            tok.scan();     /* move past the semi */
        }
Exemplo n.º 2
0
  /*
   * common routine to construct a signature string for a given varlist item
   * requires a destination ptr, will return the updated dest ptr
   */
  private String genDataTypeSig(Var e)
    {
    if (e == null)
      return null;

    StringBuilder sb = new StringBuilder(MyC.MAXSTR);

    if (e.getSign() == Tok.T_UNSIGNED)	/* if var is unsigned, put it in sig */
      sb.Append("unsigned ");

    sb.Append(ilSType(e.getTypeId()));	/* get the datatype */
    return (sb.ToString());
    }
Exemplo n.º 3
0
  private String genFieldRef(Var e)
    {
    if (e == null)
      return null;

    StringBuilder sb = new StringBuilder(MyC.MAXSTR);

    if (e.getSign() == Tok.T_UNSIGNED)	/* if var is unsigned, put it in sig */
      sb.Append("unsigned ");

    sb.Append(ilSType(e.getTypeId()));	/* get the datatype */
    sb.Append(" ");
    sb.Append(Io.GetClassname());	/* get the current classname */
    sb.Append(".");
    sb.Append(e.getName());	/* copy the variable name */
    return (sb.ToString());
    }
Exemplo n.º 4
0
Arquivo: asm.cs Projeto: ydunk/masters
        /*
         * common routine to construct a signature string for a given varlist item
         * requires a destination ptr, will return the updated dest ptr
         */
        private String genDataTypeSig(Var e)
        {
            if (e == null)
            {
                return(null);
            }

            StringBuilder sb = new StringBuilder(MyC.MAXSTR);

            if (e.getSign() == Tok.T_UNSIGNED) /* if var is unsigned, put it in sig */
            {
                sb.Append("unsigned ");
            }

            sb.Append(ilSType(e.getTypeId())); /* get the datatype */
            return(sb.ToString());
        }
Exemplo n.º 5
0
/*
 * 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);
        }
Exemplo n.º 6
0
Arquivo: asm.cs Projeto: ydunk/masters
        private String genFieldRef(Var e)
        {
            if (e == null)
            {
                return(null);
            }

            StringBuilder sb = new StringBuilder(MyC.MAXSTR);

            if (e.getSign() == Tok.T_UNSIGNED) /* if var is unsigned, put it in sig */
            {
                sb.Append("unsigned ");
            }

            sb.Append(ilSType(e.getTypeId())); /* get the datatype */
            sb.Append(" ");
            sb.Append(Io.GetClassname());      /* get the current classname */
            sb.Append(".");
            sb.Append(e.getName());            /* copy the variable name */
            return(sb.ToString());
        }
Exemplo n.º 7
0
Arquivo: asm.cs Projeto: ydunk/masters
        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());
        }
Exemplo n.º 8
0
/*
 * parse the outerBlock seperately from inner block.
 * specifically parse the declarations at the beginning of an outerblock
 * the variable r tracks if the last statement was a return or not
 */
        void blockOuter(String olabel, String ilabel)
        {
            bool r = false;

#if DEBUG
            Console.WriteLine("blockOuter1 token=[" + tok + "]\n");
#endif
            CommentToken(); /* mark the position in insn stream */
            tok.scan();
#if DEBUG
            Console.WriteLine("blockOuter2 token=[" + tok + "]\n");
#endif
            declInner();
            emit.LocalVars(localvar);

            while (tok.getFirstChar() != '}')
            {
#if DEBUG
                Console.WriteLine("blockOuter3 token=[" + tok + "]\n");
#endif
                if (io.EOF())
                {
                    io.Abort("Expected statement, end of file encountered");
                }
                r = false;
                switch (tok.getId())
                {
                case Tok.T_IF: fcIf(olabel, ilabel); continue; /* fcIf updates tok */

                case Tok.T_WHILE: fcWhile(); break;

                case Tok.T_FOR: fcFor(); break;

                case Tok.T_BREAK: fcBreak(olabel); break;

                case Tok.T_CONTINUE: fcContinue(ilabel); break;

                case Tok.T_RETURN: fcReturn(); r = true; break;

                default: statement(); break;
                }
#if DEBUG
                Console.WriteLine("blockOuter4 token=[" + tok + "]\n");
#endif
            }
            if (!r)                                  /* if no outerscope return specified, try to default */
            {
                Var e = emit.GetFunc();              /* get function def */
                if (e.getTypeId() != Tok.T_VOID)     /* make sure we can default to void */
                {
                    if (!e.getName().Equals("main")) /* is it not main? */
                    {
                        io.Abort("No return value specified for non void function");
                    }
                    emit.LoadConst("0"); /* special case a dummy ret value */
                }
                emit.Ret();
            }
            CommentToken(); /* mark the position in insn stream */
            tok.scan();     /* read beyond end of block */
#if DEBUG
            Console.WriteLine("blockOuter5 token=[" + tok + "]\n");
#endif
        }
Exemplo n.º 9
0
/*
 * 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);
  }