public static void WriteDoc(TextWriter writer, CodeTemplate code) { writer.Write(code.name); writer.Write(' '); foreach (TemplateParameter parameter in code.parameters) { if (parameter.maxDimensions > 1) { writer.Write('['); for (int i = 0; i < parameter.maxDimensions; ++i) { CodeTemplate.WriteName(writer, parameter.name, i, parameter.maxDimensions); if (i != parameter.maxDimensions - 1) { writer.Write(", "); } } writer.Write("] "); } else { CodeTemplate.WriteName(writer, parameter.name, 0, parameter.maxDimensions); writer.Write(' '); } } writer.WriteLine(); }
public CanCauseError <byte[]> GetDataUnit(IExpression <int>[] parameters, Func <string, int?> getSymbolValue, ScopeStructure <int> scope) { byte[] code = this.baseData.Clone() as byte[]; localLabels.Clear(); externLabels.Clear(); for (int index = 0; index < parameters.Length; ++index) { TemplateParameter paramTemp = this[index]; if (paramTemp.lenght > 0) { if (scope.GetRegisteredASMCLabels().Exists(o => o == parameters[index].ToString()) && !scope.IsLocalLabelExisted(parameters[index].ToString())) { paramTemp.InsertValues(new int [1], code); AddExternLabel(paramTemp.position / 8, parameters[index].ToString()); } else { CanCauseError <int[]> values = CodeTemplate.GetValues(parameters[index], paramTemp, getSymbolValue, this.pointerMaker); if (values.CausedError) { return(values.ConvertError <byte[]>()); } paramTemp.InsertValues(values.Result, code); if (scope.IsLocalLabelExisted(parameters[index].ToString())) { localLabels.Add(paramTemp.position / 8, parameters[index].ToString()); } } } } return((CanCauseError <byte[]>)code); }
public int Compare(ICodeTemplate a, ICodeTemplate b) { if (a == b) { return(0); } /* if (a.GetType() == typeof (GenericFE8Template)) * return -1; * if (b.GetType() == typeof (GenericFE8Template)) * return 1; */ if (a.AmountOfFixedCode != b.AmountOfFixedCode) { return(a.AmountOfFixedCode - b.AmountOfFixedCode); } if (a.OffsetMod != b.OffsetMod) { return(a.OffsetMod - b.OffsetMod); } if (a.EndingCode != b.EndingCode) { return(a.EndingCode ? 1 : -1); } CodeTemplate source1 = a as CodeTemplate; CodeTemplate source2 = b as CodeTemplate; if (source1 != null && source2 != null) { if (source1.Length != source2.Length) { return(source1.Length - source2.Length); } int num1 = source1.Aggregate <TemplateParameter, int>(1, (Func <int, TemplateParameter, int>)((x, y) => x * y.maxDimensions)); int num2 = source2.Aggregate <TemplateParameter, int>(1, (Func <int, TemplateParameter, int>)((x, y) => x * y.maxDimensions)); if (num1 != num2) { return(num1 - num2); } if (source1.AmountOfParams != source2.AmountOfParams) { return(-source1.AmountOfParams + source2.AmountOfParams); } } else { if (source1 != null) { return(1); } if (source2 != null) { return(-1); } } return(0); }
public CanCauseError <byte[]> GetData(IExpression <int>[] code, Func <string, int?> getSymbolValue, ScopeStructure <int> scope) { List <byte> byteList = new List <byte>(32); for (int index = 0; index < code.Length; ++index) { CanCauseError <int[]> values = CodeTemplate.GetValues(code[index], this.parameter, getSymbolValue, (IPointerMaker)null); if (values.CausedError) { return(values.ConvertError <byte[]>()); } byte[] code1 = new byte[this.parameter.LenghtInBytes]; this.parameter.InsertValues(values.Result, code1); byteList.AddRange((IEnumerable <byte>)code1); } byteList.AddRange((IEnumerable <byte>) this.endingValue); return((CanCauseError <byte[]>)byteList.ToArray()); }
private CanCauseError <byte[]> GetDataUnit(IExpression <int>[] parameters, Func <string, int?> getSymbolValue) { byte[] code = this.baseData.Clone() as byte[]; for (int index = 0; index < parameters.Length; ++index) { TemplateParameter paramTemp = this[index]; if (paramTemp.lenght > 0) { CanCauseError <int[]> values = CodeTemplate.GetValues(parameters[index], paramTemp, getSymbolValue, this.pointerMaker); if (values.CausedError) { return(values.ConvertError <byte[]>()); } paramTemp.InsertValues(values.Result, code); } } return((CanCauseError <byte[]>)code); }