public static void EmitUnbox( VirtualMachine.InstructionList into, OperationDestination Source, OperationDestination Destination) { into.AddInstructions("LOAD_RSO_M " + ReadOperand(Source) + " NEXT " + WriteOperand(Destination), 2); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); Value.Emit(into, OperationDestination.Stack); (LHS as IAssignable).EmitAssignment(into); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); into.AddInstructions("ALLOC_RSO NEXT PUSH", ResultType.Size); into.AddInstructions("STORE_RSO_M NEXT PEEK NEXT", ResultType.ID, 0); //Store type id if (Constructor != null) { if (Constructor.OwnerContextID == Scope.EnvironmentContext.ID && Constructor.OwnerContextID != 0) { into.AddInstructions("CALL NEXT #" + Constructor.DescriptiveHeader, 0); Constructor.Body.CallPoints.Add(into.Count - 1); } else { into.AddInstructions("STACK_INVOKE NEXT", Constructor.MakeInvokableFunction()); } } if (Initializers != null) { foreach (var initializer in Initializers) initializer.Emit(into, OperationDestination.Discard); } if (Destination != OperationDestination.Stack) into.AddInstructions("MOVE POP " + WriteOperand(Destination)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { RHS.Emit(into, OperationDestination.Stack); LHS.Emit(into, OperationDestination.Stack); into.AddInstruction(Instruction, VirtualMachine.Operand.POP, VirtualMachine.Operand.POP, Node.WriteOperand(Destination)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); //Assumes the RSO is on the top of the stack. Value.Emit(into, OperationDestination.R); into.AddInstructions("STORE_RSO_M R PEEK NEXT", Member.Offset); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); foreach (var n in Parameters) n.Emit(into, OperationDestination.Stack); into.AddInstructions("COMPAT_INVOKE NEXT", Parameters.Count); if (Destination != OperationDestination.R && Destination != OperationDestination.Discard) into.AddInstructions("MOVE R " + Node.WriteOperand(Destination)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { Value.Emit(into, OperationDestination.R); into.AddInstructions("ALLOC_RSO NEXT PUSH", 3, "STORE_RSO_M NEXT PEEK NEXT", ResultType.ID, 0, "STORE_RSO_M NEXT PEEK NEXT", Value.ResultType.ID, 1, "STORE_RSO_M R PEEK NEXT", 2); if (Destination != OperationDestination.Stack) into.AddInstructions("MOVE POP " + WriteOperand(Destination)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); foreach (var arg in Arguments) arg.Emit(into, OperationDestination.Stack); into.AddInstructions("STACK_INVOKE NEXT", Function.MakeInvokableFunction()); if (Arguments.Count > 0) into.AddInstructions("CLEANUP NEXT", Arguments.Count); if (Destination != OperationDestination.R && Destination != OperationDestination.Discard) into.AddInstructions("MOVE R " + Node.WriteOperand(Destination)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); if (Value != null) Value.Emit(into, OperationDestination.R); else into.AddInstructions("MOVE NEXT R", 0); into.AddInstructions("JUMP NEXT", 0); DeclarationScope.RecordReturnJumpSource(into.Count - 1); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); if (Value != null) { Value.Emit(into, OperationDestination.Stack); } else { into.AddInstructions("MOVE NEXT PUSH", 0); //Just make room on the stack for it... } }
public override void Emit(VirtualMachine.InstructionList Instructions, OperationDestination Destination) { Instructions.AddInstructions("EMPTY_LIST PUSH"); foreach (var member in Members) { member.Emit(Instructions, OperationDestination.R); Instructions.AddInstructions("APPEND R PEEK PEEK"); } if (Destination == OperationDestination.Discard) Instructions.AddInstructions("MOVE POP"); else if (Destination != OperationDestination.Top) Instructions.AddInstructions("MOVE POP " + WriteOperand(Destination)); }
public static VirtualMachine.Operand ReadOperand(OperationDestination Destination) { switch (Destination) { case OperationDestination.R: return VirtualMachine.Operand.R; case OperationDestination.Stack: return VirtualMachine.Operand.POP; case OperationDestination.Top: return VirtualMachine.Operand.PEEK; case OperationDestination.Discard: default: throw new InvalidOperationException(); } }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.SetPendingAnnotation(this.ToString()); Header.Emit(into, OperationDestination.R); into.AddInstructions("IF_FALSE R", "JUMP NEXT", 0); var jumpFrom = into.Count - 1; ThenBlock.Emit(into, OperationDestination.Discard); if (ElseBlock != null) { into.AddInstructions("JUMP NEXT", 0); into[jumpFrom] = into.Count; jumpFrom = into.Count - 1; ElseBlock.Emit(into, OperationDestination.Discard); } into[jumpFrom] = into.Count; }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { if (Name.Type == TokenType.Identifier) { if (MatchedVariable.StorageMethod == VariableStorageMethod.Local) into.AddInstructions("LOAD_PARAMETER NEXT " + Node.WriteOperand(Destination) + " #" + MatchedVariable.Name, MatchedVariable.Offset); else if (MatchedVariable.StorageMethod == VariableStorageMethod.System) { into.AddInstructions( "MOVE NEXT PUSH", (MatchedVariable as SystemVariable).Implementation, "COMPAT_INVOKE NEXT", 1); if (Destination != OperationDestination.R) into.AddInstructions("MOVE R " + Node.WriteOperand(Destination)); } else if (MatchedVariable.StorageMethod == VariableStorageMethod.LambdaCapture) { into.AddInstructions("LOAD_PARAMETER NEXT R", -3, "LOAD_RSO_M R NEXT " + WriteOperand(Destination), MatchedVariable.Offset); } else if (MatchedVariable.StorageMethod == VariableStorageMethod.Static) { into.AddInstructions("LOAD_STATIC NEXT " + Node.WriteOperand(Destination), MatchedVariable.Offset); } else if (MatchedVariable.StorageMethod == VariableStorageMethod.Constant) { into.AddInstructions("MOVE NEXT " + WriteOperand(Destination), (MatchedVariable as CompileTimeConstant).Value); } else throw new NotImplementedException(); } else if (Name.Type == TokenType.String) throw new InvalidOperationException(); else if (Name.Type == TokenType.Number) into.AddInstructions("MOVE NEXT " + Node.WriteOperand(Destination), Convert.ToSingle(Name.Value)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { //Capture variables into an RSO. into.AddInstructions("ALLOC_RSO NEXT PUSH", Function.DeclarationScope.CapturedVariables.Count + 3); foreach (var capturedVariable in Function.DeclarationScope.CapturedVariables) { if (capturedVariable.Source.StorageMethod == VariableStorageMethod.Local) into.AddInstructions("LOAD_PARAMETER NEXT PUSH", capturedVariable.Source.Offset); else if (capturedVariable.Source.StorageMethod == VariableStorageMethod.LambdaCapture) into.AddInstructions("LOAD_PARAMETER NEXT R", -3, "LOAD_RSO_M R NEXT PUSH", capturedVariable.Source.Offset); else throw new InvalidProgramException(); into.AddInstructions("STORE_RSO_M POP PEEK NEXT", capturedVariable.LocalCopy.Offset); } into.AddInstructions("STORE_RSO_M NEXT PEEK NEXT", 0, Function.DeclarationScope.CapturedVariables.Count); Function.Body.CleanupCall = into.Count - 2; into.AddInstructions("STORE_RSO_M NEXT PEEK NEXT", 0, Function.DeclarationScope.CapturedVariables.Count + 1); Function.Body.CallPoints.Add(into.Count - 2); into.AddInstructions("STORE_RSO_M NEXT PEEK NEXT", Function.ActualParameterCount, Function.DeclarationScope.CapturedVariables.Count + 2); into.AddInstructions("LAMBDA POP " + WriteOperand(Destination)); }
public virtual void Emit(VirtualMachine.InstructionList Instructions, OperationDestination Destination) { throw new NotImplementedException(); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { Value.Emit(into, Destination); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { Object.Emit(into, OperationDestination.R); into.AddInstructions("LOAD_RSO_M R NEXT " + WriteOperand(Destination), MemberVariable.Offset); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { throw new InvalidOperationException("Control invokation should have been removed by transformation phase"); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { foreach (var statement in Statements) statement.Emit(into, OperationDestination.Discard); if (LocalScope.Variables.Count > 0) into.AddInstructions("CLEANUP NEXT", LocalScope.Variables.Count); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { throw new NotImplementedException(); }
public override void Emit(VirtualMachine.InstructionList Instructions, OperationDestination Destination) { if (Value.ResultType.Name == "RULE-NEVERMIND") { Instructions.AddInstructions("ALLOC_RSO NEXT R # Return NEVERMIND", 1); Instructions.AddInstructions("STORE_RSO_M NEXT R NEXT", 0, 0); } else { Value.Emit(Instructions, OperationDestination.Stack); Instructions.AddInstructions("ALLOC_RSO NEXT R # Return an actual value", 2); Instructions.AddInstructions("STORE_RSO_M NEXT R NEXT", 1, 0); Instructions.AddInstructions("STORE_RSO_M POP R NEXT", 1); } }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.AddInstructions("MOVE NEXT " + Node.WriteOperand(Destination), Value); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { into.AddInstructions("MOVE STRING " + Node.WriteOperand(Destination), into.AddString(Value)); }
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination) { throw new InvalidOperationException(); }