Пример #1
0
 public CanCauseError <string[]> GetAssembly(byte[] code, int offset)
 {
     string[] strArray = new string[this.AmountOfParams + 1];
     strArray[0] = this.name;
     for (int index1 = 0; index1 < this.parameters.Count; ++index1)
     {
         TemplateParameter templateParameter = this[index1];
         StringBuilder     stringBuilder     = new StringBuilder(templateParameter.lenght / 2);
         int[]             values            = templateParameter.GetValues(code, offset);
         if (values.Length > 1)
         {
             stringBuilder.Append("[");
             for (int index2 = 0; index2 < values.Length; ++index2)
             {
                 stringBuilder.Append(templateParameter.conversion(values[index2]));
                 if (index2 != templateParameter.maxDimensions - 1)
                 {
                     stringBuilder.Append(",");
                 }
             }
             stringBuilder.Append("]");
         }
         else
         {
             int pointer = values[0];
             if (templateParameter.pointer)
             {
                 pointer = !this.pointerMaker.IsAValidPointer(pointer) ? 0 : this.pointerMaker.MakeOffset(pointer);
             }
             stringBuilder.Append(templateParameter.conversion(pointer));
         }
         strArray[index1 + 1] = stringBuilder.ToString();
     }
     return((CanCauseError <string[]>)strArray);
 }
Пример #2
0
 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);
 }
Пример #3
0
 private byte[] GetDataUnit(string[] text, ILog messageLog)
 {
     byte[] code = this.baseData.Clone() as byte[];
     for (int index1 = 1; index1 < text.Length; ++index1)
     {
         TemplateParameter templateParameter = this[index1 - 1];
         if (templateParameter.lenght > 0)
         {
             string[] strArray = text[index1].Trim('[', ']').Split(new char[1] {
                 ','
             }, templateParameter.maxDimensions, StringSplitOptions.RemoveEmptyEntries);
             int[] values = new int[strArray.Length];
             for (int index2 = 0; index2 < strArray.Length; ++index2)
             {
                 if (!strArray[index2].GetMathStringValue(out values[index2]))
                 {
                     messageLog.AddError(strArray[index2] + " is not a valid number.");
                 }
                 if (templateParameter.pointer)
                 {
                     values[index2] = this.pointerMaker.MakePointer(values[index2]);
                 }
             }
             templateParameter.InsertValues(values, code);
         }
     }
     return(code);
 }
 public TerminatingStringTemplate(string name, IEnumerable <TemplateParameter> parameters, int endingValue, int offsetMod, StringComparer stringComparer)
 {
     this.offsetMod   = offsetMod;
     this.parameter   = parameters.First <TemplateParameter>();
     this.endingValue = ((IEnumerable <byte>)BitConverter.GetBytes(endingValue)).Take <byte>(this.parameter.LenghtInBytes).ToArray <byte>();
     this.name        = name;
     this.comparer    = stringComparer;
 }
Пример #5
0
 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);
 }
Пример #6
0
 internal static CanCauseError <int[]> GetValues(IExpression <int> parameter, TemplateParameter paramTemp, Func <string, int?> getSymbolValue, IPointerMaker pointerMaker)
 {
     int[] numArray;
     if (parameter is ExpressionList <int> )
     {
         ExpressionList <int> expressionList = parameter as ExpressionList <int>;
         numArray = new int[expressionList.ComponentCount];
         for (int index = 0; index < expressionList.ComponentCount; ++index)
         {
             CanCauseError <int> canCauseError = Folding.Fold(expressionList[index], getSymbolValue);
             if (canCauseError.CausedError)
             {
                 return(canCauseError.ConvertError <int[]>());
             }
             numArray[index] = canCauseError.Result;
         }
     }
     else
     {
         CanCauseError <int> canCauseError = Folding.Fold(parameter, getSymbolValue);
         if (canCauseError.CausedError)
         {
             return(canCauseError.ConvertError <int[]>());
         }
         if (paramTemp.pointer && pointerMaker != null)
         {
             numArray = new int[1]
             {
                 pointerMaker.MakePointer(canCauseError.Result)
             }
         }
         ;
         else
         {
             numArray = new int[1]
             {
                 canCauseError.Result
             }
         };
     }
     return((CanCauseError <int[]>)numArray);
 }