Beispiel #1
0
 static void GenerateStructExprData(StructExpression sexpr, TextWriter writer)
 {
     foreach (var val in sexpr.Values)
     {
         if (val.Value is StructExpression)
         {
             GenerateStructExprData((StructExpression)val.Value, writer);
         }
         else if (val.Value is IntegerConstant)
         {
             var constant = val.Value as IntegerConstant;
             writer.WriteLine("    DC." + (val.Type.Width == 1 ? "B" : (val.Type.Width == 2 ? "W" : "L")) +
                              "   " + constant.Constant);
         }
         else if (val.Value == null)
         {
             writer.WriteLine("    DC." + (val.Type.Width == 1 ? "B" : (val.Type.Width == 2 ? "W" : "L")) +
                              "   0");
         }
         else
         {
             writer.Write("    DC." + (val.Type.Width == 1 ? "B" : (val.Type.Width == 2 ? "W" : "L")));
             writer.WriteLine($"    {M68kInstruction.ConvertLabel(((VariableReference)((GetElementPtr)val.Value).PtrVal).Variable)}");
         }
     }
 }
Beispiel #2
0
 public object Visit(StructExpression expr)
 {
     foreach (var v in expr.Values)
     {
         if (v.Type == null)
         {
             fieldsMissingType.Add(v);
         }
     }
     return(null);
 }
Beispiel #3
0
        StructExpression ParseStructExpression()
        {
            var expr = new StructExpression
            {
                Values = new List <StructField>()
            };

            AcceptElement(Token.CurlyBraceOpen);

            while (PeekElement().Type != Token.CurlyBraceClose)
            {
                var val = new StructField();

                val.Type = ParseType();

                if (AcceptElementIfNext(Token.Null))
                {
                }
                else if (AcceptElementIfNext(Token.ZeroInitializer))
                {
                    val.InitializeToZero = true;
                }
                else
                {
                    val.Value = ParseExpression();
                }

                expr.Values.Add(val);

                AcceptElementIfNext(Token.Comma);
            }

            AcceptElement(Token.CurlyBraceClose);

            return(expr);
        }