Exemple #1
0
 public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target)
 {
     var r = new TransientNode();
     if (_struct.size == 0) throw new InternalError("Struct size not yet determined");
     r.AddInstruction(Instructions.SET, target.GetOperand(TargetUsage.Push),
         Constant((ushort)_struct.size));
     return r;
 }
Exemple #2
0
        Intermediate.IRNode AssignableNode.EmitAssignment(CompileContext context, Model.Scope scope, Intermediate.Operand from, Intermediate.Instructions opcode)
        {
            var r = new TransientNode();

            if (member == null)
            {
                context.ReportError(this, "Member was not resolved");
                return r;
            }

            var target = Target.Register(context.AllocateRegister());
            r.AddChild(Child(0).Emit(context, scope, target));
            r.AddInstruction(opcode, target.GetOperand(TargetUsage.Peek,
                Intermediate.OperandSemantics.Dereference | Intermediate.OperandSemantics.Offset, (ushort)member.offset),
                from);
            return r;
        }
Exemple #3
0
        public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target)
        {
            var r = new TransientNode();

            if (member == null)
            {
                context.ReportError(this, "Member was not resolved.");
                return r;
            }

            Target objectTarget = target;
            if (target.target == Targets.Stack)
                objectTarget = Target.Register(context.AllocateRegister());

            r.AddChild(Child(0).Emit(context, scope, objectTarget));
            if (member.isArray)
            {
                if (target != objectTarget)
                    r.AddInstruction(Instructions.SET, target.GetOperand(TargetUsage.Push), objectTarget.GetOperand(TargetUsage.Pop));
                r.AddInstruction(Instructions.ADD, target.GetOperand(TargetUsage.Peek), Constant((ushort)member.offset));
            }
            else
            {
                if (member.offset == 0)
                    r.AddInstruction(Instructions.SET,
                        target.GetOperand(TargetUsage.Push),
                        objectTarget.GetOperand(TargetUsage.Pop, Intermediate.OperandSemantics.Dereference));
                else
                    r.AddInstruction(Instructions.SET,
                        target.GetOperand(TargetUsage.Push),
                        objectTarget.GetOperand(TargetUsage.Pop,
                            Intermediate.OperandSemantics.Dereference | Intermediate.OperandSemantics.Offset,
                            (ushort)member.offset));
            }

            return r;
        }
Exemple #4
0
 public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target)
 {
     var r = new TransientNode();
     r.AddInstruction(Instructions.SET, target.GetOperand(TargetUsage.Push), GetFetchToken());
     return r;
 }
Exemple #5
0
 public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target)
 {
     var r = new TransientNode();
     r.AddLabel(label.realName);
     return r;
 }