コード例 #1
0
        public void ExpressionReferenceCannotBeStored()
        {
            var methodEmitter       = GetUnsavedMethodEmitter(false, typeof(void), new Type[0]);
            var expressionReference = new ExpressionReference(typeof(string), new ConstReference("bla").ToExpression(), methodEmitter);

            expressionReference.StoreReference(null);
        }
コード例 #2
0
 public MaterialExpressionDepthFade(string name, int editorX, int editorY, ExpressionReference inOpacity, ExpressionReference fadeDistance, float opacityDefault, float fadeDistanceDefault)
     : base(name, editorX, editorY)
 {
     InOpacity           = inOpacity;
     FadeDistance        = fadeDistance;
     OpacityDefault      = opacityDefault;
     FadeDistanceDefault = fadeDistanceDefault;
 }
コード例 #3
0
 public MaterialExpressionStaticSwitch(string name, int editorX, int editorY, ExpressionReference a, ExpressionReference b, ExpressionReference value, bool defaultValue)
     : base(name, editorX, editorY)
 {
     A            = a;
     B            = b;
     Value        = value;
     DefaultValue = defaultValue;
 }
コード例 #4
0
 public MaterialExpressionComponentMask(string name, int editorX, int editorY, ExpressionReference input, bool r, bool g, bool b, bool a)
     : base(name, editorX, editorY)
 {
     Input = input;
     R     = r;
     G     = g;
     B     = b;
     A     = a;
 }
コード例 #5
0
        public MaterialNode ResolveExpressionReference(ExpressionReference reference)
        {
            if (null == reference)
            {
                return(null);
            }

            return(Children.SingleOrDefault(node => node.Name == reference.NodeName && node.IsClassOf(reference.ClassName)) as MaterialNode);
        }
コード例 #6
0
        public void Connect(ExpressionReference expression, string toUnrealNodeName, int toSlotId)
        {
            if (null == expression)
            {
                return;
            }

            Connect(expression.NodeName, toUnrealNodeName, toSlotId, ParsedPropertyBag.Empty);
        }
コード例 #7
0
        public void ExpressionReference()
        {
            var methodEmitter = GetMethodEmitter(false, typeof(string), new Type[0]);

            var expressionReference = new ExpressionReference(typeof(string), new ConstReference("bla").ToExpression(), methodEmitter);

            methodEmitter.ImplementByReturning(new ReferenceExpression(expressionReference));

            Assert.That(InvokeMethod(), Is.EqualTo("bla"));
        }
        public void TypedMethodInvocationOnValueType()
        {
            var                 method             = GetMethodEmitter(false, typeof(string), new Type[0]);
            Expression          newObject          = new InitObjectExpression(method, typeof(ValueType));
            ExpressionReference newObjectReference = new ExpressionReference(typeof(ValueType), newObject, method);

            method.ImplementByReturning(new TypedMethodInvocationExpression(newObjectReference,
                                                                            typeof(ValueType).GetMethod("Method")));

            Assert.That(InvokeMethod(), Is.EqualTo("ValueTypeMethod"));
        }
        public void TypedMethodInvocationMethodProperty()
        {
            var                 method             = GetUnsavedMethodEmitter(false, typeof(string), new Type[0]);
            Expression          newObject          = new NewInstanceExpression(typeof(ReferenceType), Type.EmptyTypes);
            ExpressionReference newObjectReference = new ExpressionReference(typeof(ReferenceType), newObject, method);

            TypedMethodInvocationExpression expression =
                new TypedMethodInvocationExpression(newObjectReference, typeof(ReferenceType).GetMethod("Method"));

            Assert.That(expression.Method, Is.EqualTo(typeof(ReferenceType).GetMethod("Method")));
        }
コード例 #10
0
        public void LoadAddressOfExpressionReference()
        {
            var methodEmitter = GetMethodEmitter(false, typeof(string), new Type[0]);

            var expressionReference = new ExpressionReference(
                typeof(StructWithMethod),
                new InitObjectExpression(methodEmitter, typeof(StructWithMethod)),
                methodEmitter);
            var addressReference = new ExpressionReference(
                typeof(StructWithMethod).MakeByRefType(),
                expressionReference.ToAddressOfExpression(),
                methodEmitter);
            var methodCall =
                new MethodInvocationExpression(addressReference, typeof(StructWithMethod).GetMethod("Method"));

            methodEmitter.ImplementByReturning(methodCall);

            Assert.That(InvokeMethod(), Is.EqualTo("StructMethod"));
        }
