BadScript 2
Loading...
Searching...
No Matches
BadInteropFunction.cs
Go to the documentation of this file.
6
8
13{
17 private readonly Func<BadExecutionContext, BadObject[], BadObject> m_Func;
18
23
33 BadWordToken? name,
34 Func<BadObject[], BadObject> func,
35 bool isStatic,
36 BadClassPrototype returnType,
37 params BadFunctionParameter[] parameters) : base(name, false, isStatic, returnType, false,parameters)
38 {
39 m_Func = (_, args) => func(args);
40 }
41
42
52 BadWordToken? name,
54 bool isStatic,
55 BadClassPrototype returnType,
56 params BadFunctionParameter[] parameters) : base(name, false, isStatic, returnType,false, parameters)
57 {
58 m_Func = func;
59 }
60
63
70 {
71 _metaData = metaData;
72
73 return this;
74 }
75
76
85 Func<BadObject[], BadObject> func,
86 bool isStatic,
87 BadClassPrototype returnType,
88 params string[] names)
89 {
91 null,
92 func,
93 isStatic,
94 returnType,
95 names.Select(x => (BadFunctionParameter)x).ToArray()
96 );
97
98 return function;
99 }
100
101
103 protected override IEnumerable<BadObject> InvokeBlock(BadObject[] args, BadExecutionContext caller)
104 {
105 CheckParameters(args, caller);
106
107 yield return m_Func.Invoke(caller, args);
108 }
109}
Implements a Meta Data container for an expression.
static readonly BadMetaData Empty
An empty Meta Data object.
The Execution Context. Every execution of a script needs a context the script is running in....
Interop Function taking an array of arguments.
BadInteropFunction(BadWordToken? name, Func< BadObject[], BadObject > func, bool isStatic, BadClassPrototype returnType, params BadFunctionParameter[] parameters)
Creates a new BadInteropFunction.
BadMetaData? _metaData
Contains meta data for this function.
static BadInteropFunction Create(Func< BadObject[], BadObject > func, bool isStatic, BadClassPrototype returnType, params string[] names)
Creates a new BadInteropFunction.
BadInteropFunction SetMetaData(BadMetaData metaData)
Sets the MetaData for this Function.
override IEnumerable< BadObject > InvokeBlock(BadObject[] args, BadExecutionContext caller)
BadInteropFunction(BadWordToken? name, Func< BadExecutionContext, BadObject[], BadObject > func, bool isStatic, BadClassPrototype returnType, params BadFunctionParameter[] parameters)
Creates a new BadInteropFunction.
readonly Func< BadExecutionContext, BadObject[], BadObject > m_Func
The Function Lambda.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Implements a function that can be called from the script.
void CheckParameters(BadObject[] args, BadExecutionContext caller, BadSourcePosition? position=null)
Checks Parameters for the given function call.
Implements a Class Prototype for the BadScript Language.
Contains the Parser for the BadScript2 Language.
Contains the Reader Tokens for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Runtime Objects.
Definition BadArray.cs:10