private static void _execAdd_InvokeToString_CallBacker( ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeDataType v1type = v1.rtType; ASBinCode.RunTimeDataType v2type = v2.rtType; if (v1type == ASBinCode.RunTimeDataType.rt_void) { v1type = ASBinCode.RunTimeDataType.rt_number; } if (v2type == ASBinCode.RunTimeDataType.rt_void) { v2type = ASBinCode.RunTimeDataType.rt_number; } ASBinCode.RunTimeDataType finalType = TypeConverter.getImplicitOpType( v1type, v2type, ASBinCode.OpCode.add, frame.player.swc ); if (finalType == ASBinCode.RunTimeDataType.rt_number) { step.reg.getSlot(scope, frame).setValue( TypeConverter.ConvertToNumber(v1) + TypeConverter.ConvertToNumber(v2) ); frame.endStepNoError(); return; } else if (finalType == ASBinCode.RunTimeDataType.rt_string) { BlockCallBackBase cb = frame.player.blockCallBackPool.create(); cb.setCallBacker(D_Cast_TwoString_Callbacker); cb.args = frame; cb.scope = scope; cb.step = step; OpCast.CastTwoValue(v1, v2, finalType, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, cb ); return; } else if (finalType == ASBinCode.RunTimeDataType.rt_void) { step.reg.getSlot(scope, frame).setValue(ASBinCode.rtData.rtUndefined.undefined); } else { frame.throwOpException(step.token, ASBinCode.OpCode.add); } frame.endStep(step); }
private static void _execAdd_CallBacker( ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope) { ASBinCode.RunTimeDataType v1type = v1.rtType; ASBinCode.RunTimeDataType v2type = v2.rtType; if (v1type == ASBinCode.RunTimeDataType.rt_void) { v1type = ASBinCode.RunTimeDataType.rt_number; } if (v2type == ASBinCode.RunTimeDataType.rt_void) { v2type = ASBinCode.RunTimeDataType.rt_number; } if (v1type > ASBinCode.RunTimeDataType.unknown || v2type > ASBinCode.RunTimeDataType.unknown) { //***调用toString()*** OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker); } //else if (v1type > ASBinCode.RunTimeDataType.unknown) //{ // OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope, // frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker); //} //else if (v2type > ASBinCode.RunTimeDataType.unknown) //{ //} else { _execAdd_InvokeToString_CallBacker(v1, v2, frame, step, scope); } }
public void setEAXTypeWhenCompile(RunTimeDataType t) { //type = t; valueType = t; }
public Class getClassByRunTimeDataType(RunTimeDataType rttype) { return(classes[rttype - RunTimeDataType._OBJECT]); //throw new NotImplementedException(); }
public CSWC Deserialize(byte[] bin) { serizlizedObjects.Clear(); stringpool.Clear(); dictSerizlized.Clear(); CSWC swc = new CSWC(); loadingSwc = swc; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(bin)) { using (System.IO.BinaryReader br = new System.IO.BinaryReader(ms, System.Text.Encoding.UTF8)) { int classcount = br.ReadInt32(); for (int i = 0; i < classcount; i++) { swc.classes.Add(DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass)); } int functioncount = br.ReadInt32(); for (int i = 0; i < functioncount; i++) { swc.functions.Add(DeserializeObject <rtti.FunctionDefine>(br, rtti.FunctionDefine.LoadFunctionDefine)); } int blockcount = br.ReadInt32(); for (int i = 0; i < blockcount; i++) { swc.blocks.Add(DeserializeObject <CodeBlock>(br, CodeBlock.Deserialize)); } swc.primitive_to_class_table.Clear(); int tablecount = br.ReadInt32(); for (int i = 0; i < tablecount; i++) { swc.primitive_to_class_table.Add(DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass)); } int dict_vector_type_count = br.ReadInt32(); for (int i = 0; i < dict_vector_type_count; i++) { rtti.Class _class = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); RunTimeDataType t = br.ReadInt32(); swc.dict_Vector_type.Add(_class, t); } int _dictlinkcreatorcount = br.ReadInt32(); for (int i = 0; i < _dictlinkcreatorcount; i++) { string key = br.ReadString(); rtti.Class _class = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); swc._dictlinkcreatorfunctionname.Add(key, _class); } swc.operatorOverrides = DeserializeObject <OperatorFunctions>(br, OperatorFunctions.LoadOperatorFunctions); /////// <summary> /////// 链接到系统Object的类型 /////// </summary> ////public Class LinkObjectClass; //SerializeObject<rtti.Class>(bw, swc.LinkObjectClass); swc.LinkObjectClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// Class类型 /////// </summary> ////public Class TypeClass; //SerializeObject<rtti.Class>(bw, swc.TypeClass); swc.TypeClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// Object类 /////// </summary> ////public Class ObjectClass; //SerializeObject<rtti.Class>(bw, swc.ObjectClass); swc.ObjectClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// IEnumerator接口 /////// </summary> ////public Class IEnumeratorInterface; //SerializeObject<rtti.Class>(bw, swc.IEnumeratorInterface); swc.IEnumeratorInterface = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// IEnumerable接口 /////// </summary> ////public Class IEnumerableInterface; //SerializeObject<rtti.Class>(bw, swc.IEnumerableInterface); swc.IEnumerableInterface = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// yielditerator类 /////// </summary> ////public Class YieldIteratorClass; //SerializeObject<rtti.Class>(bw, swc.YieldIteratorClass); swc.YieldIteratorClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// Function类 /////// </summary> ////public Class FunctionClass; //SerializeObject<rtti.Class>(bw, swc.FunctionClass); swc.FunctionClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// 异常类 /////// </summary> ////public Class ErrorClass; //SerializeObject<rtti.Class>(bw, swc.ErrorClass); swc.ErrorClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// 字典特殊类 /////// </summary> ////public Class DictionaryClass; //SerializeObject<rtti.Class>(bw, swc.DictionaryClass); swc.DictionaryClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); /////// <summary> /////// 正则类 /////// </summary> ////public Class RegExpClass; //SerializeObject<rtti.Class>(bw, swc.RegExpClass); swc.RegExpClass = DeserializeObject <rtti.Class>(br, rtti.Class.LoadClass); swc.MaxMemNumberCount = br.ReadInt32(); swc.MaxMemIntCount = br.ReadInt32(); swc.MaxMemUIntCount = br.ReadInt32(); swc.MaxMemBooleanCount = br.ReadInt32(); } } loadingSwc = null; return(swc); }
private Variable(string name, int index, bool ignoreImplicitCast, int refblockid, RunTimeDataType type, bool isConst) : base(name, index, ignoreImplicitCast, refblockid, type, isConst) { }
public static RunTimeValueBase LoadRunTimeValueBase(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> list, int key) { RunTimeDataType type = reader.ReadInt32(); switch (type) { case RunTimeDataType.rt_boolean: { bool b = reader.ReadBoolean(); if (b) { return(rtData.rtBoolean.True); } else { return(rtData.rtBoolean.False); } } case RunTimeDataType.rt_array: { int c = reader.ReadInt32(); rtData.rtArray array = new rtData.rtArray(); for (int i = 0; i < c; i++) { array.innerArray.Add(LoadRunTimeValueBase(reader, serizlizer, list, key)); } return(array); } case RunTimeDataType.rt_function: { return(new ASBinCode.rtData.rtFunction(reader.ReadInt32(), reader.ReadBoolean())); } case RunTimeDataType.rt_int: { return(new rtData.rtInt(reader.ReadInt32())); } case RunTimeDataType.rt_null: { return(rtData.rtNull.nullptr); } case RunTimeDataType.rt_number: { return(new rtData.rtNumber(reader.ReadDouble())); } case RunTimeDataType.rt_string: { bool isnull = reader.ReadBoolean(); if (isnull) { return(new rtData.rtString(null)); } else { return(new rtData.rtString(reader.ReadString())); } } case RunTimeDataType.rt_uint: { return(new rtData.rtUInt(reader.ReadUInt32())); } case RunTimeDataType.rt_void: { return(rtData.rtUndefined.undefined); } default: throw new IOException("错误数据类型"); } }
public RunTimeValueBase(RunTimeDataType rtType) { this.rtType = rtType; }
public override bool directSet(RunTimeValueBase value) { //value只会在内部new出来,因此,如果value不为null,也肯定是自己new出来的 rtType = value.rtType; if (this.value == null || this.value.rtType != rtType) { //new 一个 this.value = (RunTimeValueBase)value.Clone(); } else { switch (value.rtType) { case RunTimeDataType.rt_boolean: this.value = value; break; case RunTimeDataType.rt_int: ((rtInt)this.value).value = ((rtInt)value).value; break; case RunTimeDataType.rt_uint: ((rtUInt)this.value).value = ((rtUInt)value).value; break; case RunTimeDataType.rt_number: ((rtNumber)this.value).value = ((rtNumber)value).value; break; case RunTimeDataType.rt_string: ((rtString)this.value).value = ((rtString)value).value; break; case RunTimeDataType.rt_void: this.value = value; break; case RunTimeDataType.rt_null: this.value = value; break; case RunTimeDataType.rt_function: ((rtFunction)this.value).CopyFrom((rtFunction)value); break; case RunTimeDataType.fun_void: this.value = value; break; case RunTimeDataType.rt_array: //((rtArray)this.value).CopyFrom((rtArray)value); this.value = value; break; case RunTimeDataType.unknown: this.value = null; break; default: if (!ReferenceEquals(this.value,value)) { rtObjectBase ro = (rtObjectBase)value; var _class = ro.value._class; //if (this.value.rtType == value.rtType)//前面已有判断这里肯定相同 { if (_class.isLink_System) { if (_class.isStruct) { ((rtti.LinkSystemObject)((rtObjectBase)this.value).value) .CopyStructData((rtti.LinkSystemObject)ro.value); } else { ((rtObjectBase)this.value).value = ro.value; //ro.value = ((rtObject)value).value; } } else { this.value = value; } } //else //{ // this.value = (RunTimeValueBase)value.Clone(); //考虑处理结构类型struct //} } //this.value = (rtObject)value.Clone(); //if (((rtObject)this.value).value.objectid != ((rtObject)value).value.objectid) //{ //} //((rtObject)this.value).CopyFrom((rtObject)value); break; } } return(true); }
//public sealed override bool isPropGetterSetter //{ // get // { // return false; // } //} public void setDefaultType(RunTimeDataType type,RunTimeValueBase v) { rtType = type; value = v; //TypeConverter.getDefaultValue(rtType).getValue(null); }