protected override void Load(Dsl.CallData callData) { m_LoadedOptArgs = new Dictionary <string, IStoryValue>(); foreach (var pair in m_OptArgs) { StoryValue val = new StoryValue(); val.InitFromDsl(pair.Value); m_LoadedOptArgs.Add(pair.Key, val); } m_LoadedArgs = new List <IStoryValue>(); int num = callData.GetParamNum(); for (int i = 0; i < num; ++i) { StoryValue val = new StoryValue(); val.InitFromDsl(callData.GetParam(i)); m_LoadedArgs.Add(val); } IsCompositeCommand = true; if (null == m_PrologueCommand) { m_PrologueCommand = new CompositePrologueCommandHelper(this); } if (null == m_EpilogueCommand) { m_EpilogueCommand = new CompositeEpilogueCommandHelper(this); } }
protected override void Load(Dsl.CallData callData) { int num = callData.GetParamNum(); if (num > 1) { m_Id.InitFromDsl(callData.GetParam(0)); m_SubstId.InitFromDsl(callData.GetParam(1)); } }
public void CopyFrom(FunctionData other) { m_Call = other.m_Call; m_Statements = other.m_Statements; m_ExtentClass = other.m_ExtentClass; m_ExternScript = other.m_ExternScript; }
public void Clear() { m_Call = null; m_Statements = new List<ISyntaxComponent>(); m_ExtentClass = (int)ExtentClassEnum.EXTENT_CLASS_NOTHING; m_ExternScript = null; }
public void AddStatement(CallData statement) { m_Statements.Add(statement); if ((int)ExtentClassEnum.EXTENT_CLASS_STATEMENT != m_ExtentClass) { m_ExtentClass = (int)ExtentClassEnum.EXTENT_CLASS_STATEMENT; } }
public void CopyFrom(CallData other) { m_IsHighOrder = other.m_IsHighOrder; m_Name = other.m_Name; m_Call = other.m_Call; m_Params = other.m_Params; m_ParamClass = other.m_ParamClass; }
public void Clear() { m_Name = null; m_Call = null; m_IsHighOrder = false; m_Params = new List<ISyntaxComponent>(); m_ParamClass = (int)ParamClassEnum.PARAM_CLASS_NOTHING; }
public void AddParams(CallData param) { m_Params.Add(param); if ((int)ParamClassEnum.PARAM_CLASS_NOTHING == m_ParamClass) { m_ParamClass = (int)ParamClassEnum.PARAM_CLASS_PARENTHESIS; } }
internal static void writeBinary(MemoryStream stream, List<string> identifiers, CallData data) { stream.WriteByte((byte)DslBinaryCode.BeginCall); if (null != data) { stream.WriteByte((byte)((int)DslBinaryCode.ParamTypeBegin + data.GetParamClass())); if (data.IsHighOrder) { writeBinary(stream, identifiers, data.Call); } else { writeBinary(stream, identifiers, data.Name); } foreach (ISyntaxComponent syntaxData in data.Params) { writeBinary(stream, identifiers, syntaxData); } } stream.WriteByte((byte)DslBinaryCode.EndCall); }
internal static void readBinary(byte[] bytes, ref int curCodeIndex, List<string> identifiers, ref int curIdIndex, FunctionData data) { byte code = readByte(bytes, curCodeIndex++); if (code == (byte)DslBinaryCode.BeginFunction) { code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.BeginCall) { CallData callData = new CallData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, callData); data.Call = callData; } code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.BeginExternScript) { ++curCodeIndex; data.SetExtentClass((int)FunctionData.ExtentClassEnum.EXTENT_CLASS_EXTERN_SCRIPT); data.SetExternScript(readIdentifier(identifiers, curIdIndex++)); code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.EndExternScript) { ++curCodeIndex; } } else { data.SetExtentClass((int)FunctionData.ExtentClassEnum.EXTENT_CLASS_STATEMENT); for (; ; ) { code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.EndFunction) { ++curCodeIndex; break; } else { ISyntaxComponent syntaxData = readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex); if (null != syntaxData) { data.Statements.Add(syntaxData); } else { break; } } } } } }
internal static void readBinary(byte[] bytes, ref int curCodeIndex, List<string> identifiers, ref int curIdIndex, CallData data) { byte code = readByte(bytes, curCodeIndex++); if (code == (byte)DslBinaryCode.BeginCall) { code = readByte(bytes, curCodeIndex); if (code >= (byte)DslBinaryCode.ParamTypeBegin) { ++curCodeIndex; data.SetParamClass(code - (byte)DslBinaryCode.ParamTypeBegin); } code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.BeginValue) { ValueData valueData = new ValueData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, valueData); data.Name = valueData; } else if (code == (byte)DslBinaryCode.BeginCall) { CallData callData = new CallData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, callData); data.Call = callData; } for (; ; ) { code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.EndCall) { ++curCodeIndex; break; } else { ISyntaxComponent syntaxData = readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex); if (null != syntaxData) { data.Params.Add(syntaxData); } else { break; } } } } }
internal static ISyntaxComponent readBinary(byte[] bytes, ref int curCodeIndex, List<string> identifiers, ref int curIdIndex) { ISyntaxComponent ret = null; byte code = readByte(bytes, curCodeIndex); if (code == (byte)DslBinaryCode.BeginValue) { ValueData data = new ValueData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, data); ret = data; } else if (code == (byte)DslBinaryCode.BeginCall) { CallData data = new CallData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, data); ret = data; } else if (code == (byte)DslBinaryCode.BeginFunction) { FunctionData data = new FunctionData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, data); ret = data; } else if (code == (byte)DslBinaryCode.BeginStatement) { StatementData data = new StatementData(); readBinary(bytes, ref curCodeIndex, identifiers, ref curIdIndex, data); ret = data; } return ret; }
public static string getCallString(CallData data, bool includeComment) { #if FULL_VERSION string lineNo = string.Empty;// string.Format("/* {0} */", data.GetLine()); string line = string.Empty; if (data.IsHighOrder) { line = getCallString(data.Call, includeComment); } else if (data.HaveId()) { line = quoteString(data.GetId(), data.GetIdType()); } if (data.HaveParam()) { int paramClass = (data.GetParamClass() & (int)CallData.ParamClassEnum.PARAM_CLASS_UNMASK); if ((int)CallData.ParamClassEnum.PARAM_CLASS_OPERATOR == paramClass) { switch (data.GetParamNum()) { case 1: return string.Format("{0} {1}", line, data.GetParam(0).ToScriptString(includeComment)); case 2: return string.Format("{0} {1} {2}", data.GetParam(0).ToScriptString(includeComment), line, data.GetParam(1).ToScriptString(includeComment)); default: return line; } } else { string lbracket = string.Empty; string rbracket = string.Empty; switch (paramClass) { case (int)CallData.ParamClassEnum.PARAM_CLASS_PARENTHESIS: lbracket = "("; rbracket = ")"; break; case (int)CallData.ParamClassEnum.PARAM_CLASS_BRACKET: lbracket = "["; rbracket = "]"; break; case (int)CallData.ParamClassEnum.PARAM_CLASS_PERIOD: lbracket = "."; rbracket = string.Empty; break; case (int)CallData.ParamClassEnum.PARAM_CLASS_PERIOD_PARENTHESIS: lbracket = ".("; rbracket = ")"; break; case (int)CallData.ParamClassEnum.PARAM_CLASS_PERIOD_BRACKET: lbracket = ".["; rbracket = "]"; break; case (int)CallData.ParamClassEnum.PARAM_CLASS_PERIOD_BRACE: lbracket = ".{"; rbracket = "}"; break; } StringBuilder stream = new StringBuilder(); stream.Append(lbracket); int ct = data.GetParamNum(); for (int i = 0; i < ct; ++i) { if (i > 0) stream.Append(","); ISyntaxComponent param = data.GetParam(i); if ((int)CallData.ParamClassEnum.PARAM_CLASS_PERIOD == paramClass) stream.Append(unquoteString(param.ToScriptString(includeComment))); else stream.Append(param.ToScriptString(includeComment)); } stream.Append(rbracket); return string.Format("{0}{1}{2}", lineNo, line, stream.ToString()); } } else { return string.Format("{0}{1}", lineNo, line); } #else return string.Empty; #endif }
protected override void Load(Dsl.CallData callData) { int num = callData.GetParamNum(); }