本文整理汇总了C#中FunctionDefinition类的典型用法代码示例。如果您正苦于以下问题:C# FunctionDefinition类的具体用法?C# FunctionDefinition怎么用?C# FunctionDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionDefinition类属于命名空间,在下文中一共展示了FunctionDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PackageItemRootViewModel
public PackageItemRootViewModel(FunctionDefinition def)
{
this.Height = 32;
this.DependencyType = DependencyType.CustomNode;
this.Definition = def;
this.BuildDependencies(new HashSet<object>());
}
开发者ID:kentvv,项目名称:Dynamo,代码行数:7,代码来源:PackageItemRootViewModel.cs
示例2: CreateFibFunction
/// <summary>
/// Creates the fibonacci function
/// </summary>
private static Function CreateFibFunction(Win64Container container, bool optimize = false)
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var def = new FunctionDefinition("fib", Enumerable.Repeat(intType, 1).ToList(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 1));
instructions.Add(new Instruction(OpCodes.BranchGreaterThan, 5));
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
instructions.Add(new Instruction(OpCodes.Ret));
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 2));
instructions.Add(new Instruction(OpCodes.SubInt));
instructions.Add(new Instruction(OpCodes.Call, "fib", Enumerable.Repeat(intType, 1).ToList()));
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 1));
instructions.Add(new Instruction(OpCodes.SubInt));
instructions.Add(new Instruction(OpCodes.Call, "fib", Enumerable.Repeat(intType, 1).ToList()));
instructions.Add(new Instruction(OpCodes.AddInt));
instructions.Add(new Instruction(OpCodes.Ret));
return new Function(def, instructions, new List<VMType>())
{
Optimize = optimize
};
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:34,代码来源:Program.cs
示例3: CompileFunction
public static FScheme.Expression CompileFunction( FunctionDefinition definition )
{
IEnumerable<string> ins = new List<string>();
IEnumerable<string> outs = new List<string>();
return CompileFunction(definition, ref ins, ref outs);
}
开发者ID:romeo08437,项目名称:Dynamo,代码行数:7,代码来源:CustomNodeLoader.cs
示例4: CreateLoopCallAdd
/// <summary>
/// Creates a loop call add function
/// </summary>
private static Function CreateLoopCallAdd(Win64Container container, int count, bool optimize = false)
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var def = new FunctionDefinition("main", new List<VMType>(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadInt, count));
instructions.Add(new Instruction(OpCodes.StoreLocal, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 1));
instructions.Add(new Instruction(OpCodes.LoadLocal, 1));
instructions.Add(new Instruction(OpCodes.Call, "add", Enumerable.Repeat(intType, 2).ToList()));
instructions.Add(new Instruction(OpCodes.StoreLocal, 1));
instructions.Add(new Instruction(OpCodes.LoadLocal, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 1));
instructions.Add(new Instruction(OpCodes.SubInt));
instructions.Add(new Instruction(OpCodes.StoreLocal, 0));
instructions.Add(new Instruction(OpCodes.LoadLocal, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 0));
instructions.Add(new Instruction(OpCodes.BranchGreaterThan, 2));
instructions.Add(new Instruction(OpCodes.LoadLocal, 1));
instructions.Add(new Instruction(OpCodes.Ret));
return new Function(def, instructions, new List<VMType>() { intType, intType })
{
Optimize = optimize
};
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:36,代码来源:Program.cs
示例5: AddFunction
/// <summary>
/// Creates a add function with that takes the given amount of arguments
/// </summary>
/// <param name="container">The container</param>
/// <param name="numArgs">The number of arguments</param>
public static Function AddFunction(Win64Container container, int numArgs)
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var parameters = new List<VMType>();
for (int i = 0; i < numArgs; i++)
{
parameters.Add(intType);
}
var def = new FunctionDefinition("add", parameters, intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
for (int i = 1; i < numArgs; i++)
{
instructions.Add(new Instruction(OpCodes.LoadArgument, i));
instructions.Add(new Instruction(OpCodes.AddInt));
}
instructions.Add(new Instruction(OpCodes.Ret));
return new Function(def, instructions, new List<VMType>());
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:30,代码来源:TestProgramGenerator.cs
示例6: TestLocals1
public void TestLocals1()
{
using (var container = new Win64Container())
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var funcDef = new FunctionDefinition("main", new List<VMType>(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadInt, 100));
instructions.Add(new Instruction(OpCodes.StoreLocal, 0));
instructions.Add(new Instruction(OpCodes.LoadInt, 200));
instructions.Add(new Instruction(OpCodes.StoreLocal, 1));
instructions.Add(new Instruction(OpCodes.LoadInt, 300));
instructions.Add(new Instruction(OpCodes.StoreLocal, 2));
instructions.Add(new Instruction(OpCodes.LoadInt, 400));
instructions.Add(new Instruction(OpCodes.StoreLocal, 3));
instructions.Add(new Instruction(OpCodes.LoadLocal, 3));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(funcDef, instructions, Enumerable.Repeat(intType, 4).ToList());
container.LoadAssembly(Assembly.SingleFunction(func));
Assert.AreEqual(400, container.Execute());
}
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:29,代码来源:TestLocals.cs
示例7: CreateFunction
public override Function CreateFunction(
IEnumerable<string> inputs,
IEnumerable<string> outputs,
FunctionDefinition functionDefinition)
{
if (functionDefinition.WorkspaceModel.Nodes.Any(x => x is RevitTransactionNode)
|| functionDefinition.Dependencies.Any(d => d.WorkspaceModel.Nodes.Any(x => x is RevitTransactionNode)))
{
return new FunctionWithRevit(inputs, outputs, functionDefinition);
}
return base.CreateFunction(inputs, outputs, functionDefinition);
}
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:12,代码来源:DynamoRevitViewModel.cs
示例8: dynFunction
public dynFunction(IEnumerable<string> inputs, IEnumerable<string> outputs, FunctionDefinition def)
: base(def.FunctionId.ToString())
{
_def = def;
//Set inputs and output
SetInputs(inputs);
foreach (var output in outputs)
OutPortData.Add(new PortData(output, "function output", typeof (object)));
RegisterAllPorts();
ArgumentLacing = LacingStrategy.Disabled;
}
开发者ID:romeo08437,项目名称:Dynamo,代码行数:14,代码来源:dynFunction.cs
示例9: FromSPAGS
public FunctionDefinition FromSPAGS(SPAGS.Function spagsFunc)
{
FunctionDefinition jsFunc = new FunctionDefinition();
for (int i = 0; i < spagsFunc.ParameterVariables.Count; i++)
{
SPAGS.Parameter spagsParam = spagsFunc.ParameterVariables[i];
Variable p = new Variable(spagsParam.Name, GetValueTypes(spagsParam.Type));
AddReference(spagsParam, p);
jsFunc.Parameters.Add(p);
}
foreach (SPAGS.Statement statement in spagsFunc.Body.ChildStatements)
{
jsFunc.Body.Add(FromSPAGS(spagsFunc, statement, jsFunc.Body));
}
return jsFunc;
}
开发者ID:duncanc,项目名称:Red-Herring-Farm,代码行数:16,代码来源:SPAGSConverter.cs
示例10: TestMul
public void TestMul()
{
using (var container = new Win64Container())
{
var floatType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Float);
var funcDef = new FunctionDefinition("floatMain", new List<VMType>(), floatType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadFloat, 2.5f));
instructions.Add(new Instruction(OpCodes.LoadFloat, 1.35f));
instructions.Add(new Instruction(OpCodes.MulFloat));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(funcDef, instructions, new List<VMType>());
container.LoadAssembly(Assembly.SingleFunction(func));
Assert.AreEqual(2.5f * 1.35f, ExecuteFloatProgram(container), 1E-4);
}
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:19,代码来源:TestFloat.cs
示例11: TestMul
public void TestMul()
{
using (var container = new Win64Container())
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var funcDef = new FunctionDefinition("main", new List<VMType>(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadInt, 2));
instructions.Add(new Instruction(OpCodes.LoadInt, 3));
instructions.Add(new Instruction(OpCodes.MulInt));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(funcDef, instructions, new List<VMType>());
container.LoadAssembly(Assembly.SingleFunction(func));
Assert.AreEqual(6, container.Execute());
}
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:19,代码来源:TestInt.cs
示例12: TestFloatDefaultValue
public void TestFloatDefaultValue()
{
using (var container = new Win64Container())
{
var floatType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Float);
var funcDef = new FunctionDefinition("floatMain", new List<VMType>(), floatType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadLocal, 0));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(funcDef, instructions, Enumerable.Repeat(floatType, 1).ToList());
container.LoadAssembly(Assembly.SingleFunction(func));
container.VirtualMachine.Compile();
var mainFunc = Marshal.GetDelegateForFunctionPointer<FloatMain>(
container.VirtualMachine.Binder.GetFunction("floatMain()").EntryPoint);
Assert.AreEqual(0.0f, mainFunc());
}
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:21,代码来源:TestLocals.cs
示例13: DefinitionOrder
public void DefinitionOrder()
{
using (var container = new Win64Container())
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var assemblyFunctions = new List<Function>();
Action testFn = () =>
{
var def = new FunctionDefinition("test", new List<VMType>(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadInt, 1));
instructions.Add(new Instruction(OpCodes.LoadInt, 2));
instructions.Add(new Instruction(OpCodes.AddInt));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(def, instructions, new List<VMType>());
assemblyFunctions.Add(func);
};
Action mainFn = () =>
{
var def = new FunctionDefinition("main", new List<VMType>(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.Call, "test", new List<VMType>()));
instructions.Add(new Instruction(OpCodes.Ret));
var func = new Function(def, instructions, new List<VMType>());
assemblyFunctions.Add(func);
};
mainFn();
testFn();
container.LoadAssembly(new Assembly(assemblyFunctions));
Assert.AreEqual(3, container.Execute());
}
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:40,代码来源:TestCalls.cs
示例14: CreateAddFunction
/// <summary>
/// Creates an add function with that takes the given amount of arguments
/// </summary>
private static Function CreateAddFunction(Win64Container container, int numArgs, bool optimize = false)
{
var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);
var def = new FunctionDefinition("add", Enumerable.Repeat(intType, numArgs).ToList(), intType);
var instructions = new List<Instruction>();
instructions.Add(new Instruction(OpCodes.LoadArgument, 0));
for (int i = 1; i < numArgs; i++)
{
instructions.Add(new Instruction(OpCodes.LoadArgument, i));
instructions.Add(new Instruction(OpCodes.AddInt));
}
instructions.Add(new Instruction(OpCodes.Ret));
return new Function(def, instructions, new List<VMType>())
{
Optimize = optimize
};
}
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:25,代码来源:Program.cs
示例15: dynFunction
public dynFunction(IEnumerable<string> inputs, IEnumerable<string> outputs, FunctionDefinition def)
: base(def.FunctionId.ToString())
{
_def = def;
//Set inputs and output
SetInputs(inputs);
foreach (var output in outputs)
OutPortData.Add(new PortData(output, "function output", typeof(object)));
//Setup double-click behavior
NodeUI.MouseDoubleClick += delegate
{
Controller.ViewCustomNodeWorkspace(_def);
};
((DropShadowEffect)NodeUI.elementRectangle.Effect).Opacity = 1;
((DropShadowEffect)NodeUI.elementRectangle.Effect).Color = Colors.WhiteSmoke;
((DropShadowEffect) NodeUI.elementRectangle.Effect).BlurRadius = 20;
((DropShadowEffect)NodeUI.elementRectangle.Effect).ShadowDepth = 0;
NodeUI.RegisterAllPorts();
}
开发者ID:hippo811028,项目名称:Dynamo,代码行数:23,代码来源:dynFunction.cs
示例16: IsUnderPackageControl
public bool IsUnderPackageControl(FunctionDefinition def)
{
return IsUnderPackageControl(def.WorkspaceModel.FileName);
}
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:4,代码来源:PackageLoader.cs
示例17: GetOwnerPackage
public Package GetOwnerPackage(FunctionDefinition def)
{
return GetOwnerPackage(def.WorkspaceModel.FileName);
}
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:4,代码来源:PackageLoader.cs
示例18: Add
/// <summary>
/// Adds a parameter to the definition of this external function with the given
/// name, type and linkage. Parameters must be added in the exact order in which
/// they are defined in the external function.
/// </summary>
/// <param name="name">The parameter name.</param>
/// <param name="type">A SymType representing the parameter type.</param>
/// <param name="linkage">A SymLinkage representing the parameter linkage.</param>
/// <param name="include">Specifies whether this parameter should be included in ParametersNode.</param>
public void Add(string name, SymType type, SymLinkage linkage, bool include = true)
{
FunctionDefinition definition = new FunctionDefinition();
definition.Name = name;
definition.Symbol = new Symbol(name, new SymFullType(type), SymClass.VAR, null, 0);
definition.Symbol.Linkage = linkage;
definition.Include = include;
_definitions.Add(definition);
_paramList.Add(name);
}
开发者ID:stevewpalmer,项目名称:jcom,代码行数:19,代码来源:extfunc.cs
示例19: CreateFunction
public virtual Function CreateFunction(IEnumerable<string> inputs, IEnumerable<string> outputs,
FunctionDefinition functionDefinition)
{
return new Function(inputs, outputs, functionDefinition);
}
开发者ID:kscalvin,项目名称:Dynamo,代码行数:5,代码来源:DynamoViewModel.cs
示例20: FocusCustomNodeWorkspace
/// <summary>
/// Change the currently visible workspace to a custom node's workspace
/// </summary>
/// <param name="symbol">The function definition for the custom node workspace to be viewed</param>
internal void FocusCustomNodeWorkspace(FunctionDefinition symbol)
{
if (symbol == null)
{
throw new Exception("There is a null function definition for this node.");
}
if (_model.CurrentWorkspace is CustomNodeWorkspaceModel)
{
var customNodeWorkspace = _model.CurrentWorkspace as CustomNodeWorkspaceModel;
if (customNodeWorkspace.FunctionDefinition.FunctionId
== symbol.WorkspaceModel.FunctionDefinition.FunctionId)
{
return;
}
}
var newWs = symbol.WorkspaceModel;
if (!this._model.Workspaces.Contains(newWs))
this._model.Workspaces.Add(newWs);
CurrentSpaceViewModel.CancelActiveState();
_model.CurrentWorkspace = newWs;
_model.CurrentWorkspace.OnDisplayed();
//set the zoom and offsets events
var vm = dynSettings.Controller.DynamoViewModel.Workspaces.First(x => x.Model == newWs);
vm.OnCurrentOffsetChanged(this, new PointEventArgs(new Point(newWs.X, newWs.Y)));
vm.OnZoomChanged(this, new ZoomEventArgs(newWs.Zoom));
}
开发者ID:kscalvin,项目名称:Dynamo,代码行数:36,代码来源:DynamoViewModel.cs
注:本文中的FunctionDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论