Exemplo n.º 1
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);
 }
 // private void DeclareExternASMCLabels<T>(ScopeStructure<int> scope, T output)
 private void DeclareExternASMCLabels(ScopeStructure <int> scope, TextWriter output)
 {
     //if (output is TextWriter)
     if (scope != null)
     {
         foreach (var label in scope.GetRegisteredASMCLabels())
         {
             if (!scope.IsLocalLabelExisted(label))
             {
                 //(output as TextWriter).WriteLine("\t.global " + label);
                 output.WriteLine("\t.global " + label);
             }
         }
     }
 }