/* analyzing all arguments of the function call */ void analyze_args(Exprs args, char* procName, char* callee, int paramNum) { Expr first = args->first; Exprs rest = args->rest; if(first && getParamType(callee, paramNum)!=-1) { analyze_expr(first, procName); analyze_arg(first, callee, paramNum, procName); } else if(first && getParamType(callee, paramNum)==-1) { printf("function call %s has more number of parameter.\n", callee); errorNum++; return; } if(rest == 0 && getParamType(callee, paramNum+1)!=-1) { printf("function call %s has less number of parameter.\n", callee); errorNum++; } if(rest) analyze_args(rest, procName, callee, paramNum+1); }
void TColorStyle::assignBlend(const TColorStyle &a, const TColorStyle &b, double t) { // Blend colors { int col, colCount = getColorParamCount(); assert(a.getColorParamCount() == colCount && b.getColorParamCount() == colCount); for (col = 0; col != colCount; ++col) setColorParamValue( col, blend(a.getColorParamValue(col), b.getColorParamValue(col), t)); } // Blend parameters { int par, parCount = getParamCount(); assert(a.getParamCount() == parCount && b.getParamCount() == parCount); for (par = 0; par != parCount; ++par) { switch (getParamType(par)) { case DOUBLE: setParamValue(par, (1 - t) * a.getParamValue(double_tag(), par) + t * b.getParamValue(double_tag(), par)); break; default: break; } } } invalidateIcon(); }
std::string OfxhParamAccessor::getParamTypeName() const { static const std::string ofxPrefix = "OfxParamType"; const std::string& type = getParamType(); BOOST_ASSERT(type.size() > ofxPrefix.size()); return type.substr(ofxPrefix.size()); }
/* generate code from function call arguments*/ int print_arg(Expr expr, int reg, char* proc_id, int paramNum,char* callee) { int curr_reg = reg; int next_reg; int ID_type; int ID_type2; switch (expr->kind) { Type ID_type; int stackNo; case EXPR_ID: ID_type = getType(proc_id,expr->id); stackNo = getStackSlotNum(proc_id, expr->id); if(isParamRef(callee,paramNum)==0){ printf("load r%d, %d\n", curr_reg,stackNo); } if(isParamRef(callee,paramNum)==1){ if(isRef(proc_id, expr->id)==1) printf("load r%d, %d\n", curr_reg,stackNo); else printf("load_address r%d, %d\n", curr_reg,stackNo); } break; case EXPR_CONST: print_constant(expr->constant, curr_reg); break; case EXPR_BINOP: ID_type = getExprType(expr->e1, proc_id); ID_type2 = getExprType(expr->e2, proc_id); curr_reg = print_expr(expr->e1, curr_reg, proc_id); next_reg = print_expr(expr->e2, curr_reg + 1, proc_id); print_binop_string(expr->binop, curr_reg, next_reg, ID_type, ID_type2); break; case EXPR_RELOP: ID_type = getExprType(expr->e1, proc_id); ID_type2 = getExprType(expr->e2, proc_id); curr_reg = print_expr(expr->e1, curr_reg, proc_id); next_reg = print_expr(expr->e2, curr_reg + 1, proc_id); print_relop_string(expr->relop, curr_reg, next_reg, ID_type, ID_type2); break; case EXPR_UNOP: ID_type = getExprType(expr->e1, proc_id); print_unop_string(expr->unop, curr_reg, ID_type); break; } if(getExprType(expr,proc_id) != getParamType(callee,paramNum)){ //printf("%d,%d ",getExprType(expr), getParamType(callee,paramNum)); printf("int_to_real r%d, r%d\n", curr_reg,curr_reg); } return curr_reg; }
// Возвращает текущее значение параметра. int16_t LocalParams::getValue() const { int16_t v = val; if (getParamType() == Param::PARAM_BITES) { uint8_t cur = getNumOfCurrSameParam() - 1; uint8_t bite = cur % 8; v = ((val & (1 << bite)) != 0) ? 1 : 0; } return v; }
/* analyzing each argument of the function call check the arguments number and type with the defination of the callee */ void analyze_arg(Expr arg, char* callee, int paramNum, char* procName) { if(isParamRef(callee, paramNum)==1) { // ref parameters if (arg->kind != EXPR_ID&& arg->kind!=EXPR_ARRAY) { printf("ref parameter is not a scaler.\n"); errorNum++; } if((getParamType(callee, paramNum) != getExprType(arg, procName)) && (getArrayType(getParamType(callee, paramNum)) != getExprType(arg, procName))) { printf("No.%d parameter of function call %s has wrong type.\n", paramNum+1, callee); errorNum++; } } else if(isParamRef(callee, paramNum)==0) { // val parameters if((getParamType(callee, paramNum) != getExprType(arg, procName)) && (getArrayType(getParamType(callee, paramNum)) != getExprType(arg, procName))) { if(getParamType(callee, paramNum) == FLOAT_TYPE && (getExprType(arg, procName) == INT_TYPE || getExprType(arg, procName) == INT_ARRAY_TYPE)) {} else { printf("No.%d parameter of function call %s has wrong type.\n", paramNum+1, callee); errorNum++; } } } }
static tZGBool getParam(tZGU8 index) { tZGU8 paramType; paramType = getParamType(ARGV[index]); switch (paramType) { case kZGUnknownParam: sprintf( (char *) g_ConsoleContext.txBuf, "Param %d invalid", index); ZG_PUTSUART( (char *) g_ConsoleContext.txBuf ); return kZGBoolFalse; case kZGNetmaskParam: gLineParseState = kZGWaitingForNetmaskValue; return kZGBoolTrue; #ifdef ZG_CONFIG_DHCP case kZGDHCPParam: gLineParseState = kZGWaitingForDHCP; return kZGBoolTrue; #endif case kZGGatewayParam: gLineParseState = kZGWaitingForGateway; return kZGBoolTrue; case kZGArpParam: case kZGMinusArpParam: case kZGDownParam: case kZGUpParam: sprintf( (char *) g_ConsoleContext.txBuf, "Param %d not supported", index); ZG_PUTSUART( (char *) g_ConsoleContext.txBuf ); return kZGBoolFalse; default: sprintf( (char *) g_ConsoleContext.txBuf, "Param %d not handled", index); ZG_PUTSUART( (char *) g_ConsoleContext.txBuf ); return kZGBoolFalse; } return kZGBoolTrue; }
/***************************************************************************** * FUNCTION: getParam * * RETURNS: None * * PARAMS: tokenIndex -- index of token in the command line * * NOTES: *****************************************************************************/ static tZGBool getParam(tZGU8 tokenIndex) { tZGU8 paramType; // Parse the token and return it's corresponding paramType id paramType = getParamType(ARGV[tokenIndex]); // set the state of the line parsing state machine based on the parameter type. // Either need to wait for a value or go on to the next parameter switch (paramType) { case kZGUnknownParam: sprintf( (char *) g_ConsoleContext.txBuf, "Param %d invalid", tokenIndex); ZG_PUTSUART( (char *) g_ConsoleContext.txBuf ); return kZGBoolFalse; case kZGWpaPskParam: gLineParseState = kZGWaitingForWpaPsk; break; case kZGWpaStrParam: gLineParseState = kZGWaitingForWpaStr; break; case kZGEncTypeParam: gLineParseState = kZGWaitingForEnc; break; case kZGWepAuthParam: gLineParseState = kZGWaitingForWepAuth; break; case kZGWepKeyParam: gLineParseState = kZGWaitingForWepKey; break; case kZGBeaconParam: gLineParseState = kZGWaitingForBeacon; break; default: sprintf( (char *) g_ConsoleContext.txBuf, "Param %d not handled", tokenIndex); return kZGBoolFalse; } return kZGBoolTrue; }
bool TColorStyle::operator==(const TColorStyle &cs) const { if (getTagId() != cs.getTagId()) return false; if (getMainColor() != cs.getMainColor()) return false; int paramCount = getParamCount(); if (paramCount != cs.getParamCount()) return false; int colorParamCount = getColorParamCount(); if (colorParamCount != cs.getColorParamCount()) return false; if (m_name != cs.getName()) return false; if (m_originalName != cs.getOriginalName()) return false; if (m_globalName != cs.getGlobalName()) return false; if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false; if (m_pickedPosition != cs.getPickedPosition()) return false; if (m_flags != cs.getFlags()) return false; for (int p = 0; p < colorParamCount; ++p) if (getColorParamValue(p) != cs.getColorParamValue(p)) return false; for (int p = 0; p < paramCount; ++p) { switch (getParamType(p)) { case BOOL: if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p)) return false; break; case INT: case ENUM: if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p)) return false; break; case DOUBLE: if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p)) return false; break; case FILEPATH: if (getParamValue(TFilePath_tag(), p) != cs.getParamValue(TFilePath_tag(), p)) return false; break; default: assert(false); } } return true; }
// Возвращает максимальное значение параметра. int16_t LocalParams::getMax() const { uint16_t max = 0; switch(getDependMax()) { case Param::DEPEND_MAX_NO: max = pgm_read_word(&getPtrParam()->max); break; case Param::DEPEND_MAX_ON_NUM_DEVS: max = numDevices; break; case Param::DEPEND_MAX_ON_COM_PRD: max = numComPrd; } // для строковых параметров в максимуме записано макс.количество элементов // списка, поэтому скорректируем максимальное значение Param::PARAM_TYPE type = getParamType(); if ((type == Param::PARAM_LIST) || (type == Param::PARAM_BITES)) { max = getMin() + max - 1; } return max; }
/***************************************************************************** * FUNCTION: do_iwpriv_cmd * * RETURNS: None * * PARAMS: None * * NOTES: Responds to the user invoking ifconfig *****************************************************************************/ tZGVoidReturn do_iwpriv_cmd(tZGVoidInput) { tZGU8 i; tZGU8 temp; tZGBool cont_parse; tZGS8* ptrString; gLineParseState = kZGWaitingForParamKeyword; // if user only typed in iwpriv with no other parameters if (ARGC == 1u) { IwprivDisplayStatus(); } // else loop through each parameter else { // parse each param and set state variables for (i = 1; i < ARGC; ++i) { switch (gLineParseState) { case kZGWaitingForParamKeyword: if ( !getParam(i) ) { return; } break; case kZGWaitingForWpaPsk: /* Can only set security in idle state */ if ( ZG_IS_CONNECTED() == kZGBoolTrue ) { ZG_PUTRSUART("Security context may only be set in idle state\n\r"); return; } /* The ARGV buffer is modified in place */ if ( !ExtractandValidateWpaPSK( ARGV[i] ) ) { ZG_PUTRSUART("WPA PSK must be exactly 64 bytes\n\r"); return; } ZG_SET_WPAPSK( (tZGU8Ptr) ARGV[i] ); gLineParseState = kZGWaitingForParamKeyword; break; case kZGWaitingForWpaStr: /* Can only set security in idle state */ if ( ZG_IS_CONNECTED() == kZGBoolTrue ) { ZG_PUTRSUART("Security context may only be set in idle state\n\r"); return; } ptrString = ARGV[i++]; /* if the start char is found, gobble that char */ if ( (cont_parse = ExtractWpaStrStart(ptrString)) == kZGBoolTrue) { ptrString++; } /* this code concats tokens together with whitespace */ /* until no more tokens or the EOS " char is found */ while ( cont_parse && (i++ < ARGC)) { cont_parse = ExtractWpaStrEnd( ptrString ); } /* if the EOS char is not found then cont parse is true */ if (cont_parse) { ZG_PUTRSUART("Passphrase missing EOS '\"' \n\r"); return; } /* temp contains the string length after call */ if ( !ValidateWpaStr(&ptrString, &temp) ) { ZG_PUTRSUART("Passphrase must be between 8 and 63 chars\n\r"); return; } ZG_SET_WPA_PASSPHRASE( ptrString, temp ); gLineParseState = kZGWaitingForParamKeyword; break; case kZGWaitingForEnc: /* Can only set security in idle state */ if ( ZG_IS_CONNECTED() == kZGBoolTrue ) { ZG_PUTRSUART("Security context may only be set in idle state\n\r"); return; } /* temp contains the encryption type enum */ if ( !ExtractandValidateEncType(ARGV[i], &temp) ) { ZG_PUTRSUART("Invalid encyption type\n\r"); return; } ZG_SET_ENC_TYPE( temp ); gLineParseState = kZGWaitingForParamKeyword; break; case kZGWaitingForWepAuth: /* Can only set security in idle state */ if ( ZG_IS_CONNECTED() == kZGBoolTrue ) { ZG_PUTRSUART("Security context may only be set in idle state\n\r"); return; } /* temp contains the Wep Auth type enum */ if ( !ExtractandValidateAuthType(ARGV[i], &temp) ) { ZG_PUTRSUART("Invalid WEP Auth type\n\r"); return; } ZG_SET_AUTH_TYPE( temp ); gLineParseState = kZGWaitingForParamKeyword; break; case kZGWaitingForWepKey: /* Can only set security in idle state */ if ( ZG_IS_CONNECTED() == kZGBoolTrue ) { ZG_PUTRSUART("Security context may only be set in idle state\n\r"); return; } /* temp contains the active WEP key index 1 of 4 */ if ( !ExtractandValidateWepIndex(ARGV[i], &temp) ) { ZG_PUTRSUART("Invalid WEP key index\n\r"); return; } /* check for a 3rd optional parameter */ if ( (i+1 < ARGC) && (getParamType(ARGV[i+1]) == kZGUnknownParam) ) { i++; /* advance to the optional param */ /* The ARGV buffer is modified in place */ if ( ExtractandValidateWepLong( ARGV[i] ) ) { ZG_SET_WEP_KEY_LONG( (tZGU8Ptr) ARGV[i], temp ); } else if ( ExtractandValidateWepShort( ARGV[i] ) ) { ZG_SET_WEP_KEY_SHORT( (tZGU8Ptr) ARGV[i], temp ); } else { ZG_PUTRSUART("\n\rWarning, 64/128bit WEP key format not valid \n\r\t"); return; } } ZG_SET_WEP_ACTIVE_INDEX(temp); gLineParseState = kZGWaitingForParamKeyword; break; default: ZGSYS_MODULE_ASSERT(2, (ROM FAR char*)"iwpriv param"); break; } // end switch } // end for } switch (gLineParseState) { case kZGWaitingForBeacon: // Send an untampered frame that looks like a Beacon. iwpriv_beacon(); gLineParseState = kZGWaitingForParamKeyword; break; default: //do nothing break; } if (gLineParseState != (tZGU8)kZGWaitingForParamKeyword) { ZG_PUTRSUART("Missing value after last parameter\n\r"); } }