add() public method

public add ( Var e ) : void
e Var
return void
        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 addOuter(Var e)
        {
#if DEBUG
            Console.WriteLine("addOuter e=[" + e + "]\n");
#endif

            /*
             * validate this declaration as a potential variable
             */
            if (e.getClassId() == Tok.T_AUTO)
            {
                io.Abort("?Cannot allocate automatic variable outside a function\n");
            }
            if (staticvar.FindByName(e.getName()) != null)
            {
                io.Abort("?Cannot redefine static name '" + e.getName() + "'\n");
            }
            staticvar.add(e);
        }
        void addInner(Var e)
        {
            /*
             * validate this declaration as a potential variable
             */
            int id = e.getClassId();

#if DEBUG
            Console.WriteLine("addInner e=[" + e + "]\n");
#endif
            if (id == Tok.T_EXTERN || id == Tok.T_STATIC)
            {
                io.Abort("Cannot allocate static within a method\n");
            }
            if (paramvar.FindByName(e.getName()) != null) /* cannot redefine param name */
            {
                io.Abort("Cannot redefine parameter name '" + e.getName() + "'\n");
            }
            if (localvar.FindByName(e.getName()) != null) /* check not already set */
            {
                io.Abort("Local variable '" + e.getName() + "' already defined\n");
            }
            localvar.add(e);
        }
Example #4
0
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;
  }