Beispiel #1
0
 public override void EmitOp(DMObject dmObject, DMProc proc, DMReference reference)
 {
     proc.PushReferenceValue(reference);
     RHS.EmitPushValue(dmObject, proc);
     proc.BitShiftRight();
     proc.Assign(reference);
 }
Beispiel #2
0
        public void ProcessProcDefinition(DMASTProcDefinition procDefinition)
        {
            if (procDefinition.Body == null)
            {
                return;
            }

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

                if (!_proc.TryAddLocalVariable(parameterName, parameter.ObjectType))
                {
                    DMCompiler.Error(new CompilerError(procDefinition.Location, $"Duplicate argument \"{parameterName}\" on {procDefinition.ObjectPath}/proc/{procDefinition.Name}()"));
                    continue;
                }

                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();
        }
Beispiel #3
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);
        }
Beispiel #4
0
 public override void EmitOp(DMObject dmObject, DMProc proc, DMReference reference)
 {
     RHS.EmitPushValue(dmObject, proc);
     proc.Assign(reference);
 }