public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && (_scoreEffectSpec != null)) { return(true); } _scoreEffectSpec = null; int ErrorLine; string ErrorExtraMessage; Synthesizer.EffectSpecListRec LocalEffectSpec; Synthesizer.BuildInstrErrors Error = Synthesizer.BuildScoreEffectList( this.Source, ((Document)Parent).CodeCenter, out ErrorLine, out ErrorExtraMessage, out LocalEffectSpec); if (Error != Synthesizer.BuildInstrErrors.eBuildInstrNoError) { failedCallback(this, new LiteralBuildErrorInfo(Synthesizer.BuildInstrGetErrorMessageText(Error, ErrorExtraMessage), ErrorLine)); return(false); } _scoreEffectSpec = LocalEffectSpec; return(true); }
public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && (_sequencerSpec != null)) { return(true); } _sequencerSpec = null; int ErrorLine; Synthesizer.SequencerConfigSpecRec LocalSequencerSpec; Synthesizer.BuildSeqErrors Error = Synthesizer.BuildSequencerFromText( this.Source, out ErrorLine, out LocalSequencerSpec); if (Error != Synthesizer.BuildSeqErrors.eBuildSeqNoError) { failedCallback(this, new LiteralBuildErrorInfo(Synthesizer.BuildSeqGetErrorMessageText(Error), ErrorLine)); return(false); } _sequencerSpec = LocalSequencerSpec; return(true); }
// Compile functions to find errors. Does not do a full build - compiles only this module and does // not check function arg/return types for references to other modules. public bool TestBuild( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback, CodeCenterRec throwAwayCodeCenter) { int ErrorLine; int ErrorModuleIndex; CompileErrors Error = Compiler.CompileWholeProgram( out ErrorLine, out ErrorModuleIndex, new string[] { this.Source }, new object[] { this }, throwAwayCodeCenter, // use throw-away linker to not pollute the real one with unchecked function calls new string[] { this.Name }); if ((Error != CompileErrors.eCompileNoError) // these errors are permitted for test-build because without full function signatures known there will be // arg-type inference ambiguities. && (Error != CompileErrors.eCompileMultiplyDeclaredFunction)) { failedCallback( this, new LiteralBuildErrorInfo(Compiler.GetCompileErrorString(Error), ErrorLine)); return(false); } return(true); }
public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && (_instrument != null)) { return(true); } _instrument = null; Synthesizer.InstrumentRec TheInstrument; int ErrorLine; string ErrorExtraMessage; Synthesizer.BuildInstrErrors Error = Synthesizer.BuildInstrumentFromText( InstrDefinition, ((Document)Parent).CodeCenter, out ErrorLine, out ErrorExtraMessage, out TheInstrument); if (Error != Synthesizer.BuildInstrErrors.eBuildInstrNoError) { failedCallback(this, new LiteralBuildErrorInfo(Synthesizer.BuildInstrGetErrorMessageText(Error, ErrorExtraMessage), ErrorLine)); return(false); } _instrument = TheInstrument; return(true); }
// DO NOT CALL THIS DIRECTLY! Instead, use MainWindow.MakeUpToDate(), which will ensure // that all editors commit their edits to the data storage before building. Calling this // directly will fail because Document doesn't know who it's editors are. public bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { List <IBuildable> sequence = GetBuildSequence(); // for global rebuild, unbuild all first if (force) { foreach (IBuildable buildable in sequence) { buildable.Unbuild(); } } foreach (IBuildable buildable in sequence) { if (!buildable.EnsureBuilt(force, pcodeEnvironment, failedCallback)) { return(false); } } return(true); }
/* build the functions if necessary. return True if successful. */ public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { return(functionBuilderProxy.EnsureBuilt( force, pcodeEnvironment, failedCallback)); }
private void Init( PcodeSystem.IEvaluationContext EvaluationContext, IntPtr[] FunctionPointers, int[] FunctionSignatures, CILThreadLocalStorage previous) { this.EvaluationContext = EvaluationContext; this.FunctionPointers = FunctionPointers; this.FunctionSignatures = FunctionSignatures; this.previous = previous; }
public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && Built) { return(true); } List <string> sources = new List <string>(); List <string> filenames = new List <string>(); List <object> signatures = new List <object>(); for (int i = 0; i < functionList.Count; i++) { sources.Add(functionList[i].Source); filenames.Add(functionList[i].Name); signatures.Add(functionList[i]); functionList[i].Unbuild1(); } int ErrorLine; int ErrorModuleIndex; CompileErrors Error = Compiler.CompileWholeProgram( out ErrorLine, out ErrorModuleIndex, sources.ToArray(), signatures.ToArray(), CodeCenter, filenames.ToArray()); if (Error != CompileErrors.eCompileNoError) { failedCallback( (FunctionObjectRec)signatures[ErrorModuleIndex], new LiteralBuildErrorInfo(Compiler.GetCompileErrorString(Error), ErrorLine)); return(false); } for (int i = 0; i < functionList.Count; i++) { functionList[i].Built1 = true; } return(true); }
public static void Push( PcodeSystem.IEvaluationContext EvaluationContext, IntPtr[] FunctionPointers, int[] FunctionSignatures) { CILThreadLocalStorage top = threadFreeList; if (top == null) { top = new CILThreadLocalStorage(); } else { threadFreeList = threadFreeList.previous; } top.Init(EvaluationContext, FunctionPointers, FunctionSignatures, threadLocal); threadLocal = top; }
public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && (WaveTableData != null)) { return(true); } WaveTableData = null; PcodeRec FuncCode; if (!BuildCode(failedCallback, out FuncCode)) { return(false); } using (ParamStackRec ParamList = new ParamStackRec()) { ArrayHandleFloat dataHandle = new ArrayHandleFloat(new float[NumFrames * NumTables]); int initialCapacity = 1 /*frames*/ + 1 /*tables*/ + 1 /*data*/ + 1 /*retaddr*/; ParamList.EmptyParamStackEnsureCapacity(initialCapacity); ParamList.AddIntegerToStack(NumFrames); ParamList.AddIntegerToStack(NumTables); ParamList.AddArrayToStack(dataHandle); ParamList.AddIntegerToStack(0); /* return address placeholder */ CodeCenterRec CodeCenter = ((Document)Parent).CodeCenter; EvalErrInfoRec ErrorInfo; EvalErrors EvaluationError = PcodeSystem.EvaluatePcodeThread.EvaluatePcode( ParamList, FuncCode, CodeCenter, out ErrorInfo, pcodeEnvironment); if (EvaluationError != EvalErrors.eEvalNoError) { failedCallback( this, new PcodeEvaluationErrorInfo( EvaluationError, ErrorInfo, FuncCode, CodeCenter)); return(false); } Debug.Assert(ParamList.GetStackNumElements() == initialCapacity); // args - retaddr + return value #if DEBUG ParamList.Elements[2].AssertFloatArray(); #endif dataHandle = ParamList.Elements[2].reference.arrayHandleFloat; WaveTableData = new WaveTableStorageRec(NumTables, NumFrames, NumBitsType.eSample24bit); float[] NewData = dataHandle.floats; if (NewData.Length != NumTables * NumFrames) { failedCallback( this, new PcodeEvaluationErrorInfo( "<anonymous>", PcodeSystem.GetPcodeErrorMessage(EvalErrors.eEvalArrayWrongDimensions), 1)); return(false); } for (int i = 0; i < NumTables; i++) { WaveTableStorageRec.Table table = WaveTableData.ListOfTables[i]; for (int j = 0; j < NumFrames; j++) { table[j] = NewData[i * NumFrames + j]; } } } return(true); }
public override bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { if (!force && (SampleData != null)) { return(true); } SampleData = null; PcodeRec FuncCode; if (!BuildCode(failedCallback, out FuncCode)) { return(false); } using (ParamStackRec ParamList = new ParamStackRec()) { ArrayHandleFloat dataHandleLeft = new ArrayHandleFloat(new float[0]); ArrayHandleFloat dataHandleRight = new ArrayHandleFloat(new float[0]); int initialCapacity = 1 /*loopstart1*/ + 1 /*loopstart2*/ + 1 /*loopstart3*/ + 1 /*loopend1*/ + 1 /*loopend2*/ + 1 /*loopend3*/ + 1 /*origin*/ + 1 /*samplingrate*/ + 1 /*naturalfrequency*/ + (NumChannels == NumChannelsType.eSampleStereo ? 2 : 1) /*data or leftdata/rightdata */ + 1 /*retaddr*/; ParamList.EmptyParamStackEnsureCapacity(initialCapacity); ParamList.AddIntegerToStack(LoopStart1); ParamList.AddIntegerToStack(LoopStart2); ParamList.AddIntegerToStack(LoopStart3); ParamList.AddIntegerToStack(LoopEnd1); ParamList.AddIntegerToStack(LoopEnd2); ParamList.AddIntegerToStack(LoopEnd3); ParamList.AddIntegerToStack(Origin); ParamList.AddIntegerToStack(SamplingRate); ParamList.AddDoubleToStack(NaturalFrequency); if (NumChannels == NumChannelsType.eSampleStereo) { ParamList.AddArrayToStack(dataHandleLeft); ParamList.AddArrayToStack(dataHandleRight); } else { ParamList.AddArrayToStack(dataHandleLeft); } ParamList.AddIntegerToStack(0); /* return address placeholder */ CodeCenterRec CodeCenter = ((Document)Parent).CodeCenter; EvalErrInfoRec ErrorInfo; EvalErrors EvaluationError = PcodeSystem.EvaluatePcodeThread.EvaluatePcode( ParamList, FuncCode, CodeCenter, out ErrorInfo, pcodeEnvironment); if (EvaluationError != EvalErrors.eEvalNoError) { failedCallback( this, new PcodeEvaluationErrorInfo( EvaluationError, ErrorInfo, FuncCode, CodeCenter)); return(false); } Debug.Assert(ParamList.GetStackNumElements() == initialCapacity); // args - retaddr + return value #if DEBUG ParamList.Elements[9].AssertFloatArray(); #endif dataHandleLeft = ParamList.Elements[9].reference.arrayHandleFloat; if (NumChannels == NumChannelsType.eSampleStereo) { #if DEBUG ParamList.Elements[10].AssertFloatArray(); #endif dataHandleRight = ParamList.Elements[10].reference.arrayHandleFloat; } if (NumChannels == NumChannelsType.eSampleStereo) { float[] Left = dataHandleLeft.floats; float[] Right = dataHandleRight.floats; if (Left.Length != Right.Length) { failedCallback( this, new PcodeEvaluationErrorInfo( "<anonymous>", "Left and Right algorithmic sample arrays are not the same size.", 1)); return(false); } SampleData = new SampleStorageActualRec(Left.Length, NumBitsType.Max, NumChannels); for (int i = 0; i < Left.Length; i++) { SampleData[2 * i + 0] = Left[i]; SampleData[2 * i + 1] = Right[i]; } } else { float[] Mono = dataHandleLeft.floats; SampleData = new SampleStorageActualRec(Mono.Length, NumBitsType.Max, NumChannels); for (int i = 0; i < Mono.Length; i++) { SampleData[i] = Mono[i]; } } } return(true); }
// requirement IBuildable public abstract bool EnsureBuilt( bool force, PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback);
// DO NOT CALL THIS DIRECTLY! Instead, use MainWindow.MakeUpToDateFunctions(), which will ensure // that all editors commit their edits to the data storage before building. Calling this // directly will fail because Document doesn't know who it's editors are. public bool EnsureBuiltFunctions( PcodeSystem.IEvaluationContext pcodeEnvironment, BuildFailedCallback failedCallback) { return(functionBuilderProxy.EnsureBuilt(false /*force*/, pcodeEnvironment, failedCallback)); }