本文整理汇总了C#中KacTalk.ktList.IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.IsEmpty方法的具体用法?C# ktList.IsEmpty怎么用?C# ktList.IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktList
的用法示例。
在下文中一共展示了ktList.IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
/// <summary>
/// Add values to the integer (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to add to the integer</param>
/// <returns>The sum of all the arguments and the internal integer</returns>
public ktValue Add(ktList Arguments)
{
ktValue Value = ktValue.Null;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't add nothing (null) to an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Try to convert the argument to an int and add it to the internal integer
m_value += GetAsInt((ktValue)L.Node.Value);
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktInt", this, m_HardType, true);
// ... and return it
return Value;
}
示例2: Assign
/// <summary>
/// Assign a value to the float
/// </summary>
/// <param name="Arguments">The value to assign</param>
/// <returns>ktValue with the current object</returns>
public ktValue Assign(ktList Arguments)
{
ktValue Value = ktValue.Null;
// Can't assign nothing..
if ((Arguments.IsEmpty()) || ((ktValue)Arguments.First.Node.Value).IsNull())
{
throw new ktError("Can't assign nothing (null) to a float!", ktERR.NOTDEF);
}
// Store the first value given as argument (ignore the rest)
m_value = GetAsFloat((ktValue)Arguments.First.Node.Value);
// Return this object wrapped in a ktValue
return new ktValue(this.Name, "ktFloat", this, m_HardType, false);
}
示例3: Multiply
/// <summary>
/// Multiply values with the integer (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to multiply with the integer</param>
/// <returns>The product of all the arguments and the internal integer</returns>
public ktValue Multiply(ktList Arguments)
{
ktValue Value = ktValue.Null;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't multiply nothing (null) with an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Multiply with the current argument
m_value *= GetAsInt((ktValue)L.Node.Value);
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktInt", this, m_HardType, true);
// ... and return it
return Value;
}
示例4: FromBase
/// <summary>
/// Convert from one base to decimal
/// </summary>
/// <param name="Arguments">A list of arguments (Arg1: The value to convert, Arg2: The base to convert from)</param>
/// <returns></returns>
public ktValue FromBase(ktList Arguments)
{
ktValue Arg = ktValue.Null;
string val = "";
int frombase = 2;
// Did we get any arguments?
if (Arguments.IsEmpty())
{
throw new ktError("Not enough arguments for ktInt::FromBase()!", ktERR.NOTDEF);
}
// Did we get enough arguments?
else if (Arguments.Count < 2)
{
throw new ktError("Not enough arguments for ktInt::FromBase(), expected 2!", ktERR.NOTDEF);
}
// Get the first value and convert it to a string
Arg = (ktValue)Arguments.First.Node.Value;
val = Arg.ToString();
// Get the second value and convert it to a string
Arg = (ktValue)Arguments.First.Next.Node.Value;
frombase = Arg.ToInt();
// Convert
return _FromBase(val, frombase);
}
示例5: MapArguments
protected bool MapArguments(ktList Arguments)
{
if (((Arguments == null) || Arguments.IsEmpty()) &&
((m_Arguments == null) || m_Arguments.IsEmpty()))
{
return true;
}
else if ((m_Arguments == null) || m_Arguments.IsEmpty())
{
return true;
}
ktString Name = new ktString();
ktString RestName = null;
ktList Rest = null, CurrArgL = null;
ktValue Arg = null, CurrArg = null, Arg2Add = null;
//bool GoOn = true;
CurrArgL = Arguments.First;
m_Arguments.Reset();
foreach (ktList AL in m_Arguments)
{
Arg2Add = null;
/*if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null)) {
Arg2Add = ktValue.Null;
}*/
if ((AL == null) || (AL.Node == null) || (AL.Node.Value == null))
{
ktDebug.Log("NA");
// ????????????????????????????????????????????????????????????
Arg2Add = ktValue.Null;
}
else
{
Arg = (ktValue)AL.Node.Value;
Name = Arg.Name;
if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null))
{
ktDebug.Log("NULL");
if (Arg.Value != null)
{
Arg2Add = new ktValue(Name, Arg.Type, Arg.Value, Arg.HardType, Arg.Constant);
}
else
{
Arg2Add = new ktValue(Name, "null", null, true, true);
}
AddVariable(Arg2Add);
continue;
}
CurrArg = (ktValue)CurrArgL.Node.Value;
if (Name[0] == '#')
{
Name.RemoveFirst();
Arg2Add = new ktValue(Name, "ktList", Arguments, true, false);
}
else if (Name[0] == '$')
{
Name.RemoveFirst();
RestName = Name;
Rest = new ktList();
while (CurrArgL != null)
{
Arg2Add = new ktValue(CurrArg);
if (CurrArgL != null)
{
CurrArgL = CurrArgL.Next;
if ((CurrArgL == null) || (CurrArgL.Node == null) ||
(CurrArgL.Node.Value == null))
{
continue;
}
else
{
CurrArg = (ktValue)CurrArgL.Node.Value;
}
}
}
}
else
{
if ((Arg.HardType) && (!Arg.CheckType(CurrArg)))
{
throw new ktError("ktFunction::MapArguments() : Didn't get a value with the right type for the argument '" +
Name + "' in the function " +
m_Name + "!", ktERR.WRONGTYPE);
}
Arg2Add = new ktValue(CurrArg);
}
}
//.........这里部分代码省略.........
示例6: _Multiply
/// <summary>
/// Multiply values with the integer (doesn't change the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to multiply with the integer</param>
/// <returns>The product of all the arguments and the internal integer</returns>
public ktValue _Multiply(ktList Arguments)
{
ktValue Value = ktValue.Null;
int res = m_value;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't multiply nothing (null) to an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Multiply with the current argument
res *= GetAsInt((ktValue)L.Node.Value);
}
// Create a new ktInt and wrap it in a ktValue
Value = new ktValue("return", "ktInt", new ktInt(res), true, true);
return Value;
}
示例7: _ExclusiveOr
/// <summary>
/// Calculate the value of the integer XOR with the power of the arguments (doesn't change the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to XOR the integer with</param>
public ktValue _ExclusiveOr(ktList Arguments)
{
ktValue Value = ktValue.Null;
int res = m_value;
int a = 1;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't divide an integer with nothing (null)!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Get the argument as an integer
a = GetAsInt((ktValue)L.Node.Value);
// Perform an XOR-operation
res ^= a;
}
// Create a new ktInt and wrap it in a ktValue
Value = new ktValue("return", "ktInt", new ktInt(res), false, true);
return Value;
}
示例8: _Add
/// <summary>
/// Add values to the integer (doesn't change the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to add to the integer</param>
/// <returns>The sum of all the arguments and the internal integer</returns>
public ktValue _Add(ktList Arguments)
{
ktValue Value = ktValue.Null;
int res = 0;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't add nothing (null) to an integer!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Try to convert the argument to an int and add it to the sum
res += GetAsInt((ktValue)L.Node.Value);
}
// Add the current sum to the internal integer, create a new ktInt and wrap it in a ktValue
Value = new ktValue("return", "ktInt", new ktInt(m_value + res), true, true);
// Return the result
return Value;
}
示例9: Power
/// <summary>
/// Calculate the value of the float raised to the power of the arguments (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to raise the float with</param>
/// <returns>The value of the internal float to the power of the arguments</returns>
public ktValue Power(ktList Arguments)
{
ktValue Value = ktValue.Null;
float a = 1;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't raise a float with nothing (null)!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Get the argument as an float
a = GetAsFloat((ktValue)L.Node.Value);
// Raise it to the power of the argument
m_value = (int)Math.Pow((double)m_value, (double)a);
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktFloat", this, m_HardType, true);
// ... and return it
return Value;
}
示例10: Modulus
/// <summary>
/// Calculate the modulus of the float and the arguments (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to multiply with the float</param>
/// <returns>The product of all the arguments and the internal float</returns>
public ktValue Modulus(ktList Arguments)
{
ktValue Value = ktValue.Null;
ktValue Arg = ktValue.Null;
float a = 1;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't divide a float with nothing (null)!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Get the argument as an float
a = GetAsFloat((ktValue)L.Node.Value);
// Do modulus with the current argument
m_value %= a;
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktFloat", this, m_HardType, true);
// ... and return it
return Value;
}
示例11: Divide
/// <summary>
/// Divide values with the float (changes the value of the object)
/// </summary>
/// <param name="Arguments">A list of values to divide the float with</param>
/// <returns>The quotient of all the arguments and the internal float</returns>
public ktValue Divide(ktList Arguments)
{
ktValue Value = ktValue.Null;
ktValue Arg = ktValue.Null;
float a = 1;
// Check so we actually got some arguments
if (Arguments.IsEmpty())
{
throw new ktError("Can't divide an float with nothing (null)!", ktERR.NOTDEF);
}
// Go through the list of arguments
foreach (ktList L in Arguments)
{
// If there's nothing in this argument
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
// Get the argument as an float
a = GetAsFloat((ktValue)L.Node.Value);
// Check so it isn't zero
if (a == 0)
{
// Oops, can't do that!!!
throw new ktError("You can't divide by zero!", ktERR.DIV_BY_ZERO);
}
// Divide with the current argument
m_value /= a;
}
// Wrap this object in a ktValue ...
Value = new ktValue("return", "ktFloat", this, m_HardType, true);
// ... and return it
return Value;
}
示例12: Round
/// <summary>
/// Round the float
/// </summary>
/// <param name="Arguments"></param>
/// <returns></returns>
private ktValue Round(ktList Arguments)
{
ktValue Value = ktValue.Null;
float res = m_value;
int precision = 0;
// Check if we got some arguments
if (!Arguments.IsEmpty())
{
ktValue arg = (ktValue)Arguments.FirstNode.Value;
if (!arg.IsNull())
{
//ktClass obj = (ktClass)arg.Value;
if (arg.Type == "ktInt")
{
precision = arg.ToInt();
}
else
{
throw new ktError("ktFloat::Round() expected an integer as argument but got a '" + arg.Type + "'!", ktERR.WRONGTYPE);
}
}
}
res = (float)Math.Round(res, precision);
// Create a new ktFloat and wrap it in a ktValue
Value = new ktValue("return", "ktFloat", new ktFloat(res), true, true);
return Value;
}
示例13: HandleRunStatement
protected ktValue HandleRunStatement(ktList Statement)
{
#if Debug
ktDebug.Log( "HrSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRS" );
#endif
ktValue Value = ktValue.Null;
if ((Statement == null) || (Statement.IsEmpty()))
{
return Value;
}
#if Debug
ktDebug.Log( Statement.Get_R() );
#endif
ktRunStatement RunStatement = new ktRunStatement(Statement, this);
Value = RunStatement.AsValue();
#if Debug
ktDebug.Log( "EOHRS" );
#endif
return Value;
}
示例14: HandleStatement
protected ktValue HandleStatement(ktList Statement)
{
#if Debug
ktDebug.Log( "HSHSHSHSHSHSHSHSHSHSHSHSHSHSHS" );
#endif
ktValue Value = ktValue.Null;
ktDebug.Log(Statement.Get_R());
if ((Statement == null) || (Statement.IsEmpty()) ||
(Statement.First.Node == null) || (Statement.First.Node.Value == null))
{
ktDebug.Log(Statement.Get_R());
return Value;
}
#if Debug
ktDebug.Log( Statement.Get_R() );
#endif
ktToken Token = (ktToken)Statement.First.Node.Value;
Value = TokenToValue(Token, Statement.First);
#if Debug
ktDebug.Log( "EOHS" );
#endif
return Value;
}
示例15: Add
private ktValue Add(ktList Arguments)
{
ktValue Value = ktValue.Null;
ktValue Arg = ktValue.Null;
float res = 0.0f;
if (Arguments.IsEmpty())
{
throw new ktError("Can't add nothing (null) to a float!", ktERR.NOTDEF);
}
foreach (ktList L in Arguments)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
Arg = (ktValue)L.Node.Value;
res += Arg.ToFloat();
}
Value = new ktValue("return", "ktDouble", new ktDouble(m_value + res), false, true);
return Value;
}