/// <summary> Resolve the object into a variable by various means and /// using the current context. /// </summary> /// <returns> variable, or <code>null</code> /// </returns> internal virtual Variable resolveToVariable(Object o) { Variable v = null; // if o is a variable already, then we're done! if (o is Variable) return (Variable) o; // Resolve the name to something { // not an id so try as name String name = o.ToString(); long id = nameAsId(name); /* * if #N was used just pick up the variable, otherwise * we need to use the current context to resolve * the name to a member */ if (id != Value.UNKNOWN_ID) { // TODO what here? } else { // try to resolve as a member of current context (will set context if null) id = determineContext(name); v = locateForNamed((int) id, name, true); if (v != null) v = new VariableFacade(v, id); else if (v == null && m_createIfMissing && name[0] != '$') { v = new VariableFacade(id, name); } } } return v; }
/* * Resolve the object into a variable by various means and * using the current context. */ internal virtual Value resolveToValue(Object o) { Value v = null; // if o is a variable or a value already, then we're done! if (o is Value) return (Value) o; else if (o is Variable) return ((Variable) o).getValue(); { // not an id so try as name String name = o.ToString(); long id = nameAsId(name); /* * if #N was used just pick up the variable, otherwise * we need to use the current context to resolve * the name to a member */ if (id != Value.UNKNOWN_ID) { v = Session.getValue((int) id); } else { // TODO what here? } } return v; }
// assign the object o, the value v; returns Boolean true if worked, false if failed public virtual Object assign(Object o, Object v) { bool worked = false; try { Variable var = resolveToVariable(o); if (var == null) throw new NoSuchVariableException((java.lang.Object)m_current); // set the value, for the case of a variable that does not exist it will not have a type // so we try to glean one from v. int type = determineType(var, v); FaultEvent faultEvent = var.setValue(Session, type, v.ToString()); if (faultEvent != null) throw new PlayerFaultException(faultEvent); worked = true; } catch (PlayerDebugException) { worked = false; } return worked; }