// ------------------------------------------------------------------------- /// Returns list of nodes required for code generation /// /// @param node Root node from which the code will be generated. /// CodeBase[] GetFunctionBodyParts(iCS_EditorObject node) { var code = new List <CodeBase>(); node.ForEachChildRecursiveDepthFirst( vsObj => { if (Context.IsInError(vsObj.InstanceId)) { Debug.LogWarning("iCanScript: Code not generated for node in Error: " + VSObject.FullName); return; } if (IsFieldOrPropertyGet(vsObj)) { code.Add(new GetPropertyCallDefinition(vsObj, this)); } else if (IsFieldOrPropertySet(vsObj)) { code.Add(new SetPropertyCallDefinition(vsObj, this)); } else if (vsObj.IsKindOfFunction && !vsObj.IsConstructor) { code.Add(new FunctionCallDefinition(vsObj, this)); } else if (vsObj.IsConstructor && !AreAllInputsConstant(vsObj)) { code.Add(new ConstructorDefinition(vsObj, this)); } else if (vsObj.IsInlineCode) { code.Add(new InlineCodeDefinition(vsObj, this)); } else if (vsObj.IsTriggerPort) { if (ShouldGenerateTriggerCode(vsObj)) { var triggerSet = new TriggerSetDefinition(vsObj, this); var triggerVariable = new TriggerVariableDefinition(vsObj, this, triggerSet); code.Add(triggerVariable); code.Add(triggerSet); } } else if (vsObj.IsOutDataPort && vsObj.ParentNode == node) { var portVariable = Context.GetCodeFor(vsObj); if (portVariable != null) { var producerPort = GraphInfo.GetProducerPort(vsObj); if (producerPort != null) { var consumerCode = new VariableReferenceDefinition(vsObj, this); var producerCode = new VariableReferenceDefinition(producerPort, this); code.Add(new AssignmentDefinition(this, consumerCode, producerCode)); } } } } ); return(code.ToArray()); }
// =================================================================== // INFORMATION GATHERING FUNCTIONS // ------------------------------------------------------------------- /// Builds an output parameter definition. /// /// @param port The VS port producing the data. /// @param parent The parent code context. /// @return The newly created reference. /// public TriggerVariableDefinition(iCS_EditorObject port, CodeBase parent, TriggerSetDefinition triggerSet) : base(port, parent, AccessSpecifier.Private, ScopeSpecifier.NonStatic) { myTriggerSet = triggerSet; }