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 Func<BadObject[], BadObject> func,
34 bool isStatic,
35 BadClassPrototype returnType,
36 params BadFunctionParameter[] parameters) : base(name,
37 false,
38 isStatic,
39 returnType,
40 false,
41 parameters
42 )
43 {
44 m_Func = (_, args) => func(args);
45 }
46
47
58 bool isStatic,
59 BadClassPrototype returnType,
60 params BadFunctionParameter[] parameters) : base(name,
61 false,
62 isStatic,
63 returnType,
64 false,
65 parameters
66 )
67 {
68 m_Func = func;
69 }
70
73
80 {
81 _metaData = metaData;
82
83 return this;
84 }
85
86
94 public static BadInteropFunction Create(Func<BadObject[], BadObject> func,
95 bool isStatic,
96 BadClassPrototype returnType,
97 params string[] names)
98 {
99 BadInteropFunction function = new BadInteropFunction(null,
100 func,
101 isStatic,
102 returnType,
103 names.Select(x => (BadFunctionParameter)x)
104 .ToArray()
105 );
106
107 return function;
108 }
109
110
112 protected override IEnumerable<BadObject> InvokeBlock(BadObject[] args, BadExecutionContext caller)
113 {
114 CheckParameters(args, caller);
115
116 yield return m_Func.Invoke(caller, args);
117 }
118}
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