// ExSampleTcb constructor
//
// 1. Allocate buffer pool.
// 2. Allocate parent queues and initialize private state.
// 3. Fixup expressions.
//
ExSampleTcb::ExSampleTcb
(const ExSampleTdb &  myTdb, 
 const ex_tcb &    child_tcb,
 ex_globals * glob
 ) : 
  ex_tcb(myTdb, 1, glob)
{
  Space * space = (glob ? glob->getSpace() : 0);
  CollHeap * heap = (glob ? glob->getDefaultHeap() : 0);
  
  childTcb_ = &child_tcb;

   // get the queue that child use to communicate with me
  qchild_  = child_tcb.getParentQueue(); 

  // Allocate the queue to communicate with parent
  qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE,
							myTdb.queueSizeDown_,
				     myTdb.criDescDown_,
				     space);
  
  // Allocate the private state in each entry of the down queue
  ExSamplePrivateState *p 
    = new(space) ExSamplePrivateState(this);
  qparent_.down->allocatePstate(p, this);
  delete p;


  qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE,
				    myTdb.queueSizeUp_,
				    myTdb.criDescUp_,
				    space);

  // Intialized processedInputs_ to the next request to process
  processedInputs_ = qparent_.down->getTailIndex();

  // Fixup the sample expression
  //
  if (initExpr())
    initExpr()->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob);

  if (balanceExpr())
    balanceExpr()->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob);

  if (postPred())
    postPred()->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob);
}
Beispiel #2
0
bool parserCls::exprStmt(void )
{bool bb1 ;initExpr();bb1 = exprssion() ;
 if(bb1)
 { initEiwCss(ExprInstr);addExprToStmt(0);
   initEiwCss(ExprInstr);bb1=endWhiteLine();
 }
 if(!bb1) initEiwCss( ErrorInstr );
 return bb1 ;
}
Beispiel #3
0
bool parserCls::returnStmt(void)
{initExpr();getToken();bool bb1=exprssion();
 if(bb1){
	if(noTokenInExpr){addExprToStmt(0);initEiwCss(ReturnInstr);}
	else   initEiwCss(ReturnOnlyInstr);
	bb1=endWhiteLine();
 }
 if(!bb1)  initEiwCss(ErrorInstr) ;
 return bb1 ;
}
Beispiel #4
0
/*
 * Makes a super (keyword) node. 
 */
AstNode *
makeSuper(unsigned int line)
{
  Expr *p;

  p = t_malloc(memory, sizeof(Expr));
  initAstNode(NODE(p), SUPER_NODE, line);
  initExpr(EXPR(p));

  return NODE(p);
}
Beispiel #5
0
/*
 * Makes a this (keyword) node. 
 */
AstNode *
makeThis(unsigned int line)
{
  Expr *p;

  p = t_malloc(memory, sizeof(Expr));
  initAstNode(NODE(p), THIS_NODE, line);
  initExpr(EXPR(p));

  return NODE(p);
}
Beispiel #6
0
/*
 * Creates a null literal node. 
 */
AstNode *
makeNullLit(unsigned int line)
{
  Expr *p;

  p = t_malloc(memory, sizeof(Expr));
  initAstNode(NODE(p), NULLLIT_NODE, line);
  initExpr(EXPR(p));

  return NODE(p);
}
Beispiel #7
0
/*
 * Makes an expression identifier node. 
 */
AstNode *
makeExprId(Literal * name)
{
  ExprId *p;

  p = t_malloc(memory, sizeof(ExprId));
  initAstNode(NODE(p), EXPRID_NODE, name->line);
  initExpr(EXPR(p));

  p->name = name->str;

  return NODE(p);
}
Beispiel #8
0
/*
 * Creates an integer literal node with the given value. 
 */
AstNode *
makeIntLit(Literal * value)
{
  IntLit *p;

  p = t_malloc(memory, sizeof(IntLit));
  initAstNode(NODE(p), INTLIT_NODE, value->line);
  initExpr(EXPR(p));

  p->str = value->str;

  return NODE(p);
}
Beispiel #9
0
AstNode *
makeDeref(Type * type, AstNode * next, unsigned int line)
{
  Deref *p;

  p = t_malloc(memory, sizeof(Deref));
  initAstNode(NODE(p), DEREF_NODE, line);
  initExpr(EXPR(p));

  p->super.type = type;
  p->next = next;

  return NODE(p);
}
Beispiel #10
0
/*
 * Makes a unary operation expression of the given type. 
 */
AstNode *
makeUnaryOp(OpType op, AstNode * left, unsigned int line)
{
  UnaryOp *p;

  p = t_malloc(memory, sizeof(UnaryOp));
  initAstNode(NODE(p), UNARYOP_NODE, line);
  initExpr(EXPR(p));

  p->op = op;
  p->left = left;

  return NODE(p);
}
Beispiel #11
0
/*
 * Makes an array access node. 
 */
