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; }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { Model.Label destination = null; foreach (var _label in scope.activeFunction.function.labels) if (_label.declaredName == label) destination = _label; if (destination == null) context.ReportError(this, "Unknown label - " + label); var r = new StatementNode(); if (destination != null) r.AddInstruction(Instructions.SET, Operand("PC"), Label(destination.realName)); return r; }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { var r = new StatementNode(); r.AddChild(new Annotation(context.GetSourceSpan(this.Span))); if (ChildNodes.Count > 0) { r.AddChild(Child(0).Emit(context, scope, Target.Stack)); r.AddInstruction(Instructions.SET, Operand("A"), Operand("POP")); } r.AddChild(scope.activeFunction.CompileReturn(context, scope)); return r; }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { var r = new StatementNode(); r.AddChild(new Annotation(context.GetSourceSpan(this.Span))); var fetch_token = Child(1).GetFetchToken(); if (fetch_token == null) { var rTarget = Target.Register(context.AllocateRegister()); r.AddChild(Child(1).Emit(context, scope, rTarget)); fetch_token = rTarget.GetOperand(TargetUsage.Pop); } r.AddChild((Child(0) as AssignableNode).EmitAssignment(context, scope, fetch_token, opcodes[@operator])); return r; }
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; }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { return new Intermediate.Annotation("Declaration of function " + function.name); }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { var r = new Intermediate.TransientNode(); r.AddInstruction(Instructions.SET, target.GetOperand(TargetUsage.Push), Label(staticLabel)); return r; }
public virtual Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { return new Annotation("Emit not implemented on " + this.GetType().Name); }
public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) { var r = new TransientNode(); r.AddLabel(label.realName); return r; }