示例#1
0
        public override void EmitPushValue(DMObject dmObject, DMProc proc)
        {
            string cLabel   = proc.NewLabelName();
            string endLabel = proc.NewLabelName();

            _a.EmitPushValue(dmObject, proc);
            proc.JumpIfFalse(cLabel);
            _b.EmitPushValue(dmObject, proc);
            proc.Jump(endLabel);
            proc.AddLabel(cLabel);
            _c.EmitPushValue(dmObject, proc);
            proc.AddLabel(endLabel);
        }
示例#2
0
        public override void EmitOp(DMObject dmObject, DMProc proc, DMReference reference)
        {
            string skipLabel = proc.NewLabelName();
            string endLabel  = proc.NewLabelName();

            proc.PushReferenceValue(reference);
            proc.JumpIfTrue(skipLabel);

            RHS.EmitPushValue(dmObject, proc);
            proc.Assign(reference);
            proc.Jump(endLabel);

            proc.AddLabel(skipLabel);
            proc.PushReferenceValue(reference);
            proc.AddLabel(endLabel);
        }
示例#3
0
        public override void EmitPushValue(DMObject dmObject, DMProc proc)
        {
            string endLabel = proc.NewLabelName();

            LHS.EmitPushValue(dmObject, proc);
            proc.BooleanAnd(endLabel);
            RHS.EmitPushValue(dmObject, proc);
            proc.AddLabel(endLabel);
        }
示例#4
0
        public override void EmitPushValue(DMObject dmObject, DMProc proc)
        {
            (DMReference reference, bool conditional) = EmitReference(dmObject, proc);

            if (conditional)
            {
                string skipLabel = proc.NewLabelName();

                proc.JumpIfNullDereference(reference, skipLabel);
                proc.PushReferenceValue(reference);
                proc.AddLabel(skipLabel);
            }
            else
            {
                proc.PushReferenceValue(reference);
            }
        }
示例#5
0
        public override void EmitPushValue(DMObject dmObject, DMProc proc)
        {
            (DMReference reference, bool conditional) = LHS.EmitReference(dmObject, proc);

            if (conditional)
            {
                string nullSkipLabel = proc.NewLabelName();

                proc.JumpIfNullDereference(reference, nullSkipLabel);
                EmitOp(dmObject, proc, reference);
                proc.AddLabel(nullSkipLabel);
            }
            else
            {
                EmitOp(dmObject, proc, reference);
            }
        }
示例#6
0
        public void ProcessProcDefinition(DMASTProcDefinition procDefinition)
        {
            if (procDefinition.Body == null)
            {
                return;
            }

            foreach (DMASTDefinitionParameter parameter in procDefinition.Parameters)
            {
                string parameterName = parameter.Name;

                if (parameter.Value != null)   //Parameter has a default value
                {
                    string      afterDefaultValueCheck = _proc.NewLabelName();
                    DMReference parameterRef           = _proc.GetLocalVariableReference(parameterName);

                    //Don't set parameter to default if not null
                    _proc.PushReferenceValue(parameterRef);
                    _proc.IsNull();
                    _proc.JumpIfFalse(afterDefaultValueCheck);

                    //Set default
                    try {
                        DMExpression.Emit(_dmObject, _proc, parameter.Value, parameter.ObjectType);
                    } catch (CompileErrorException e) {
                        DMCompiler.Error(e.Error);
                    }
                    _proc.Assign(parameterRef);
                    _proc.Pop();

                    _proc.AddLabel(afterDefaultValueCheck);
                }
            }

            ProcessBlockInner(procDefinition.Body);
            _proc.ResolveLabels();
        }