AstNode *
makeArrayAccess(AstNode * name, AstNode * dexp, unsigned int line)
{
  ArrayAccess *p;

  p = t_malloc(memory, sizeof(ArrayAccess));
  initAstNode(NODE(p), ARRAYACCESS_NODE, line);
  initExpr(EXPR(p));

  p->name = name;
  p->dexp = dexp;

  return NODE(p);
}
Beispiel #12
0
/*
 * Makes a cast expression node. 
 */
AstNode *
makeCast(AstNode * type, AstNode * expr, unsigned int line)
{
  Cast *p;

  p = t_malloc(memory, sizeof(Cast));
  initAstNode(NODE(p), CAST_NODE, line);
  initExpr(EXPR(p));

  p->type = type;
  p->expr = expr;

  return NODE(p);
}
Beispiel #13
0
/*
 * Makes a Field Access node. 
 */
AstNode *
makeFieldAccess(AstNode * target, AstNode * ident, unsigned int line)
{
  FieldAccess *p;

  p = t_malloc(memory, sizeof(FieldAccess));
  initAstNode(NODE(p), FIELDACCESS_NODE, line);
  initExpr(EXPR(p));

  p->target = target;
  assert(ident->type == NAMEID_NODE);
  p->name = ((NameId *) ident)->name;

  return NODE(p);
}
Beispiel #14
0
/*
 * Makes a class instance creation node. 
 */
AstNode *
makeClassCreate(AstNode * type, AstNode * args, unsigned int line)
{
  ClassCreate *p;

  p = t_malloc(memory, sizeof(ClassCreate));
  initAstNode(NODE(p), CLASSCREATE_NODE, line);
  initExpr(EXPR(p));

  p->type = type;
  p->args = args;
	p->cons = NULL;

  return NODE(p);
}
Beispiel #15
0
/*
 * Makes a constructor invocation node. 
 */
AstNode *
makeConstInvoc(AstNode * target, AstNode * args, unsigned int line)
{
  ConstInvoc *p;

  p = t_malloc(memory, sizeof(ConstInvoc));
  initAstNode(NODE(p), CONSTINVOC_NODE, line);
  initExpr(EXPR(p));

  p->target = target;
  p->args = args;
  p->cons = NULL;

  return NODE(p);
}
Beispiel #16
0
/*
 * Makes a binary operation node with the given operation. 
 */
AstNode *
makeBinaryOp(OpType op, AstNode * left, AstNode * right, unsigned int line)
{
  BinaryOp *p;

  p = t_malloc(memory, sizeof(BinaryOp));
  initAstNode(NODE(p), BINARYOP_NODE, line);
  initExpr(EXPR(p));

  p->op = op;
  p->left = left;
  p->right = right;

  return NODE(p);
}
Beispiel #17
0
/*
 * Makes an array creation expression node. 
 */
AstNode *
makeArrayCreate(AstNode * type, AstNode * expr, unsigned int dims,
                unsigned int line)
{
  ArrayCreate *p;

  p = t_malloc(memory, sizeof(ArrayCreate));
  initAstNode(NODE(p), ARRAYCREATE_NODE, line);
  initExpr(EXPR(p));

  p->type = type;
  p->expr = expr;
  p->dims = dims;

  return NODE(p);
}
Beispiel #18
0
/*
 * Makes a formal parameter node. 
 */
AstNode *
makeFormalParam(AstNode * type, AstNode * decl, unsigned int line)
{
  FormalParam *p;

  p = t_malloc(memory, sizeof(FormalParam));
  initAstNode(NODE(p), FORMALPARAM_NODE, line);
  initExpr(EXPR(p));

  p->type = type;
  p->decl = decl;
  p->num = 0;
  p->name = NULL;

  return NODE(p);
}
Beispiel #19
0
/*
 * Makes a method invocation node. 
 */
AstNode *
makeMethodInvoc(AstNode * target, AstNode * ident, AstNode * args,
                unsigned int line)
{
  MethodInvoc *p;

  p = t_malloc(memory, sizeof(MethodInvoc));
  initAstNode(NODE(p), METHODINVOC_NODE, line);
  initExpr(EXPR(p));

  p->target = target;
  assert(ident->type == NAMEID_NODE);
  p->name = ((NameId *) ident)->name;
  p->args = args;
	p->method_type = NULL;

  return NODE(p);
}
Beispiel #20
0
bool parserCls::exprShould(EinstructionWord t1 )
{tokenContainCls tcs1= getCurToken();initExpr();getToken();
 bool bb1=exprssion();
 if(bb1)if(!noTokenInExpr){exprShouldError(tcs1,t1);bb1=false;}
 return bb1 ;
}