本文整理汇总了C#中KacTalk.ktList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.Add方法的具体用法?C# ktList.Add怎么用?C# ktList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktList
的用法示例。
在下文中一共展示了ktList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ktDelegateFunction
public ktDelegateFunction(ktString Name, ktFunction_Double_Delegate Delegate)
: base(Name, null, null, ktValue.Null)
{
m_Arguments = new ktList();
m_Arguments.Add(new ktValue("D", "double",
kacTalk.Main.GetClass("double"),
true, true));
m_Delegate = delegate(ktList Args)
{
if ((Args == null) || (Args.FirstNode == null) ||
(Args.FirstNode.Value == null))
{
throw new ktError("Didn't get an argument for '" +
Name + "'!", ktERR.MISSING);
}
//ktDebug.Log( "ktDF::DOUBLE(" +Args.FirstNode.Value.ToString() + ")" );
ktString S_In = new ktString(Args.FirstNode.Value.ToString());
double D_In = 0.0;
double D_Out = 0.0;
try
{
if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator == ",")
{
S_In.Replace(".", ",", true);
}
D_In = S_In.ToDouble();
}
catch (Exception E)
{
if (E.GetType() == typeof(System.FormatException) && !S_In.IsEmpty())
{
throw new ktError("ktDouble::CreateObject: Cant make '" + S_In + "' into an double", ktERR.WRONGTYPE);
}
}
ktDebug.Log("D_In: " + D_In.ToString());
D_Out = Delegate(D_In);
ktDebug.Log("D_Out: " + D_Out.ToString());
return new ktValue("return", "double",
kacTalk.Main.MakeObjectOf("double", D_Out),
true, true);
};
}
示例2: Split
public ktList Split(ktString Input, int Count)
{
// If we have a pattern?!
if ((m_Pattern.IsEmpty()) || (m_P == null))
{
// Set error (throw exeption??) and return false
throw new ktError("ktRegExp::Split(): The pattern is not set!", ktERR.NOTSET);
}
ktList Parts = new ktList();
string[] OrgParts = m_P.Split(Input, Count);
foreach (string Part in OrgParts)
{
Parts.Add(new ktString(Part));
}
return Parts;
}
示例3: GetMethods
public override ktList GetMethods()
{
ktList List = new ktList();
List.Add("Export", CreateObject("0"));
return List;
}
示例4: MakeATree
/// <summary>
/// Parse the tokens and create a tree /*(mainly for operators)**/
/// </summary>
protected ktList MakeATree(ktList List, bool FirstRun, bool ThirdRun)
{
//ktDebug.Log( "MAT!" + List.Get_R( "\t", true ));
ktList Tree = new ktList(), Prev = null, Next = null, Temp = null, Temp2 = null;
ktToken Token = null, PrevToken = null;
/*/ If the list are the "root"
if (List == m_LineStack) {
Tree.Node = new ktNode( "ktTBlock", new ktToken( ktTokenType.Block, "", 0, 0 ) );
} else/**/
{
Tree.Node = List.Node;
}
List.Reset();
foreach (ktList L in List)
{
//ktDebug.Log( "\nLLL: "+ List.Get_R() /*+ " :" +L.Export() */);
if ((L.Node != null) && (L.Node.Value != null))
{
Token = (ktToken)L.Node.Value;
Prev = Tree.Last;
if ((Prev != null) && (Prev.Node != null) && (Prev.Node.Value != null))
{
PrevToken = (ktToken)Prev.Node.Value;
}
else
{
PrevToken = new ktToken(ktTokenType.NULLTOKEN, ":null", 0, 0);
}
}
else
{
continue;
}
//#if ParseDebug
ktDebug.Log( "TT:" + Token.Type.ToString() + "(" + Token.Value + ")" );
ktDebug.Log( "PTT:" + PrevToken.Type.ToString() + "(" + PrevToken.Value + ")" );
//#endif
if ((FirstRun) && (
((PrevToken.Type == ktTokenType.Const) || (PrevToken.Type == ktTokenType.Hard)) ||
((Token.Type == ktTokenType.Const) || (Token.Type == ktTokenType.Hard)) ||
((PrevToken.Type == ktTokenType.VarStatement) && (
(Token.Type != ktTokenType.AssignmentOperator)/* ||
(Token.Type != ktTokenType.)*/
)
)))
{
//ktDebug.Log( "CONSTCONSTCONSTCONSTCONSTCONSTCONSTCONSTCONST" );
if (PrevToken.Type == ktTokenType.VarStatement)
{
if ((Token.Type != ktTokenType.Id) && (Token.Type != ktTokenType.Hard) &&
(Token.Type != ktTokenType.Const))
{
throw new ktError("Unexpected " + Token.Name + " on line " + Token.LineNo.ToString() +
" by character " + Token.CharPos.ToString() + "!", ktERR.UNEXP);
}
Prev.Add(Token);
}
else
{
Temp = new ktList();
Temp.Node = new ktNode("ktTVarStatement", new ktToken(ktTokenType.VarStatement, "", Token.LineNo, Token.CharPos));
Temp.Add(Token);
// Temp.AddList( MakeATree( L, FirstRun ) );
Tree.AddList(Temp);
}
}
else if (
(
((PrevToken.Type == ktTokenType.Id) && (ThirdRun)) ||
((/*!*/FirstRun) && (
(PrevToken.Type == ktTokenType.CompStatement) &&
(
(PrevToken.Value == ".") ||
(PrevToken.Value == "::")
)
)
)) && (
(Token.Type == ktTokenType.List) ||
(Token.Type == ktTokenType.Statement) ||
// (Token.Type == ktTokenType.CompStatement) ||
(Token.Type == ktTokenType.Const) ||
(Token.Type == ktTokenType.Hard) ||
(Token.Type == ktTokenType.String) ||
(Token.Type == ktTokenType.Boolean) ||
(Token.Type == ktTokenType.Number) ||
(Token.Type == ktTokenType.Float) ||
(Token.Type == ktTokenType.Null) ||
(Token.Type == ktTokenType.Id) // ?? Not shure on how this actually will work!?
))
{
ktDebug.Log("Tree:" + Tree.Get_R());
Tree.Pop(false);
/* ktDebug.Log("TToxen:" + Token.ToString());
//.........这里部分代码省略.........
示例5: GetArguments
public ktList GetArguments(ktList Arguments)
{
ktList Args = null;
ktToken Token = null;
#if Debug
ktDebug.Log( "GAGAGAGAGAGA:" + Arguments.Get_R( "\t", true ) );
#endif
if (Arguments == null)
{
return null;
}
else if ((Arguments.Node != null) && (Arguments.Node.Value != null) &&
((Token = (ktToken)(Arguments.Node.Value)).Type == ktTokenType.CompStatement))
{
Args = new ktList();
Args.Add(HandleCompound(Arguments).CopyValue());
return Args;
}
else if (((Arguments.First != null) && (Arguments.First.Node != null) &&
(Arguments.First.Node.Value != null) &&
((Token = (ktToken)(Arguments.First.Node.Value)).Type == ktTokenType.CompStatement)
) || ((Arguments.Node != null) && (Arguments.Node.Value != null) &&
((Token = (ktToken)(Arguments.Node.Value)).Type == ktTokenType.CompStatement)
)
)
{
#if Debug
ktDebug.Log( "GACSGACSGACSGACSGACSGACS:" + Arguments.Get_R() );
#endif
ktList Stat = new ktList();
Stat.Node = new ktNode("ktStatement", new ktToken(ktTokenType.Statement, "ktStatement",
Token.LineNo, Token.CharPos));
Args = new ktList();
Args.Node = new ktNode("ktList", new ktToken(ktTokenType.List, "ktList", Token.LineNo,
Token.CharPos));
Args.AddList(Stat);
Stat.AddList(Arguments);
return GetArguments(Args);
}
#if Debug
ktDebug.Log( "gQAGAGAGAGAGAGAGGAgA::::" + Arguments.Get_R( "\t", true ) );
#endif
if (Arguments.GetCount() == 0)
{
if (Arguments.Node == null)
{
return null;
}
Token = (ktToken)Arguments.Node.Value;
//ktDebug.Log( "GAGA111:" + Token.Name );
Args = new ktList();
if (Token.Type == ktTokenType.RunStatement)
{
Args.Add(TokenToValue(Token, null));
}
else
{
Args.Add(TokenToValue(Token, null).CopyValue());
}
}
else
{
ktValue Value = null;
Arguments.Reset();
foreach (ktList L in Arguments)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
if (Args == null)
{
Args = new ktList();
}
Token = (ktToken)L.Node.Value;
if (Token.Type == ktTokenType.RunStatement)
{
Value = TokenToValue(Token, L);
}
else
{
Value = TokenToValue(Token, L).CopyValue();
}
if (Value != null)
{
Args.Add(Value);
//.........这里部分代码省略.........
示例6: GetMethods
public virtual ktList GetMethods()
{
ktList Methods = new ktList();
if (m_Methods == null)
{
return Methods;
}
m_Methods.Reset();
foreach (ktList ML in m_Methods)
{
if ((ML.Node == null) || (ML.Node.Value == null))
{
continue;
}
Methods.Add(ML.Node.Name, ((ktFunction)ML.Node.Value).Return);
}
Methods.Add("Export", CreateObject());
return Methods;
}
示例7: CopyTo
public void CopyTo(ktList List)
{
foreach (ktRE_Group G in this)
{
List.Add(G);
}
}
示例8: HandleAssignment
protected ktValue HandleAssignment(ktToken Operator, ktList ListTarget, ktToken Target, ktValue AssValue)
{
ktValue Value = ktValue.Null;
ktClass Class = null;
ktList Args = null;
AssValue.HardType = false;
#if Debug
ktDebug.Log( "ASSSVALUE:" + Value.Export() + ";" );
#endif
try
{
if (Target.Type == ktTokenType.Id)
{
Value = GetVariable(Target.Value);
}
else if (Target.Type == ktTokenType.CompStatement)
{
Value = HandleCompound(ListTarget);
#if Debug
ktDebug.Log( "ASCP:" + Value.Export() + ";" );
#endif
}
}
catch (ktError Err)
{
if ((Err.ErrorNumber == ktERR.NOTFOUND) || (Err.ErrorNumber == ktERR.NOTDEF))
{
if (Operator.Value == "=")
{
SetVariable(Target.Value, true, AssValue, true, true);
return AssValue;
}
else
{
throw new ktError("You can't use a complex assignment operator (" +
Operator.Value + ") when creating a variable!",
ktERR.UNEXP);
}
}
else
{
throw Err;
}
}
//ktDebug.Log("HARD:" + Value.HardType);
if (Value.Constant)
{
throw new ktError("You are trying to assign a value to " + Target.Value +
", which is a constant!", ktERR.CONST);
}
else if (Value.IsNull())
{
SetVariable(Target.Value, true, AssValue, true, true);
return AssValue;
}/*
else if (!Value.HardType)
{
SetVariable(Target.Value, Value = AssValue, true, true);
}*/
try
{
Class = (ktClass)Value.Value;
Args = new ktList();
Args.Add(AssValue);
ArrayList MethNames = new ArrayList(4);
MethNames.Add("operator" + Operator.Value);
MethNames.Add("op" + Operator.Value);
switch (Operator.Value)
{
case "=":
{
MethNames.Add("_assign");
break;
}
case "+=":
{
MethNames.Add("_append");
break;
}
}
foreach (ktString Meth in MethNames)
{
try
{
Value.SetTheValue(Class.RunMethod(Meth, Args));
#if Debug
ktDebug.Log( "AFTREEEEOP:" + Value.Export() + ";" );
#endif
return Value;
}
catch (ktError Err)
{
// ktDebug.Log("ASSMETHERR:" + Err.ToString());
//.........这里部分代码省略.........
示例9: ktRE_GroupCollection
public ktRE_GroupCollection(ktRE_GroupCollection GC)
: this()
{
m_List = new ktList();
foreach (ktRE_Group G in GC)
{
m_List.Add(G);
}
}
示例10: ktRE_CaptureCollection
public ktRE_CaptureCollection(ktRE_CaptureCollection GC)
: this()
{
m_List = new ktList();
foreach (ktRE_Capture G in GC)
{
m_List.Add(G);
}
}
示例11: Scan
/// <summary>
/// Scan/Parse the script into tokens
/// </summary>
public bool Scan(ktString Script, ktString Name)
{
bool Ret = true;
Script.Replace("\r\n", "\n",true);
// Initiate the lineno.
m_CurLine = 1;
m_CharPos = 1;
// .. and name
m_Name = Name;
if (m_Tokens != null)
{
m_Tokens.Clear();
m_Tokens = null;
}
// Init...
ktString Line = new ktString();
int Pos = 0;
Script.Trim();
ktRegEx RE = new ktRegEx(ktToken.Separators);
// ... the block-stack
if (m_BlockStack != null)
{
m_BlockStack.Clear();
m_BlockStack = null;
}
m_BlockStack = new ktList();
// ... the token-list
if (m_Tokens != null)
{
m_Tokens.Clear();
m_Tokens = null;
}
m_Tokens = new ktList();
m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", 0, 0));
// ... the token-stack
if (m_TokenStack != null)
{
m_TokenStack.Clear();
m_TokenStack = null;
}
m_TokenStack = new ktList();
// ... the lines (??)
if (m_Lines != null)
{
m_Lines.Clear();
m_Lines = null;
}
m_Lines = new ktList();
m_Lines.Node = new ktNode(Name, m_CurToken = new ktToken(ktTokenType.Program, Name, 0, 0));
// ... the line-stack
if (m_LineStack != null)
{
m_LineStack.Clear();
m_LineStack = null;
}
m_LineStack = new ktList();
if (m_MainBlock == null)
{
m_MainBlock = new ktBlock(new ktList());
}
else
{
if (m_MainBlock.Lines != null)
{
m_MainBlock.Lines.Clear();
}
m_MainBlock.ClearKTSymbols();
}
m_MainBlock.SetMain(this);
m_BlockStack.Add("ktTBlock", m_MainBlock);
/* In the "original scanner" (C++), we took one line (terminated by \n)
* at a time and worked on, now we just go through the line.
* And We hope that it will be much "leaner"!
*/
// Go on until the there's nothing left...
while (!Script.IsEmpty())
{
// Get the position for the next separator
Pos = RE.Find(Script);
// If there was none...
if (Pos < 0)
{
// Take it to the end...
Pos = Script.Len();
}
else if (Pos == 0)
{
Pos++;
//.........这里部分代码省略.........
示例12: CallCallback
protected void CallCallback(ktString Method)
{
if (Method.IsEmpty() || (m_Callback == null))
{
return;
}
ktList Args = new ktList();
Args.Add("Name", Name);
Args.Add("Value", this);
try
{
m_Callback.RunMethod("_" + Method, Args);
}
catch (ktError Err)
{
if ((Err.ErrorNumber != ktERR._404) && (Err.ErrorNumber != ktERR.NOTDEC))
{
throw Err;
}
}
}
示例13: Replace
public static ktList Replace(ktString Pattern, ktString Haystack, ktRE_MatchEvaluator[] Evaluators)
{
ktList Results = new ktList();
foreach (ktRE_MatchEvaluator Evaluator in Evaluators)
{
Results.Add(Replace(Pattern, Haystack, Evaluator));
}
return Results;
}
示例14: HandleOperator
protected ktValue HandleOperator(ktList OpTree)
{
ktValue Value = ktValue.Null;
ktValue SecondValue = ktValue.Null;
if (OpTree == null)
{
ktDebug.Log("NOOOOOOOHO!!O!!!!!!!");
return Value;
}
#if Debug
ktDebug.Log( "HOHOHOHOHOHOHOHOHOHOHOHOHOHO:" + OpTree.Get_R( " ", true ) );
#endif
ktToken Op = null;
ktToken First = null;
ktToken Last = null;
if ((OpTree.Node != null) && (OpTree.Node.Value != null))
{
Op = (ktToken)(OpTree.Node.Value);
}
if ((OpTree.First != null) && (OpTree.First.Node != null))
{
if (OpTree.First.Node.Value is ktToken)
{
First = (ktToken)(OpTree.First.Node.Value);
}
else if (OpTree.First.Node.Value is ktValue)
{
Value = (ktValue)(OpTree.First.Node.Value);
First = new ktToken(ktTokenType.NULLTOKEN, "Value", 0, 0);
}
}
if ((OpTree.Last != null) && (OpTree.Last.Node != null))
{
Last = (ktToken)(OpTree.Last.Node.Value);
}
if ((First == null) && (Last == null) || (Op == null))
{
return Value;
}
if (Op.Type == ktTokenType.Operator)
{
ktClass Class = null;
if (First.Type == ktTokenType.NULLTOKEN)
{
//ktDebug.Log( "000000000000000000000000000000" );
}
else
{
Value = TokenToValue(First, OpTree.First);
}
SecondValue = TokenToValue(Last, OpTree.Last);
if (Value.IsNull() || SecondValue.IsNull())
{
throw new ktError("The " + (Value.IsNull() ? "left-hand" : "right-hand") +
" operand can not be a null value!", ktERR.NULL);
}
try
{
//ktDebug.Log("111:" + ((ktClass)Value.Value).Name + "!!!!222:" + ((ktClass)SecondValue.Value).Name + "#####");
Class = (ktClass)(Value.Value);
//ktDebug.Log( "?????????????????????????????????????" );
ktList Args = null;
if (((ktClass)SecondValue.Value).Name == "ktList")
{
ktDebug.Log("!!!!!!!!!");
Args = (ktList)(((ktClass)SecondValue.Value).GetProperty("___").Value);
}
else
{
Args = new ktList();
Args.Add(SecondValue);
}
ArrayList MethNames = new ArrayList(4);
MethNames.Add("operator" + Op.Value.ToString());
MethNames.Add("op" + Op.Value.ToString());
switch (Op.Value)
{
case "+":
{
MethNames.Add("_add");
break;
}
case "-":
{
MethNames.Add("_subtract");
break;
}
case "*":
{
//.........这里部分代码省略.........
示例15: HandleCompAssignment
protected ktValue HandleCompAssignment(ktList Target, ktValue Value)
{
bool Constant = false, Hard = false;
ktString Name = new ktString(), ClassName = null;
ktToken Token = null;
ktClass Class = null;
#if Debug
ktDebug.Log( "HCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCA" );
#endif
ktDebug.Log("HCA: V:" + Value.Export() + "\n" + Target.Get_R());
Target.Reset();
foreach (ktList L in Target)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
Token = (ktToken)L.Node.Value;
#if Debug
ktDebug.Log( "HCA:" + Token.ToString() );
#endif
switch (Token.Type)
{
case ktTokenType.Const:
{
if (Constant)
{
throw new ktError("Unexpected " + Token.ToString() + " on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
Constant = true;
break;
}
case ktTokenType.Hard:
{
if (Hard)
{
throw new ktError("Unexpected " + Token.ToString() + " on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
Hard = true;
break;
}
case ktTokenType.Id:
{
if (!Name.IsEmpty())
{
try
{
Class = GetClass(Name);
ClassName = Name;
Hard = true;
} catch (Exception) {
throw new ktError("Unexpected " + Token.ToString() + " (" +
Token.Value + ") on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
}
Name = Token.Value;
break;
}
}
}
Value.Constant = Constant;
Value.HardType = Hard;
if (!Value.IsNull())
{
((ktClass)Value.Value).HardType = Hard;
((ktClass)Value.Value).IsConstant = Constant;
}
if (Class != null)
{
ktList Arg = new ktList();
ktClass Obj = Class.CreateObject();
Obj.HardType = Hard;
Obj.IsConstant = Constant;
if (!Value.IsNull())
{
Arg.Add(Value);
Obj.RunMethod("Assign", Arg);
}
Value = new ktValue(Name, ClassName, Obj, Hard, Constant);
}
SetVariable(Name, true, Value, true, true);
//.........这里部分代码省略.........