コード例 #11
0
        public override void ProcessNode(BslFunctionCallNode node)
        {
            ExpressionReference expressionReference = m_decompilerLookup.FunctionOpCodeLookup[node.OperationCode];

            FunctionReference functionReference;
            OperatorReference operatorReference;
            GlobalReference   globalReference;

            if ((functionReference = expressionReference as FunctionReference) != null)
            {
                if (functionReference.Function.IsOverloadedByBooleanArgument)
                {
                    node.Children.Add(new BoolValueNode(functionReference.Overload == 1));
                }
                node.Replace(new PslFunctionUsageNode(functionReference.Function, node.Children));

                foreach (NodeBase child in node.Children)
                {
                    child.VisitThis(this);
                }
            }
            else if ((operatorReference = expressionReference as OperatorReference) != null)
            {
                switch (operatorReference.Operation.Specification)
                {
                case FunctionSpecification.Begin:
                    node.Replace(new GroupingNode(node.Children));
                    foreach (NodeBase child in node.Children)
                    {
                        child.VisitThis(this);
                    }
                    break;

                case FunctionSpecification.BeginRandom:
                    ValueDiscrepancy vd = SingleValueDiscrepancySearch.Perform(node.Children);

                    if (vd != null)
                    {
                        short           typeIndex             = vd.TypeIndex;
                        string          pluralTypeName        = m_engineDefinition.GetTypeName(typeIndex);
                        List <NodeBase> randomizerExpressions = node.Children[0].Children;
                        VariableNode    iteratorParameter     = new VariableNode(pluralTypeName + "s", typeIndex, true, true, null);
                        vd.Nodes[0].Replace(new VariableReferenceValueNode(iteratorParameter, typeIndex));
                        List <NodeBase> parameters = new List <NodeBase>();
                        parameters.Add(iteratorParameter);
                        ScriptNode randomFunction = new ScriptNode("Randomize" + StringOps.CapitalizeWords(pluralTypeName), ScriptType.Random, (short)IntegralValueType.Void, randomizerExpressions);
                        m_scriptInsertionQueue.QueueInsertion(m_state.CurrentScriptIndex, randomFunction);

                        List <NodeBase> randomFunctionArguments = new List <NodeBase>();
                        randomFunctionArguments.Add(new PslArrayNode(typeIndex, vd.Nodes));

                        node.Replace(new ScriptCallNode(randomFunction, randomFunctionArguments));

                        foreach (NodeBase child in node.Children)
                        {
                            child.VisitThis(this);
                        }
                    }
                    break;

                case FunctionSpecification.If:
                    // Early recursion to identify GroupingNodes and sub Ifs before constructing conditional node
                    foreach (NodeBase child in node.Children)
                    {
                        child.VisitThis(this);
                    }

                    ConditionalConstructNode conditionalConstruct = null;

                    NodeBase     condition   = node.Children[0];
                    GroupingNode expressions = GroupingNode.MakeGrouping(node.Children[1]);

                    GroupingNode elseExpressions = null;
                    if (node.Children.Count > 2)
                    {
                        elseExpressions = GroupingNode.MakeGrouping(node.Children[2]);

                        ConditionalConstructNode embeddedIf;
                        if (elseExpressions.Children.Count == 1 && (embeddedIf = elseExpressions.Children[0] as ConditionalConstructNode) != null)
                        {
                            BoolValueNode potentialAlwaysTrueStatement = embeddedIf.Conditions[0] as BoolValueNode;
                            if (potentialAlwaysTrueStatement != null && potentialAlwaysTrueStatement.Value)
                            {
                                elseExpressions = embeddedIf.ExpressionSets[0] as GroupingNode;
                            }
                            else
                            {
                                conditionalConstruct = embeddedIf;
                                conditionalConstruct.InsertConditional(condition, expressions);
                            }
                        }
                    }

                    if (conditionalConstruct == null)
                    {
                        List <NodeBase> conditions = new List <NodeBase>();
                        conditions.Add(condition);
                        List <NodeBase> expressionSets = new List <NodeBase>();
                        expressionSets.Add(expressions);
                        conditionalConstruct = new ConditionalConstructNode(conditions, expressionSets, elseExpressions);
                    }

                    node.Replace(conditionalConstruct);
                    break;

                case FunctionSpecification.Cond:
                    throw new NeedMoreResearchException("How does cond look in compiled form - how are its children mapped out?");

                //node.Replace(new ConditionalConstructNode());
                //break;
                default:
                    List <NodeBase> children = node.Children;
                    node.Replace(new PslOperatorUsageNode(operatorReference.Operation, children));
                    foreach (NodeBase child in children)
                    {
                        child.VisitThis(this);
                    }
                    break;
                }
            }
            else if ((globalReference = expressionReference as GlobalReference) != null)
            {
                switch (globalReference.Method)
                {
                case GlobalReference.AccessMethod.Get:
                    node.Replace(new PslGameGlobalReferenceNode(globalReference.Global));
                    break;

                case GlobalReference.AccessMethod.Set:
                    List <NodeBase> operands = new List <NodeBase>();
                    operands.Add(new PslGameGlobalReferenceNode(globalReference.Global));
                    operands.Add(node.Children[0]);
                    node.Replace(new PslOperatorUsageNode(m_engineDefinition.SpecificFunctions[(int)FunctionSpecification.Set], operands));

                    operands[1].VisitThis(this);
                    break;
                }
            }
            else if (expressionReference is CasterReference)
            {
                node.Replace(node.Children[0]);
                node.Children[0].VisitThis(this);
            }
        }
 public MaterialExpressionMaterialFunctionCall(string name, int editorX, int editorY, ExpressionReference materialFunction, ParsedPropertyBag[] functionInputs)
     : base(name, editorX, editorY)
 {
     MaterialFunction = materialFunction;
     FunctionInputs   = functionInputs;
 }