Ejemplo n.º 1
0
 public void BasicCodegen(TextWriter writer, bool simple)
 {
     InstructionWriter.WriteHeader(writer, simple);
     InstructionWriter.WriteInstructionOp(writer, Opcodes.INIT, simple);
     writer.WriteLine($"{maxValues} {maxObjects}");
     foreach (BaseNode child in children)
     {
         child.BasicCodegen(writer, simple);
     }
     writer.WriteLine("}");
 }
Ejemplo n.º 2
0
 public override void BasicCodegen(TextWriter writer, bool simple)
 {
     foreach (Instruction node in nodes)
     {
         InstructionWriter.WriteInstructionOp(writer, (Opcodes)node.OpCode, simple);
         foreach (object obj in node.Parameters)
         {
             writer.Write($" {obj}");
         }
         writer.WriteLine();
     }
 }
Ejemplo n.º 3
0
        public override void BasicCodegen(TextWriter writer, bool simple)
        {
            InstructionWriter.WriteInstructionOp(writer, Opcodes.PUSH_MAP, simple);
            KeyValuePair <BaseNode, BaseNode> firstkvp = map.First();

            // Optimisation if they all are value nodes
            if (firstkvp.Key is ValueNode firstKey && firstkvp.Value is ValueNode firstValue)
            {
                string keyTypeID   = InstructionWriter.GetTypeID(firstKey.obj, simple);
                string valueTypeID = InstructionWriter.GetTypeID(firstValue.obj, simple);

                writer.WriteLine($"{keyTypeID} {valueTypeID}");
                InstructionWriter.WriteInstructionOp(writer, Opcodes.QUICK_SET_MAP, simple);
                writer.Write($"{keyTypeID} {valueTypeID}");
                foreach (KeyValuePair <BaseNode, BaseNode> kvp in map)
                {
                    ValueNode key   = (ValueNode)kvp.Key;
                    ValueNode value = (ValueNode)kvp.Value;
                    writer.Write($" {key.obj} {value.obj}");
                }
                writer.WriteLine();
            }
Ejemplo n.º 4
0
 public override void BasicCodegen(TextWriter writer, bool simple)
 {
     InstructionWriter.WriteInstructionOp(writer, Opcodes.PUSH_ARRAY, simple);
     // Check for onedimensional
     if (values[0] is ValueNode)
     {
         string typeID = InstructionWriter.GetTypeID(((ValueNode)values[0]).obj, simple);
         writer.WriteLine($"{typeID} {values.Count}");
         InstructionWriter.WriteInstructionOp(writer, Opcodes.ARRAY_CPY, simple);
         writer.Write($"{typeID} {values.Count}");
         foreach (BaseNode node in values)
         {
             writer.Write($" {(node as ValueNode).obj}");
         }
         writer.WriteLine();
     }
     else
     {
         // @TODO: Implement non one dimensional arrays
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 5
0
 public override void BasicCodegen(TextWriter writer, bool simple)
 {
     InstructionWriter.WriteInstructionOp(writer, Opcodes.DE_INIT, simple);
     writer.WriteLine();
 }