static int read_line(void) { const char** p; int matches; if (!ibuf_getstr(&inbuf, &last_line.line, LF)) { exitasap = exitoneof || seq_next == seq_send; if (!ibuf_eof(&inbuf)) error1sys("Could not read line from stdin"); stdin_eof = 1; return 0; } --last_line.line.len; /* Strip off the trailing LF */ if (patterns != 0) { matches = 1; for (p = patterns; *p != 0; ++p) { if (str_matchs(&last_line.line, (*p)+1)) matches = **p == '+'; } if (!matches) return 0; } gettimestamp(&last_line.timestamp); SET_SEQ(last_line.seq = seq_next++); if (last_line.line.len > MAX_LINE) { str_rcut(&last_line.line, last_line.line.len - MAX_LINE); memcpy(last_line.line.s + MAX_LINE - 17, "[...truncated...]", 17); } buffer->push(&last_line); return 1; }
TVP recordR1() { /* types R1 :: a : int b : seq of char c : bool; operations public recordR1: ()==>bool recordR1()==( dcl r : R1 := mk_R1(0,"ab",false); let r2 = r, mk_R1(-,-,b)=r in return r2.c or true or b; ); */ //dcl r : R1 := mk_R1(0,"ab",false); TVP r = mk_R1(); // RECORD_FIELD_ACCESS(r,struct R1*,a,tmp1); // 0 TVP tmp1 = newInt(0); RECORD_FIELD_SET(r,RECORD_R1,a,tmp1); vdmFree(tmp1); TVP tmp2 = newSeq(2); TVP tmp2_1 = newChar('a'); SET_SEQ(tmp2,1,tmp2_1); vdmFree(tmp2_1); TVP tmp2_2 = newChar('b'); SET_SEQ(tmp2,2,tmp2_2); vdmFree(tmp2_2); RECORD_FIELD_SET(r,RECORD_R1,b,tmp2); vdmFree(tmp2); TVP tmp3 = newBool(false); RECORD_FIELD_SET(r,RECORD_R1,c,tmp3); vdmFree(tmp3); //let r2 = r; TVP r2 = vdmClone(r); // mk_R1(-,-,b)=r TVP tmp4 = mk_R1(); patternMatchBind(tmp4,r); RECORD_FIELD_ACCESS(tmp4,RECORD_R1,c,b); // in // return r2.c or true or b; RECORD_FIELD_ACCESS(r2,RECORD_R1,c,tmp5); TVP tmp6 = newBool(true); TVP tmp7 =newBool( tmp5->value.boolVal || tmp6->value.boolVal || b->value.boolVal); TVP res = vdmClone(tmp7); vdmFree(tmp7); vdmFree(tmp6); vdmFree(tmp5); vdmFree(tmp4); return res; }