void IBescriptedPropertyGroup.Initialize(GlobalRuntimeContext globalContext) { scriptObject = ScriptParser.LexAndParseScript( script: Script, new FunctionSignature( identifier: "Initialize", returnType: typeof(int)), new FunctionSignature( identifier: "Step", returnType: typeof(int), arguments: new VariableData("lastTrialCorrect", typeof(bool))), new FunctionSignature( identifier: "End", returnType: typeof(bool)), new FunctionSignature( identifier: "CalculateThreshold", returnType: typeof(double))); context = scriptObject.PrepareScript(globalContext); }
void IBescriptedPropertyGroup.Initialize(GlobalRuntimeContext globalContext) { scriptObject = ScriptParser.LexAndParseScript( script: Script, new FunctionSignature( identifier: "Initialize", returnType: typeof(void)), new FunctionSignature( identifier: "GetValue", returnType: typeof(double), arguments: new VariableData("stepNumber", typeof(int))), new FunctionSignature( identifier: "CouldStepTo", returnType: typeof(bool), arguments: new VariableData("stepNumber", typeof(int))), new FunctionSignature( identifier: "CalculateThreshold", returnType: typeof(double), arguments: new VariableData("stepValue", typeof(double)))); context = scriptObject.PrepareScript(globalContext); }
void IBescriptedPropertyGroup.UpdateStateVarRectifier(InputRectificationContainer rectifier) { Script scriptObject = ScriptParser.LexAndParseScript( script: Script, new FunctionSignature( identifier: "Initialize", returnType: typeof(void)), new FunctionSignature( identifier: "GetValue", returnType: typeof(double), arguments: new VariableData("stepNumber", typeof(int))), new FunctionSignature( identifier: "CouldStepTo", returnType: typeof(bool), arguments: new VariableData("stepNumber", typeof(int))), new FunctionSignature( identifier: "CalculateThreshold", returnType: typeof(double), arguments: new VariableData("stepValue", typeof(double)))); foreach (KeyInfo keyInfo in scriptObject.GetDeclarations()) { //Mark output if (rectifier.unsatisfiedVariables.Contains(keyInfo.key)) { rectifier.unsatisfiedVariables.Remove(keyInfo.key); } if (rectifier.typeMapping.ContainsKey(keyInfo.key)) { if (keyInfo.valueType != rectifier.typeMapping[keyInfo.key].valueType) { throw new KeyMismatchException( keyName: keyInfo.key, keyPath: "Script", desiredType: keyInfo.valueType, encounteredType: rectifier.typeMapping[keyInfo.key].valueType, message: $"Variable {keyInfo.key} of type {keyInfo.valueType.Name} mismatched existing variable of type {rectifier.typeMapping[keyInfo.key].valueType.Name}"); } } else { rectifier.typeMapping.Add(keyInfo.key, keyInfo); } } foreach (KeyInfo keyInfo in scriptObject.GetDependencies()) { //Mark requirements if (!rectifier.unsatisfiedVariables.Contains(keyInfo.key)) { rectifier.unsatisfiedVariables.Add(keyInfo.key); } if (rectifier.typeMapping.ContainsKey(keyInfo.key)) { if (keyInfo.valueType != rectifier.typeMapping[keyInfo.key].valueType) { throw new KeyMismatchException( keyName: keyInfo.key, keyPath: "Script", desiredType: keyInfo.valueType, encounteredType: rectifier.typeMapping[keyInfo.key].valueType, message: $"Variable {keyInfo.key} of type {keyInfo.valueType.Name} mismatched existing variable of type {rectifier.typeMapping[keyInfo.key].valueType.Name}"); } } else { rectifier.typeMapping.Add(keyInfo.key, keyInfo); } } }