Exemplo n.º 1
0
 public override void MakeByteCode(bool leaveOnStack, ArrayList bytecodeList)
 {
     SymbolInfo si = SymbolTable.LookupExisting(Token);
     if (si is ConSymbolInfo)
     {
         if (!leaveOnStack)
             throw new ParseException("Internal error: IdExpr.MakeByteCode(false) ConSymbolInfo", this.Token);
         ConSymbolInfo csi = si as ConSymbolInfo;
         MakePushInt(csi.Value.AsIntBits(), bytecodeList);
         return;
     }
     StackOp op = StackOp.PUSH;
     if (si is LocalSymbolInfo)
     {
         if (!leaveOnStack)
             throw new ParseException("Internal error: IdExpr.MakeByteCode(false) LocalSymbolInfo", this.Token);
         LocalSymbolInfo lsi = si as LocalSymbolInfo;
         MakeStackOp(op, 4, MemorySpace.LOCAL, lsi.Offset, null, bytecodeList);
         size = 4;
     }
     else if (si is VarSymbolInfo)
     {
         if (!leaveOnStack)
             throw new ParseException("Internal error: IdExpr.MakeByteCode(false) VarSymbolInfo", this.Token);
         VarSymbolInfo vsi = si as VarSymbolInfo;
         MakeStackOp(op, vsi.Size, MemorySpace.VAR, vsi.Offset, null, bytecodeList);
         size = vsi.Size;
     }
     else if (si is DatSymbolInfo)
     {
         if (!leaveOnStack)
             throw new ParseException("Internal error: IdExpr.MakeByteCode(false) DatSymbolInfo", this.Token);
         DatSymbolInfo dsi = si as DatSymbolInfo;
         MakeStackOp(op, dsi.Alignment, MemorySpace.OBJ, dsi.Dp, null, bytecodeList);
         size = dsi.Alignment;
     }
     else if (si is MethodSymbolInfo)
     {
         CallExpr call = new CallExpr(null, this.Token, null, new ArrayList());
         call.MakeByteCode(leaveOnStack, bytecodeList);
     }
     else if (si is ObjSymbolInfo)
     {
         ObjSymbolInfo osi = si as ObjSymbolInfo;
         if (!leaveOnStack)
             throw new ParseException("IdExpr.MakeByteCode(false) ObjSymbolInfo", Token);
         // Get the entry out of the current object table, then add current object's
         // address to the LSW and the current object's VAR address (lshifted 16) to
         // the MSW. That'll make both addresses absolute.
         MakeStackOp(StackOp.PUSH, 4, MemorySpace.OBJ, osi.Index << 2, null, bytecodeList);
         MakePushInt(this.SymbolTable.HubAddress, bytecodeList);
         bytecodeList.Add((byte)0xec);		// ADD
         bytecodeList.Add((byte)0x43);		// PUSH# VAR+0
         bytecodeList.Add((byte)0x37);		// PUSH#kp
         bytecodeList.Add((byte)0x03);		//         16
         bytecodeList.Add((byte)0xe3);		// SHL
         bytecodeList.Add((byte)0xec);		// ADD
     }
     else
         throw new ParseException("Unexpected " + si.ToString(), this.Token);	// should never happen.
 }
Exemplo n.º 2
0
 public override Expr Nud()
 {
     Expr e = ParseExpression(Tokenizer, 0);
     if (e is CallExpr)
     {
         CallExpr ce = e as CallExpr;
         ce.AbortTrap = true;
         return ce;
     }
     if (e is IdExpr)
     {
         IdExpr ie = e as IdExpr;
         CallExpr ce = new CallExpr(null, ie.Token, null, new ArrayList());
         ce.AbortTrap = true;
         return ce;
     }
     throw new ParseException("Expected method call", this);
 }
Exemplo n.º 3
0
 public void Visit(CallExpr e)
 {
     throw new ParseException("Call not allowed in constant expression", e.Token);
 }