本文整理汇总了C#中CloneContext类的典型用法代码示例。如果您正苦于以下问题:C# CloneContext类的具体用法?C# CloneContext怎么用?C# CloneContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloneContext类属于命名空间,在下文中一共展示了CloneContext类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XenkoShaderMixer
/// <summary>
/// Constructor
/// </summary>
/// <param name="moduleMixin">the final shader information</param>
/// <param name="log">The log.</param>
/// <param name="context">all the mixins in the context</param>
/// <param name="compositionsPerVariable">The compositions per variable.</param>
/// <param name="cloneContext">The clone context.</param>
/// <exception cref="System.ArgumentNullException">
/// moduleMixin
/// or
/// log
/// or
/// context
/// </exception>
public XenkoShaderMixer(ModuleMixin moduleMixin, LoggerResult log, Dictionary<string, ModuleMixin> context, CompositionDictionary compositionsPerVariable, CloneContext cloneContext = null)
{
if (moduleMixin == null)
throw new ArgumentNullException("moduleMixin");
if (log == null)
throw new ArgumentNullException("log");
if (context == null)
throw new ArgumentNullException("context");
this.log = log;
mixContext = context;
mainModuleMixin = moduleMixin;
defaultCloneContext = cloneContext;
if (compositionsPerVariable != null)
CompositionsPerVariable = compositionsPerVariable;
else
CompositionsPerVariable = new CompositionDictionary();
var mixinsToAnalyze = new Stack<ModuleMixin>(CompositionsPerVariable.Values.SelectMany(x => x));
mixinsToAnalyze.Push(mainModuleMixin);
while (mixinsToAnalyze.Count > 0)
AddDefaultCompositions(mixinsToAnalyze);
}
示例2: CloneTo
protected override void CloneTo(CloneContext clonectx, Expression target)
{
base.CloneTo (clonectx, target);
AQueryClause t = (AQueryClause) target;
if (block != null)
t.block = (QueryBlock) clonectx.LookupBlock (block);
if (next != null)
t.next = (AQueryClause) next.Clone (clonectx);
}
示例3: CloneTo
protected override void CloneTo (CloneContext clonectx, Expression target)
{
Join t = (Join) target;
t.inner_selector = (QueryBlock) inner_selector.Clone (clonectx);
t.outer_selector = (QueryBlock) outer_selector.Clone (clonectx);
base.CloneTo (clonectx, t);
}
示例4: BuildCompositionsDictionary
/// <summary>
/// create the context for each composition by cloning their dependencies
/// </summary>
/// <param name="shaderSource">the entry ShaderSource (root)</param>
/// <param name="dictionary">the ouputed compositions</param>
/// <param name="compilationContext">the compilation context</param>
/// <param name="cloneContext">The clone context.</param>
/// <returns>a list of all the needed mixins</returns>
private static List<ModuleMixin> BuildCompositionsDictionary(ShaderSource shaderSource, CompositionDictionary dictionary, ShaderCompilationContext compilationContext, CloneContext cloneContext, LoggerResult log)
{
if (shaderSource is ShaderMixinSource)
{
var shaderMixinSource = shaderSource as ShaderMixinSource;
var finalModule = compilationContext.GetModuleMixinFromShaderSource(shaderSource);
//PerformanceLogger.Start(PerformanceStage.DeepClone);
finalModule = finalModule.DeepClone(new CloneContext(cloneContext));
//PerformanceLogger.Pause(PerformanceStage.DeepClone);
foreach (var composition in shaderMixinSource.Compositions)
{
//look for the key
var foundVars = finalModule.FindAllVariablesByName(composition.Key).Where(value => value.Variable.Qualifiers.Contains(ParadoxStorageQualifier.Compose)).ToList();
if (foundVars.Count > 1)
{
log.Error(ParadoxMessageCode.ErrorAmbiguousComposition, new SourceSpan(), composition.Key);
}
else if (foundVars.Count > 0)
{
Variable foundVar = foundVars[0].Variable;
var moduleMixins = BuildCompositionsDictionary(composition.Value, dictionary, compilationContext, cloneContext, log);
if (moduleMixins == null)
return null;
dictionary.Add(foundVar, moduleMixins);
}
else
{
// No matching variable was found
// TODO: log a message?
}
}
return new List<ModuleMixin> { finalModule };
}
if (shaderSource is ShaderClassSource)
{
var finalModule = compilationContext.GetModuleMixinFromShaderSource(shaderSource);
//PerformanceLogger.Start(PerformanceStage.DeepClone);
finalModule = finalModule.DeepClone(new CloneContext(cloneContext));
//PerformanceLogger.Pause(PerformanceStage.DeepClone);
return new List<ModuleMixin> { finalModule };
}
if (shaderSource is ShaderArraySource)
{
var shaderArraySource = shaderSource as ShaderArraySource;
var compositionArray = new List<ModuleMixin>();
foreach (var shader in shaderArraySource.Values)
{
var mixin = BuildCompositionsDictionary(shader, dictionary, compilationContext, cloneContext, log);
if (mixin == null)
return null;
compositionArray.AddRange(mixin);
}
return compositionArray;
}
return null;
}
示例5: Initialize
public void Initialize(CloneContext previousCloneContext)
{
// Clone original context
var cloneContext = new CloneContext();
foreach (var keyValurPair in previousCloneContext)
{
cloneContext.Add(keyValurPair.Key, keyValurPair.Value);
}
// Removes the method to clone
cloneContext.Remove(Method);
// Clone the old method with the clone context
NewMethod = Method.DeepClone(cloneContext);
var oldParameters = NewMethod.Parameters;
NewMethod.Parameters = new List<Parameter>();
int j = 0;
for (int i = 0; i < oldParameters.Count; i++)
{
var parameter = oldParameters[i];
var variableValue = (Variable)this.Method.Parameters[i].GetTag(ScopeValueKey);
if (variableValue != null)
{
this.NewMethod.Body.Insert(j, new DeclarationStatement(parameter));
j++;
parameter.InitialValue = new VariableReferenceExpression(variableValue.Name) { TypeInference = { Declaration = variableValue, TargetType = variableValue.Type } };
}
else
NewMethod.Parameters.Add(parameter);
}
// Create new method with new method name
var methodNameBuild = new StringBuilder();
methodNameBuild.Append(Method.Name);
foreach (var variable in Variables)
{
methodNameBuild.Append("_");
methodNameBuild.Append(variable.Name);
}
methodName = methodNameBuild.ToString();
NewMethod.Name = methodName;
}
示例6: Clone
public Arguments Clone (CloneContext ctx)
{
Arguments cloned = new Arguments (args.Count);
foreach (Argument a in args)
cloned.Add (a.Clone (ctx));
return cloned;
}
示例7: CloneTo
protected override void CloneTo (CloneContext clonectx, Expression t)
{
AsIn target = (AsIn) t;
target.expr = expr.Clone (clonectx);
target.objExpr = objExpr.Clone (clonectx);
}
示例8: CloneInternal
internal override Statement CloneInternal(CloneContext ctx)
{
IfStatement clone = new IfStatement();
ctx.Map(this, clone);
foreach (Expression e in Conditions)
clone.Conditions.Add(e);
foreach (Statement b in Branches)
clone.Branches.Add(b.GetClone(ctx));
return clone;
}
示例9: CloneTo
protected override void CloneTo (CloneContext clonectx, Expression t)
{
Assign _target = (Assign) t;
_target.target = target.Clone (clonectx);
_target.source = source.Clone (clonectx);
}
示例10: ExportDwgToJpg
public void ExportDwgToJpg(string destPath)
{
string sourcePath = String.Format("{0}{1}.dwg", DefaultDwgFolder, Control.ControlNo);
Dictionary<string, string> dictDim = new Dictionary<string, string>();
foreach (ControlDrawingDetail detail in ControlDrawingDetails)
{
if (dictDim.ContainsKey(detail.Dim.DimNo) == false)
{
dictDim.Add(detail.Dim.DimNo, detail.DimValue);
}
}
try
{
DxfModel readModel = DwgReader.Read(sourcePath);
DxfModel writeModel = new DxfModel();
CloneContext ct = new CloneContext(readModel, ReferenceResolutionType.CloneMissing);
TransformConfig tc = new TransformConfig();
Matrix4D translation = Transformation4D.Translation(250, 0, 0);
ct.RenameClashingBlocks = true;
for (int i = 0; i < readModel.Entities.Count; i++)
{
DxfEntity block = readModel.Entities[i];
if (block.GetType() == typeof(DxfMText))
{
DxfMText di = (DxfMText)block;
if (dictDim.ContainsKey(di.SimplifiedText))
{
di.Text = dictDim[di.SimplifiedText];
di.Width = di.BoxWidth * 2;
}
writeModel.Entities.Add(di);
}
else if (block.GetType() == typeof(DxfText))
{
DxfText di = (DxfText)block;
if (dictDim.ContainsKey(di.SimplifiedText))
{
di.Text = dictDim[di.SimplifiedText];
}
writeModel.Entities.Add(di);
}
else
{
writeModel.Entities.Add(block);
}
}
ct.ResolveReferences();
CADHelper.ExportToJpg(writeModel, destPath);
}
catch (Exception exc)
{
Tracing.Tracer.LogError(exc.Message);
Logger.For(this).Error(exc.Message);
}
}
示例11: Parse
/// <summary>
/// Mixes shader parts to produces a single HLSL file shader.
/// </summary>
/// <param name="shaderMixinSource">The shader source.</param>
/// <param name="macros">The shader perprocessor macros.</param>
/// <param name="modifiedShaders">The list of modified shaders.</param>
/// <returns>The combined shader in AST form.</returns>
public ShaderMixinParsingResult Parse(ShaderMixinSource shaderMixinSource, Paradox.Shaders.ShaderMacro[] macros = null)
{
// Creates a parsing result
HashSet<ModuleMixinInfo> mixinsToAnalyze;
ShaderMixinParsingResult parsingResult;
var context = ParseAndAnalyze(shaderMixinSource, macros, out parsingResult, out mixinsToAnalyze);
// Return directly if there was any errors
if (parsingResult.HasErrors)
return parsingResult;
// Update the clone context in case new instances of classes are created
lock (hlslCloneContext)
{
HlslSemanticAnalysis.UpdateCloneContext(hlslCloneContext);
}
// only clone once the stage classes
var mixCloneContext = new CloneContext(hlslCloneContext);
foreach (var mixinInfo in mixinsToAnalyze)
{
foreach (var mixin in mixinInfo.Mixin.MinimalContext.Where(x => x.StageOnlyClass))
{
mixin.DeepClone(mixCloneContext);
}
}
// ----------------------------------------------------------
// Perform Shader Mixer
// ----------------------------------------------------------
var externDict = new CompositionDictionary();
var finalModuleList = BuildCompositionsDictionary(shaderMixinSource, externDict, context, mixCloneContext, parsingResult);
//PerformanceLogger.Stop(PerformanceStage.DeepClone);
if (parsingResult.HasErrors)
return parsingResult;
// look for stage compositions and add the links between variables and compositions when necessary
var extraExternDict = new Dictionary<Variable, List<ModuleMixin>>();
foreach (var item in externDict)
{
if (item.Key.Qualifiers.Contains(ParadoxStorageQualifier.Stage))
FullLinkStageCompositions(item.Key, item.Value, externDict, extraExternDict, parsingResult);
}
foreach (var item in extraExternDict)
externDict.Add(item.Key, item.Value);
var mixinDictionary = BuildMixinDictionary(finalModuleList);
if (finalModuleList != null)
{
var finalModule = finalModuleList[0];
//PerformanceLogger.Start(PerformanceStage.Mix);
var mixer = new ParadoxShaderMixer(finalModule, parsingResult, mixinDictionary, externDict, new CloneContext(mixCloneContext));
mixer.Mix();
//PerformanceLogger.Stop(PerformanceStage.Mix);
// Return directly if there was any errors
if (parsingResult.HasErrors)
return parsingResult;
var finalShader = mixer.GetMixedShader();
// Simplifies the shader by removing dead code
var simplifier = new ExpressionSimplifierVisitor();
simplifier.Run(finalShader);
parsingResult.Reflection = new EffectReflection();
var pdxShaderLinker = new ShaderLinker(parsingResult);
pdxShaderLinker.Run(finalShader);
// Return directly if there was any errors
if (parsingResult.HasErrors)
return parsingResult;
// Find all entry points
// TODO: make this configurable by CompileParameters
foreach (var stage in new[] {ShaderStage.Compute, ShaderStage.Vertex, ShaderStage.Hull, ShaderStage.Domain, ShaderStage.Geometry, ShaderStage.Pixel})
{
var entryPoint = finalShader.Declarations.OfType<MethodDefinition>().FirstOrDefault(f => f.Attributes.OfType<AttributeDeclaration>().Any(a => a.Name == "EntryPoint" && (string)a.Parameters[0].Value == stage.ToString()));
if (entryPoint == null)
{
continue;
}
parsingResult.EntryPoints[stage] = entryPoint.Name.Text;
// When this is a compute shader, there is no need to scan other stages
if (stage == ShaderStage.Compute)
break;
}
//.........这里部分代码省略.........
示例12: CloneTo
protected override void CloneTo (CloneContext clonectx, Expression t)
{
CompletionMemberAccess target = (CompletionMemberAccess) t;
if (targs != null)
target.targs = targs.Clone ();
target.expr = expr.Clone (clonectx);
}
示例13: CloneTo
protected override void CloneTo (CloneContext clonectx, Expression t)
{
NullCoalescingOperator target = (NullCoalescingOperator) t;
target.left = left.Clone (clonectx);
target.right = right.Clone (clonectx);
}