Exemplo n.º 1
0
int DoSet (Parser *p)
{
    Value v;
    int r;

    DynamicBuffer buf;
    DBufInit(&buf);

    r = ParseIdentifier(p, &buf);
    if (r) return r;

    /* Allow optional equals-sign:  SET var = value */
    if (ParseNonSpaceChar(p, &r, 1) == '=') {
	ParseNonSpaceChar(p, &r, 0);
    }

    r = EvaluateExpr(p, &v);
    if (r) {
	DBufFree(&buf);
	return r;
    }

    if (*DBufValue(&buf) == '$') r = SetSysVar(DBufValue(&buf)+1, &v);
    else r = SetVar(DBufValue(&buf), &v);
    DBufFree(&buf);
    return r;
}
Exemplo n.º 2
0
std::vector<std::string> ParametricAd::getISBStrings(){
	GLITE_STACK_TRY("ParametricAd::getISBStrings()");
	// This vector contains all ISB string Values
	vector<string> inputFiles ;
	ExprTree* isbTree = Lookup (JDL::INPUTSB);
	if (!isbTree){ /* No inputFiles found: return */ return inputFiles; }
	Value val ;
	string isb ;
	EvaluateExpr(isbTree,val);
	switch (val.GetType()){
		case Value::UNDEFINED_VALUE:
			// Single Undefined (expression) value
			break;
		case Value::STRING_VALUE:
			// ISB consists on a single (String) value
			val.IsStringValue(isb);
			inputFiles.push_back(isb);
			break;
		case Value::LIST_VALUE:{
			// ISB is a list of (possible) mixed (string&expresssion) values
			const ExprList *el;
			val.IsListValue(el);
			vector<ExprTree*> vectList;
			el->GetComponents(vectList);
			for ( unsigned int i = 0; i< vectList.size() ; i++){
				if (vectList[i]->GetKind()!=ExprTree::LITERAL_NODE){
					// not a literal node
				}else if (vectList[i]->Evaluate(val)){
					switch (val.GetType()){
						case Value::STRING_VALUE:
							val.IsStringValue( isb ) ;
							inputFiles.push_back (isb) ;
							break;
						case Value::UNDEFINED_VALUE:
							// It's an Expression evaluated
							break;
						default:
							throw AdMismatchException (__FILE__,__LINE__,
							METHOD,WMS_JDLMISMATCH , JDL::INPUTSB );
					}
				}
				val.Clear() ;
			}
		}
		break;
		default:
			throw AdMismatchException (__FILE__ , __LINE__ ,METHOD, WMS_JDLMISMATCH , JDL::INPUTSB );
			break;
	}
	return inputFiles ;
	GLITE_STACK_JDL_CATCH_ALL() ; //Exiting from method: remove line from stack trace
}
Exemplo n.º 3
0
void ParametricAd::checkInputSandbox(std::vector<std::string>& extracted){
	GLITE_STACK_TRY("ParametricAd::checkInputSandbox(std::vector<std::string>&)");
	// This vector contains all ISB string extracted Values
	unsigned int iter_i = extracted.size();
	// This Vector will replace the old InputSanbox with the extracted values
	vector<ExprTree*> isVect ;
	ExprTree* isbTree = Lookup (JDL::INPUTSB);
	if (!isbTree){ /* No inputFiles found: return */ return; }
	// These variables are needed when extracting
	const string wmpURI = (hasAttribute(JDL::WMPISB_BASE_URI))? (getString(JDL::WMPISB_BASE_URI)):"";
	const string isbURI=   (hasAttribute(JDL::ISB_BASE_URI))  ? (getString(JDL::ISB_BASE_URI)   ):"";
	Value val ;
	string isb ;
	EvaluateExpr(isbTree,val);
	inputRemotes.clear();
	switch ( val.GetType() ){
		case Value::UNDEFINED_VALUE:
			inputRemotes.push_back(isbTree->Copy());
			isVect.push_back(isbTree->Copy());
			break;
		case Value::STRING_VALUE:
			val.IsStringValue(isb);
			toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
				lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
			// put the extracted files back into the InputSandbox attribute
			for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
				val.SetStringValue(extracted[iter_i]);	// create classad Value
				isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
			}
			break;
		case Value::LIST_VALUE:{
			const ExprList *el;
			val.IsListValue( el );
			vector<ExprTree*> vectList ;
			el->GetComponents(vectList) ;
			for ( unsigned int i = 0; i< vectList.size() ; i++){
				if (vectList[i]->GetKind()!=ExprTree::LITERAL_NODE){
					// not a literal node
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				else if (vectList[i]->Evaluate(val)){
					switch (val.GetType()){
						case Value::STRING_VALUE:
							val.IsStringValue(isb);
							toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
								lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
							// put the extracted files back into the InputSandbox attribute
							for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
								val.SetStringValue(extracted[iter_i]);	// create classad Value
								isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
							}
							break;
						case Value::UNDEFINED_VALUE:
							// It's an Expression evaluated
							inputRemotes.push_back( vectList[i]->Copy() );
							isVect.push_back(vectList[i]->Copy());
							break;
						default:
							throw AdMismatchException (__FILE__,__LINE__,
							METHOD,WMS_JDLMISMATCH , JDL::INPUTSB );
					}
				}else{
					// It's an Expression not evaluated, leave it unchanged
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				val.Clear() ;
			}
		}
		break;
		default:
			throw AdMismatchException (__FILE__ , __LINE__ ,METHOD, WMS_JDLMISMATCH , JDL::INPUTSB );
			break;
	}
	classad:ExprTree* tmp_expr = ExprList::MakeExprList(isVect);
	Insert (JDL::INPUTSB , tmp_expr) ;
	GLITE_STACK_JDL_CATCH_ALL() ; //Exiting from method: remove line from stack trace
}
Exemplo n.º 4
0
bool wxLuaDebugTarget::HandleDebuggerCmd(int debugCommand)
{
    bool ret = false;

    switch ((int)debugCommand)
    {
        case wxLUASOCKET_DEBUGGER_CMD_NONE :
        {
            // This is an error, but maybe we can continue?
            ret = true;
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_ADD_BREAKPOINT:
        {
            wxString fileName;
            wxInt32  lineNumber = 0;

            if (m_clientSocket.ReadString(fileName) &&
                m_clientSocket.ReadInt32(lineNumber))
            {
                ret = AddBreakPoint(fileName, lineNumber);
            }
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_REMOVE_BREAKPOINT:
        {
            wxString fileName;
            wxInt32  lineNumber = 0;

            if (m_clientSocket.ReadString(fileName) &&
                m_clientSocket.ReadInt32(lineNumber))
            {
                ret = RemoveBreakPoint(fileName, lineNumber);
            }
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_CLEAR_ALL_BREAKPOINTS:
        {
            ret = ClearAllBreakPoints();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_RUN_BUFFER:
        {
            wxString fileName;
            wxString buffer;

            if (m_clientSocket.ReadString(fileName) &&
                m_clientSocket.ReadString(buffer))
            {
                ret = Run(fileName, buffer);
            }
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DEBUG_STEP:
        {
            ret = Step();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DEBUG_STEPOVER:
        {
            ret = StepOver();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DEBUG_STEPOUT:
        {
            ret = StepOut();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DEBUG_CONTINUE:
        {
            m_forceBreak = false;
            ret = Continue();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DEBUG_BREAK:
        {
            ret = Break();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_ENUMERATE_STACK:
        {
            ret = EnumerateStack();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_ENUMERATE_STACK_ENTRY:
        {
            wxInt32 stackRef = 0;

            if (m_clientSocket.ReadInt32(stackRef))
                ret = EnumerateStackEntry(stackRef);

            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_ENUMERATE_TABLE_REF:
        {
            wxInt32 tableRef = 0;
            wxInt32 index    = 0;
            long    itemNode = 0;

            if (m_clientSocket.ReadInt32(tableRef) &&
                m_clientSocket.ReadInt32(index) &&
                m_clientSocket.ReadLong(itemNode))
            {
                ret = EnumerateTable(tableRef, index, itemNode);
            }
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_RESET:
        {
            ret = Reset();
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_EVALUATE_EXPR:
        {
            wxInt32 exprRef = 0;
            wxString buffer;

            if (m_clientSocket.ReadInt32(exprRef) &&
                m_clientSocket.ReadString(buffer))
            {
                ret = EvaluateExpr(exprRef, buffer);
            }
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_CLEAR_DEBUG_REFERENCES:
        {
            size_t idx, idxMax = m_references.GetCount();
            for (idx = 0; idx < idxMax; ++idx)
            {
                int iItem = m_references.Item(idx);
                m_wxlState.wxluaR_Unref(iItem, &wxlua_lreg_debug_refs_key);
            }
            m_references.Clear();
            ret = true;
            break;
        }
        case wxLUASOCKET_DEBUGGER_CMD_DISABLE_BREAKPOINT: // FIXME do something here
            ret = true;
            break;
        case wxLUASOCKET_DEBUGGER_CMD_ENABLE_BREAKPOINT: // FIXME do something here
            ret = true;
            break;
        default :
            wxFAIL_MSG(wxT("Invalid wxLuaSocketDebuggerCommands_Type in wxLuaDebugTarget::ThreadFunction"));
    }

    return ret;
}