void term(){ if(look == '*'){ match("*"); term(); emitln("xor ebx, ebx"); settype(reduceptr(current_type)); STRSWITCH(current_type) STRCASE("short") emitln("mov bx, word [eax]"); STRCASE("char") emitln("mov bl, byte [eax]"); STRDEFAULT emitln("mov ebx, dword [eax]"); STRSWITCHEND emitln("xchg eax, ebx"); } else if(look == '('){ match("("); emitln("push eax"); expression(); match(")"); } else if(look == '"'){ emitln("mov eax, %s", add_string(getstring('"'))); current_type = "char*"; } else if(look == '\''){ match("'"); emitln("mov eax, %d", look); getcharacter(); match("'"); current_type = "char"; } else if(is_in(dynstring("%c", look), "+", "-", NULL)){ emitln("push dword 0"); operator(); } else if(isalpha(look)){ identifier(); } else if(isdigit(look)){ emitln("mov eax, %s", getnumber()); } else expected("Number or variable"); }
void identifier(){ char* name = getname(); if(!idexists(name)) error("Identifier '%s' is undeclared", name); if(look == '('){ if(!isfunction(name)) error("Cannot call variable '%s'", name); int len = 0; match("("); while(look != ')'){ expression(); emitln("push eax"); if(look != ')') match(","); len++; } match(")"); if(len != numargs(name)) error("Call to %s with wrong number of args", name); emitln("call %s", getaccessor(name)); } else { emitln("xor eax, eax"); current_type = gettype(name); STRSWITCH(current_type) STRCASE("char") emitln("mov al, byte [%s]", getaccessor(name)); STRCASE("short") emitln("mov ax, word [%s]", getaccessor(name)); STRDEFAULT emitln("mov eax, dword [%s]", getaccessor(name)); STRSWITCHEND } }
void operator(){ char op = look; emitln("pop ebx"); match(dynstring("%c", op)); if(op == '['){ char* type = reduceptr(current_type); emitln("push ebx"); expression(); match("]"); emitln("pop ebx"); STRSWITCH(type) STRCASE("char") STRCASE("short") emitln("shl eax, 1"); STRDEFAULT emitln("shl eax, 2"); STRSWITCHEND emitln("add eax, ebx"); emitln("xchg eax, ebx"); emitln("xor eax, eax"); STRSWITCH(current_type) STRCASE("int") emitln("mov eax, dword [ebx]"); STRCASE("short") emitln("mov ax, word [ebx]"); STRCASE("char") emitln("mov al, byte [ebx]"); STRDEFAULT //error("Invalid type '%s'", current_type); emitln("mov eax, dword [ebx]"); STRSWITCHEND }
void RMRequest::requestError(QNetworkReply::NetworkError error) { #define STRCASE(CASE) \ case QNetworkReply:: CASE : str = # CASE ; break; QString str; switch(error) { STRCASE(NoError); STRCASE(ConnectionRefusedError); STRCASE(RemoteHostClosedError); STRCASE(HostNotFoundError); STRCASE(TimeoutError); STRCASE(OperationCanceledError); STRCASE(SslHandshakeFailedError); STRCASE(TemporaryNetworkFailureError); STRCASE(UnknownNetworkError); // proxy errors (101-199): STRCASE(ProxyConnectionRefusedError); STRCASE(ProxyConnectionClosedError); STRCASE(ProxyNotFoundError); STRCASE(ProxyTimeoutError); STRCASE(ProxyAuthenticationRequiredError); STRCASE(UnknownProxyError); // content errors (201-299): STRCASE(ContentAccessDenied); STRCASE(ContentOperationNotPermittedError); STRCASE(ContentNotFoundError); STRCASE(AuthenticationRequiredError); STRCASE(ContentReSendError); STRCASE(UnknownContentError); // protocol errors STRCASE(ProtocolUnknownError); STRCASE(ProtocolInvalidOperationError); STRCASE(ProtocolFailure); STRCASE(NetworkSessionFailedError); STRCASE(BackgroundRequestNotAllowedError); } if (str.isEmpty()) qDebug() << "Unknown Network Request error: " << error; else qDebug() << "Network Request error: (" << error << ") - " << str; }