public TalDefine(Tag tag, VariableScope scope, string name, string expression) : base(tag, CommandType.TalDefine) { Scope = scope; Name = name; Expression = expression; }
public AssignStringLiteral(Int32 destinationDestIndex, VariableScope destinationDestScope, Int32 sourceIndex, VariableScope sourceScope) { m_DestIndex = destinationDestIndex; m_DestScope = destinationDestScope; m_SourceIndex = sourceIndex; m_SourceScope = sourceScope; }
public VariablesHierarchyInfoDto(VariableScope scope, int scopeID, string scopeName) { this.ScopeKey = scope.GetName(); this.ScopeID = scopeID; this.ScopeName = scopeName; this.Variables = new List<VariableDto>(); this.Children = new List<VariablesHierarchyInfoDto>(); }
public VariableResolver(IVariableStorage varStorage, AnalysisScope scope = AnalysisScope.File) { Preconditions.NotNull(varStorage, "varStorage"); this._variableStorage = varStorage; this._scope = scope; variableScope = scope == AnalysisScope.File ? VariableScope.File : VariableScope.Function; }
public static Scope Create(VariableScope scope) { return new Scope { Name = scope.Name, VariablesReference = scope.Id }; }
public AssignString(Int32 destIndex, VariableScope destScope, Expression expression) { m_DestIndex = destIndex; m_DestScope = destScope; m_Expression = expression; if (expression.ReturnType != GossipType.String) throw new GossipScriptException("Expression must return type string"); }
public MTSSetTransactionStatement(VariableScope scope, IsolationLevel level) { if (level == IsolationLevel.None) { throw new ArgumentException("isolation level is null"); } Level = level; Scope = scope; }
public AstHelper(ModuleBuilder moduleBuilder) { ModuleBuilder = moduleBuilder; Expecting = new Expecting(); Functions = new FunctionScope(); Variables = new VariableScope(); Types = new TypeScope(); Errors = new ErrorSet(); ReturnScope = new ReturnScope(); }
public LocalDefinition DefineLocal(ParameterExpression variable, int start) { VariableScope scope; VariableScope scope2; LocalVariable variable2 = new LocalVariable(this._localCount++, false, false); this._maxLocalCount = Math.Max(this._localCount, this._maxLocalCount); if (this._variables.TryGetValue(variable, out scope)) { scope2 = new VariableScope(variable2, start, scope); if (scope.ChildScopes == null) { scope.ChildScopes = new List<VariableScope>(); } scope.ChildScopes.Add(scope2); } else { scope2 = new VariableScope(variable2, start, null); } this._variables[variable] = scope2; return new LocalDefinition(variable2.Index, variable); }
/// <summary> /// Append a variable parameter encoded Int16 /// </summary> /// <param name="value">Value to append</param> /// <param name="scope">Select either global or local scope</param> /// <param name="type">Select either value or handle scope</param> public void Append(Int16 value , VariableScope scope, VariableType type){ Append(scope, type, FollowType.TwoBytes); Append (value); }
internal override void ResolveTypes(VariableScope varScope, PastelCompiler compiler) { // nothing to do }
public override JSValue Invoke(ExecutionThread thread, JSObject context, VariableScope outerScope, JSValue[] args) { return(args.Length > 0 && args[0].CastToBoolean()); }
public void LeaveSourceUnit() { Debug.Assert(_currentElement == _currentMethod && _currentVariableScope == _currentMethod); Debug.Assert(_currentLoop == null && _currentRescue == null); Debug.Assert(_currentBlock == null); _currentElement = null; _currentMethod = null; _currentVariableScope = null; }
public void EnterMethodDefinition( ScopeBuilder/*!*/ locals, MSA.Expression/*!*/ selfParameter, MSA.ParameterExpression/*!*/ runtimeScopeVariable, MSA.Expression blockParameter, string/*!*/ methodName, Parameters parameters) { Assert.NotNull(locals, selfParameter, runtimeScopeVariable); MethodScope method = new MethodScope( locals, selfParameter, runtimeScopeVariable, blockParameter, methodName, parameters ); method.Parent = _currentElement; method.ParentRescue = _currentRescue; method.ParentLoop = _currentLoop; method.ParentBlock = _currentBlock; method.ParentVariableScope = _currentVariableScope; method.ParentMethod = _currentMethod; _currentElement = method; _currentRescue = null; _currentLoop = null; _currentBlock = null; _currentVariableScope = method; _currentMethod = method; }
public List<EpiInfo.Plugin.IVariable> GetVariablesInScope(VariableScope scopeCombination) { return this.currentScope.FindVariables(scopeCombination); }
private IModel GetModel(VariableScope scope) { switch (scope) { case VariableScope.Global: return GLOBAL; case VariableScope.Model: return _model; case VariableScope.Page: return _page; case VariableScope.Request: return _session; case VariableScope.Session: return _session; case VariableScope.Tag: return _hasTags ? _tagVariables.Peek() : null; default: throw new NotImplementedException("GetModel not implemented for " + scope); } }
public override Expression ResolveTypes(ParserContext context, VariableScope varScope) { throw new NotImplementedException(); }
internal override void ResolveVariableOrigins(ParserContext parser, VariableScope varIds, VariableIdAllocPhase phase) { this.Expression.ResolveVariableOrigins(parser, varIds, phase); }
public override IList <Executable> ResolveTypes(ParserContext context, VariableScope varScope) { throw new System.NotImplementedException(); }
protected override Expr SimplifyChildren(VariableScope variables) { return(new ExpressionExpr(InnerExpression.Simplify(variables))); }
public override JSValue Invoke(ExecutionThread thread, JSObject context, VariableScope outerScope, JSValue[] args) { return(args.Length > 0 ? args[0].ToNumber() : 0); }
public override JSValue Construct(ExecutionThread thread, VariableScope outerScope, JSValue[] args) { return(VM.NewNumber(args.Length > 0 ? args[0].ToNumber() : 0)); }
internal override Expression ResolveType(VariableScope varScope, PastelCompiler compiler) { // The args were already resolved. // This ensures that they match the native function definition PType[] expectedTypes = NativeFunctionUtil.GetNativeFunctionArgTypes(this.Function); bool[] isArgRepeated = NativeFunctionUtil.GetNativeFunctionIsArgTypeRepeated(this.Function); switch (this.Function) { case NativeFunction.FORCE_PARENS: if (this.Args.Length != 1) { throw new ParserException(this.FirstToken, "Expected 1 arg."); } return(new ForcedParenthesis(this.FirstToken, this.Args[0])); case NativeFunction.IS_DEBUG: #if DEBUG bool value = true; #else bool value = false; #endif return(new InlineConstant(PType.BOOL, this.FirstToken, value)); } Dictionary <string, PType> templateLookup = new Dictionary <string, PType>(); int verificationLength = expectedTypes.Length; if (verificationLength > 0 && isArgRepeated[isArgRepeated.Length - 1]) { verificationLength--; } for (int i = 0; i < verificationLength; ++i) { if (!PType.CheckAssignmentWithTemplateOutput(expectedTypes[i], this.Args[i].ResolvedType, templateLookup)) { throw new ParserException(this.Args[i].FirstToken, "Incorrect type. Expected " + expectedTypes[i] + " but found " + this.Args[i].ResolvedType + "."); } } if (expectedTypes.Length < this.Args.Length) { if (isArgRepeated[isArgRepeated.Length - 1]) { PType expectedType = expectedTypes[expectedTypes.Length - 1]; for (int i = expectedTypes.Length; i < this.Args.Length; ++i) { if (!PType.CheckAssignment(expectedType, this.Args[i].ResolvedType)) { throw new ParserException(this.Args[i].FirstToken, "Incorrect type. Expected " + expectedTypes[i] + " but found " + this.Args[i].ResolvedType + "."); } } } else { throw new ParserException(this.FirstToken, "Too many arguments."); } } PType returnType = NativeFunctionUtil.GetNativeFunctionReturnType(this.Function); if (returnType.HasTemplates) { returnType = returnType.ResolveTemplates(templateLookup); } this.ResolvedType = returnType; return(this); }
/// <summary> /// Append a variable parameter encoded string /// </summary> /// <param name="s">String to append</param> /// <param name="scope">Select either global or local scope</param> /// <param name="type">Select either value or handle scope</param> public void Append(string s, VariableScope scope, VariableType type){ Append(scope, type, FollowType.TerminatedString2); Append (s); }
public void EnterFileInitializer( ScopeBuilder/*!*/ locals, MSA.Expression/*!*/ selfVariable, MSA.ParameterExpression/*!*/ runtimeScopeVariable) { VariableScope scope = new VariableScope(locals, selfVariable, runtimeScopeVariable); scope.Parent = _currentElement; scope.ParentVariableScope = _currentVariableScope; _currentElement = scope; _currentVariableScope = scope; }
public ResolvedVariable(VariableScope scope, int address, CType variableType) { Scope = scope; Address = address; VariableType = variableType; }
public LocalDefinition DefineLocal(ParameterExpression variable, int start) { LocalVariable result = new LocalVariable(_localCount++, false, false); _maxLocalCount = System.Math.Max(_localCount, _maxLocalCount); VariableScope existing, newScope; if (_variables.TryGetValue(variable, out existing)) { newScope = new VariableScope(result, start, existing); if (existing.ChildScopes == null) { existing.ChildScopes = new List<VariableScope>(); } existing.ChildScopes.Add(newScope); } else { newScope = new VariableScope(result, start, null); } _variables[variable] = newScope; return new LocalDefinition(result.Index, variable); }
/// <summary> /// Adds a new variable to the layer, or gets an existing one; returns it. /// </summary> /// <param name="name"></param> /// <param name="shape"></param> /// <param name="dtype"></param> /// <param name="initializer"></param> /// <param name="trainable"></param> /// <param name="synchronization"></param> /// <param name="aggregation"></param> /// <returns></returns> protected virtual IVariableV1 add_weight(string name, int[] shape, TF_DataType dtype = TF_DataType.DtInvalid, IInitializer initializer = null, bool?trainable = null, VariableSynchronization synchronization = VariableSynchronization.Auto, VariableAggregation aggregation = VariableAggregation.None) { var default_graph = ops.get_default_graph(); Graph init_graph = null; IVariableV1[] existing_variables = null; if (synchronization == VariableSynchronization.OnRead) { trainable = false; } else if (!trainable.HasValue) { trainable = true; } if (default_graph.building_function) { throw new NotImplementedException("add_weight"); } else { init_graph = default_graph; existing_variables = variables.global_variables().ToArray(); } if (dtype == TF_DataType.DtInvalid) { dtype = TF_DataType.TF_FLOAT; } _set_scope(); var reuse = built || (_reuse != null && _reuse.Value); return(tf_with(tf.variable_scope(_scope, reuse: reuse, auxiliary_name_scope: false), scope => { _current_scope = scope; return tf_with(ops.name_scope(_name_scope()), delegate { var variable = base.add_weight(name, shape, dtype: dtype, initializer: initializer, trainable: trainable, getter: (args) => tf.compat.v1.get_variable(args.Name, shape: args.Shape, dtype: args.DType, initializer: args.Initializer, trainable: args.Trainable) ); //if (init_graph != null) //var trainable_variables = variables.trainable_variables(); return variable; }); })); }
public void EnterBlockDefinition( ScopeBuilder/*!*/ locals, MSA.Expression/*!*/ bfcVariable, MSA.Expression/*!*/ selfVariable, MSA.ParameterExpression/*!*/ runtimeScopeVariable, MSA.LabelTarget/*!*/ redoLabel) { Assert.NotNull(locals, bfcVariable, selfVariable); Assert.NotNull(redoLabel); BlockScope block = new BlockScope(locals, selfVariable, runtimeScopeVariable, bfcVariable, redoLabel); block.Parent = _currentElement; block.ParentRescue = _currentRescue; block.ParentLoop = _currentLoop; block.ParentBlock = _currentBlock; block.ParentVariableScope = _currentVariableScope; _currentElement = block; _currentRescue = null; _currentLoop = null; _currentBlock = block; _currentVariableScope = block; }
internal override Expression ResolveType(VariableScope varScope, PastelCompiler compiler) { // should be resolved out by now throw new NotImplementedException(); }
public void EnterModuleDefinition( ScopeBuilder/*!*/ locals, MSA.Expression/*!*/ selfVariable, MSA.ParameterExpression/*!*/ runtimeScopeVariable, bool isSingleton) { Assert.NotNull(locals, selfVariable, runtimeScopeVariable); ModuleScope module = new ModuleScope(locals, selfVariable, runtimeScopeVariable, isSingleton); module.Parent = _currentElement; module.ParentVariableScope = _currentVariableScope; module.ParentModule = _currentModule; _currentElement = module; _currentVariableScope = module; _currentModule = module; }
public SysVarPrimary(VariableScope scope, string varText, string varTextUp) { Scope = scope; this.varText = varText; VarTextUp = varTextUp; }
public bool FindAndUpdateMainFlagValue(string checkpointId, string flagName, bool origValue, VariableScope varScope) { if (MainSaveIsEmpty) { return(false); } dynamic editingPoint = FindMainEditPoint(varScope, checkpointId); if (editingPoint != null) { // Add new flag if (origValue == false) { ((JArray)editingPoint.flags).Add(flagName); } // Remove one of the existing flags else { JToken flagToDelete = null; foreach (var flag in editingPoint.flags) { if (flag.Value == flagName) { flagToDelete = flag; } } flagToDelete.Remove(); } MainSaveChangesSaved = false; return(true); } MessageBox.Show("Could not find checkpoint with pointId " + checkpointId + "!"); return(false); }
public bool FindAndUpdateMainItemValue(string checkpointId, string itemName, bool origValue, VariableScope varScope) { if (IsFarewellCheckpoint(checkpointId)) { if (!MainSaveHasFarewellData) { return(false); } } else if (MainSaveIsEmpty) { return(false); } var itemId = _gameData.GetItemIdByName(itemName); dynamic editingPoint = FindMainEditPoint(varScope, checkpointId); if (editingPoint != null) { JArray items = editingPoint.items; int? targetIndex = null; for (int i = 0; i < items.Count; i++) { if (((JObject)items[i]).Property("storyItem").Value.ToString() == itemId) { targetIndex = i; break; } } var newOwner = IsFarewellCheckpoint(checkpointId) ? Consts.Uids.Maxine : Consts.Uids.Chloe; if (origValue == false) { if (targetIndex == null) // Add new item and make Chloe or Max the owner { var freshItem = new Dictionary <string, object>() { { "uniqueId", Guid.NewGuid().ToString() }, { "currentOwnedBy", newOwner }, { "overridesDLC", false }, { "storyItem", itemId }, { "$type", "GameStateItemModel" } }; items.Add(JToken.FromObject(freshItem)); } else //change the owner of an existing item to Chloe or Max { ((JObject)items[targetIndex]).Property("currentOwnedBy").Value = newOwner; } } // Remove one of the existing items else { items[targetIndex].Remove(); } MainSaveChangesSaved = false; return(true); } MessageBox.Show("Could not find checkpoint with pointId " + checkpointId + "!"); return(false); }
public List <EpiInfo.Plugin.IVariable> GetVariablesInScope(VariableScope scopeCombination) { return(this.currentScope.FindVariables(scopeCombination)); }
public bool FindAndUpdateFarewellVarValue(string checkpointId, string varName, object origValue, object newValue, VariableScope varScope) { if (FarewellSaveIsEmpty) { return(false); } var varId = varName == "Objective" ? varName : _gameData.GetVariableIdByName(varName); var success = false; dynamic editingPoint = FindFarewellEditPoint(varScope, checkpointId); if (editingPoint != null) { if (varName == "Objective") { editingPoint.currentObjective.Value = newValue?.ToString() ?? ""; success = true; } else { // Add new variable if (origValue == null) { var guid = Guid.NewGuid().ToString(); if (varScope == VariableScope.CurrentFarewellCheckpoint) { foreach (var variable in FarewellData.checkpoints[FarewellData.checkpoints.Count - 1].variables) { if (variable.storyVariable.Value == varId) { guid = variable.uniqueId.Value; } } } var varBody = new Dictionary <string, object> { { "uniqueId", guid }, { "storyVariable", varId }, { "overridesDLC", false }, { "currentValue", Convert.ToInt32(newValue) }, { "$type", "GameStateVariableModel" } }; var freshVar = JObject.FromObject(varBody); ((JArray)editingPoint.variables).Add(freshVar); success = true; } // Remove variable else if (newValue == null) { foreach (var variable in editingPoint.variables) { if (variable.storyVariable.Value == varId) { ((JArray)editingPoint.variables).Remove(variable); success = true; break; } } } // Change variable value else { foreach (var variable in editingPoint.variables) { if (variable.storyVariable.Value == varId) { variable.currentValue.Value = Convert.ToInt32(newValue); success = true; break; } } } } } else { MessageBox.Show("Could not find checkpoint with pointId " + checkpointId + "!"); return(false); } if (!success) { MessageBox.Show("Could not find and replace variable with ID " + varId + "!"); } else { FarewellSaveChangesSaved = false; } return(success && FindAndUpdateMainVarValue(checkpointId, varName, origValue, newValue, varScope)); }
/// <summary> /// Append a variable parameter encoded byte in long format /// </summary> /// <param name="value">Value to append</param> /// <param name="scope">Select either global or local scope</param> /// <param name="type">Select either value or handle scope</param> public void Append (byte value, VariableScope scope, VariableType type) { Append(scope, type, FollowType.OneByte); Append (value); }
protected override Expr SimplifyChildren(VariableScope variables) { return(new TypeExpr(Location, new[] { _obj.Simplify(variables) })); }
/// <summary> /// Append a variable parameter encoded Int32 /// </summary> /// <param name="value">Value to append</param> /// <param name="scope">Select either global or local scope</param> /// <param name="type">Select either value or handle scope</param> public void Append(Int32 value, VariableScope scope, VariableType type){ Append(scope, type, FollowType.FourBytes); Append(value); }
public VariableScope(LocalVariable variable, int start, VariableScope parent) { Variable = variable; Start = start; Parent = parent; }
public ShowStatus(VariableScope scope, string pattern) { Scope = scope; Pattern = pattern; Where = null; }
public void LeaveFileInitializer() { Debug.Assert(_currentElement == _currentVariableScope); VariableScope oldScope = _currentVariableScope; _currentElement = oldScope.Parent; _currentVariableScope = oldScope.ParentVariableScope; }
public ShowStatus(VariableScope scope, IExpression where) { Scope = scope; Pattern = null; Where = where; }
public IdentifierNotDefinedError(string variableName, VariableScope scope, SourceLocation location) : base(location) { _variableName = variableName; _scope = scope; }
public ShowStatus(VariableScope scope) { Scope = scope; Pattern = null; Where = null; }
// This is called when the lambda is being resolved as an expression. internal override void ResolveVariableOrigins(ParserContext parser, VariableScope varIds, VariableIdAllocPhase phase) { }
public void RemoveVariablesInScope(VariableScope varTypes) { this.currentScope.RemoveVariablesInScope(varTypes); }
public void LeaveBlockDefinition() { Debug.Assert(_currentElement == _currentBlock); BlockScope oldBlock = _currentBlock; _currentElement = oldBlock.Parent; _currentRescue = oldBlock.ParentRescue; _currentLoop = oldBlock.ParentLoop; _currentVariableScope = oldBlock.ParentVariableScope; _currentBlock = oldBlock.ParentBlock; }
internal override Expression ResolveType(VariableScope varScope, PastelCompiler compiler) { return(this); }
public void LeaveMethodDefinition() { Debug.Assert(_currentElement == _currentMethod); MethodScope oldMethod = _currentMethod; _currentElement = oldMethod.Parent; _currentRescue = oldMethod.ParentRescue; _currentLoop = oldMethod.ParentLoop; _currentBlock = oldMethod.ParentBlock; _currentVariableScope = oldMethod.ParentVariableScope; _currentMethod = oldMethod.ParentMethod; }
public override JSValue Construct(ExecutionThread thread, VariableScope outerScope, JSValue[] args) { return(VM.NewError(args.Length > 0 ? args[0].CastToString() : string.Empty)); }
public void LeaveModuleDefinition() { Debug.Assert(_currentElement == _currentModule); ModuleScope oldModule = _currentModule; _currentElement = oldModule.Parent; _currentVariableScope = oldModule.ParentVariableScope; _currentModule = oldModule.ParentModule; }
public override JSValue Invoke(ExecutionThread thread, JSObject context, VariableScope outerScope, JSValue[] args) { return(Construct(thread, outerScope, args)); }
/// <summary>first token is <code>TRANSACTION</code></summary> /// <exception cref="System.SqlSyntaxErrorException" /> private MTSSetTransactionStatement SetMTSSetTransactionStatement(VariableScope scope) { lexer.NextToken(); MatchIdentifier("ISOLATION"); MatchIdentifier("LEVEL"); SpecialIdentifier si; switch (lexer.Token()) { case MySqlToken.KwRead: { lexer.NextToken(); si = specialIdentifiers.GetValue(lexer.GetStringValueUppercase()); if (si != SpecialIdentifier.None) { switch (si) { case SpecialIdentifier.Committed: { lexer.NextToken(); return new MTSSetTransactionStatement(scope, IsolationLevel.ReadCommitted); } case SpecialIdentifier.Uncommitted: { lexer.NextToken(); return new MTSSetTransactionStatement(scope, IsolationLevel.ReadUncommitted); } } } throw Err("unknown isolation read level: " + lexer.GetStringValue()); } case MySqlToken.Identifier: { si = specialIdentifiers.GetValue(lexer.GetStringValueUppercase()); if (si != SpecialIdentifier.None) { switch (si) { case SpecialIdentifier.Repeatable: { lexer.NextToken(); Match(MySqlToken.KwRead); return new MTSSetTransactionStatement(scope, IsolationLevel.RepeatableRead); } case SpecialIdentifier.Serializable: { lexer.NextToken(); return new MTSSetTransactionStatement(scope, IsolationLevel.Serializable); } } } break; } } throw Err("unknown isolation level: " + lexer.GetStringValue()); }
public void DrawItem(Rect position, int index, bool selected, bool focused) { Variable variable = GetVarAt(index);// this[index].objectReferenceValue as Variable; if (variable == null) { return; } for (int i = 0; i < 4; ++i) { itemRects[i] = position; itemRects[i].width = itemWidths[i] - 5; for (int j = 0; j < i; ++j) { itemRects[i].x += itemWidths[j]; } } VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(variable.GetType()); if (variableInfo == null) { return; } var flowchart = TargetFlowchart; if (flowchart == null) { return; } // Highlight if an active or selected command is referencing this variable bool highlight = false; if (flowchart.SelectedBlock != null) { if (Application.isPlaying && flowchart.SelectedBlock.IsExecuting()) { highlight = flowchart.SelectedBlock.ActiveCommand.IsVariableReferenced(variable); } else if (!Application.isPlaying && flowchart.SelectedCommands.Count > 0) { foreach (Command selectedCommand in flowchart.SelectedCommands) { if (selectedCommand == null) { continue; } if (selectedCommand.IsVariableReferenced(variable)) { highlight = true; break; } } } } if (highlight) { GUI.backgroundColor = Color.green; GUI.Box(position, ""); } string key = variable.Key; VariableScope scope = variable.Scope; // To access properties in a monobehavior, you have to new a SerializedObject // http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html SerializedObject variableObject = new SerializedObject(variable); variableObject.Update(); GUI.Label(itemRects[0], variableInfo.VariableType); SerializedProperty keyProp = variableObject.FindProperty("key"); SerializedProperty defaultProp = variableObject.FindProperty("value"); SerializedProperty scopeProp = variableObject.FindProperty("scope"); EditorGUI.BeginChangeCheck(); key = EditorGUI.TextField(itemRects[1], variable.Key); if (EditorGUI.EndChangeCheck()) { keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable); } bool isGlobal = scopeProp.enumValueIndex == (int)VariableScope.Global; if (isGlobal && Application.isPlaying) { var res = FungusManager.Instance.GlobalVariables.GetVariable(keyProp.stringValue); if (res != null) { SerializedObject globalValue = new SerializedObject(res); var globalValProp = globalValue.FindProperty("value"); var prevEnabled = GUI.enabled; GUI.enabled = false; EditorGUI.PropertyField(itemRects[2], globalValProp, emptyGUIContent); GUI.enabled = prevEnabled; } } else { EditorGUI.PropertyField(itemRects[2], defaultProp, emptyGUIContent); } scope = (VariableScope)EditorGUI.EnumPopup(itemRects[3], variable.Scope); scopeProp.enumValueIndex = (int)scope; variableObject.ApplyModifiedProperties(); GUI.backgroundColor = Color.white; }
public void DrawItem(Rect position, int index) { Variable variable = this[index].objectReferenceValue as Variable; if (variable == null) { return; } float[] widths = { 80, 100, 140, 60 }; Rect[] rects = new Rect[4]; for (int i = 0; i < 4; ++i) { rects[i] = position; rects[i].width = widths[i] - 5; for (int j = 0; j < i; ++j) { rects[i].x += widths[j]; } } VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(variable.GetType()); if (variableInfo == null) { return; } Flowchart flowchart = FlowchartWindow.GetFlowchart(); if (flowchart == null) { return; } // Highlight if an active or selected command is referencing this variable bool highlight = false; if (flowchart.selectedBlock != null) { if (Application.isPlaying && flowchart.selectedBlock.IsExecuting()) { highlight = flowchart.selectedBlock.activeCommand.HasReference(variable); } else if (!Application.isPlaying && flowchart.selectedCommands.Count > 0) { foreach (Command selectedCommand in flowchart.selectedCommands) { if (selectedCommand == null) { continue; } if (selectedCommand.HasReference(variable)) { highlight = true; break; } } } } if (highlight) { GUI.backgroundColor = Color.green; GUI.Box(position, ""); } string key = variable.key; VariableScope scope = variable.scope; // To access properties in a monobehavior, you have to new a SerializedObject // http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html SerializedObject variableObject = new SerializedObject(this[index].objectReferenceValue); variableObject.Update(); GUI.Label(rects[0], variableInfo.VariableType); key = EditorGUI.TextField(rects[1], variable.key); SerializedProperty keyProp = variableObject.FindProperty("key"); keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable); SerializedProperty defaultProp = variableObject.FindProperty("value"); EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent("")); SerializedProperty scopeProp = variableObject.FindProperty("scope"); scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.scope); scopeProp.enumValueIndex = (int)scope; variableObject.ApplyModifiedProperties(); GUI.backgroundColor = Color.white; }
public override JSValue Construct(ExecutionThread thread, VariableScope outerScope, JSValue[] args) { return(VM.NewBoolean(args.Length > 0 && args[0].CastToBoolean())); }