Ejemplo n.º 1
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     Expr.EmitPushValue(dmObject, proc);
     proc.BinaryNot();
 }
Ejemplo n.º 2
0
 public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
 {
     return(DMReference.Args, false);
 }
Ejemplo n.º 3
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            if (dmObject.HasProc(_identifier))
            {
                return(DMReference.CreateSrcProc(_identifier), false);
            }
            else if (DMObjectTree.TryGetGlobalProc(_identifier, out _))
            {
                return(DMReference.CreateGlobalProc(_identifier), false);
            }

            throw new CompileErrorException(Location, $"Type {dmObject.Path} does not have a proc named \"{_identifier}\"");
        }
Ejemplo n.º 4
0
 public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
 {
     return(DMReference.CreateSrcField(Variable.Name), false);
 }
Ejemplo n.º 5
0
 public override void EmitPushInitial(DMObject dmObject, DMProc proc)
 {
     // This happens silently in BYOND
     DMCompiler.Warning(new CompilerWarning(Location, "calling initial() on a global returns the current value"));
     EmitPushValue(dmObject, proc);
 }
Ejemplo n.º 6
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     proc.PushPath(Value);
 }
Ejemplo n.º 7
0
 public override void EmitPushInitial(DMObject dmObject, DMProc proc)
 {
     proc.PushReferenceValue(DMReference.Src);
     proc.Initial(Variable.Name);
 }
Ejemplo n.º 8
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     P.EmitPushValue(dmObject, proc);
     proc.Prob();
 }
Ejemplo n.º 9
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     _expr.EmitPushValue(dmObject, proc);
     proc.PushPath(_path);
     proc.IsType();
 }
Ejemplo n.º 10
0
 public void EmitPushIsSaved(DMObject dmObject, DMProc proc)
 {
     _expr.EmitPushValue(dmObject, proc);
     proc.IsSaved(PropertyName);
 }
Ejemplo n.º 11
0
 public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
 {
     _expr.EmitPushValue(dmObject, proc);
     return(DMReference.CreateField(PropertyName), _conditional);
 }
Ejemplo n.º 12
0
 public override void EmitPushInitial(DMObject dmObject, DMProc proc)
 {
     _expr.EmitPushValue(dmObject, proc);
     proc.Initial(PropertyName);
 }
Ejemplo n.º 13
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            _expr.EmitPushValue(dmObject, proc);
            _index.EmitPushValue(dmObject, proc);

            return(DMReference.ListIndex, _conditional);
        }
Ejemplo n.º 14
0
 public abstract void EmitOp(DMObject dmObject, DMProc proc, DMReference reference);
Ejemplo n.º 15
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     proc.PushNull();
 }
Ejemplo n.º 16
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     throw new CompileErrorException(Location, "invalid use of arglist");
 }
Ejemplo n.º 17
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     proc.PushResource(Value);
 }
Ejemplo n.º 18
0
 public void EmitPushArglist(DMObject dmObject, DMProc proc)
 {
     _expr.EmitPushValue(dmObject, proc);
     proc.PushArgumentList();
 }
Ejemplo n.º 19
0
 internal DMVisitorExpression(DMObject dmObject, DMProc proc, DreamPath?inferredPath)
 {
     _dmObject     = dmObject;
     _proc         = proc;
     _inferredPath = inferredPath;
 }
Ejemplo n.º 20
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     Expr.EmitPushValue(dmObject, proc);
     Arguments.EmitPushArguments(dmObject, proc);
     proc.CreateObject();
 }
Ejemplo n.º 21
0
 public void EmitPushIsSaved(DMProc proc)
 {
     proc.PushReferenceValue(DMReference.Src);
     proc.IsSaved(Variable.Name);
 }
Ejemplo n.º 22
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     proc.PushPath(TargetPath);
     Arguments.EmitPushArguments(dmObject, proc);
     proc.CreateObject();
 }
Ejemplo n.º 23
0
 public void EmitPushIsSaved(DMProc proc)
 {
     throw new CompileErrorException(Location, "issaved() on globals is unimplemented");
 }
Ejemplo n.º 24
0
        public void ProcessProcDefinition(DMASTProcDefinition procDefinition)
        {
            string   procName = procDefinition.Name;
            DMObject dmObject = _currentObject;

            try {
                if (procDefinition.ObjectPath.HasValue)
                {
                    dmObject = DMObjectTree.GetDMObject(_currentObject.Path.Combine(procDefinition.ObjectPath.Value));
                }

                if (!procDefinition.IsOverride && dmObject.HasProc(procName))
                {
                    throw new CompileErrorException(procDefinition.Location, $"Type {dmObject.Path} already has a proc named \"{procName}\"");
                }

                DMProc proc = new DMProc(procDefinition);

                if (procDefinition.ObjectPath == null)
                {
                    if (DMObjectTree.TryGetGlobalProc(procDefinition.Name, out _))
                    {
                        throw new CompileErrorException(new CompilerError(procDefinition.Location, $"proc {procDefinition.Name} is already defined in global scope"));
                    }

                    DMObjectTree.AddGlobalProc(procDefinition.Name, proc);
                }
                else
                {
                    dmObject.AddProc(procName, proc);
                }

                if (procDefinition.Body != null)
                {
                    foreach (var stmt in GetStatements(procDefinition.Body))
                    {
                        // TODO multiple var definitions.
                        if (stmt is DMASTProcStatementVarDeclaration varDeclaration && varDeclaration.IsGlobal)
                        {
                            DMVariable variable = proc.CreateGlobalVariable(varDeclaration.Type, varDeclaration.Name, varDeclaration.IsConst);
                            variable.Value = new Expressions.Null(varDeclaration.Location);

                            if (varDeclaration.Value != null)
                            {
                                DMVisitorExpression._scopeMode = "static";
                                DMExpression expression = DMExpression.Create(_currentObject, DMObjectTree.GlobalInitProc, varDeclaration.Value, varDeclaration.Type);
                                DMVisitorExpression._scopeMode = "normal";
                                DMObjectTree.AddGlobalInitAssign(dmObject, proc.GetGlobalVariableId(varDeclaration.Name).Value, expression);
                            }
                        }
                    }
                }

                if (procDefinition.IsVerb && (dmObject.IsSubtypeOf(DreamPath.Atom) || dmObject.IsSubtypeOf(DreamPath.Client)) && !DMCompiler.Settings.NoStandard)
                {
                    Expressions.Field  field    = new Expressions.Field(Location.Unknown, dmObject.GetVariable("verbs"));
                    DreamPath          procPath = new DreamPath(".proc/" + procName);
                    Expressions.Append append   = new Expressions.Append(Location.Unknown, field, new Expressions.Path(Location.Unknown, procPath));

                    dmObject.InitializationProcExpressions.Add(append);
                }
            } catch (CompileErrorException e) {
                DMCompiler.Error(e.Error);
            }
        }
Ejemplo n.º 25
0
 public virtual void EmitPushInitial(DMObject dmObject, DMProc proc)
 {
     throw new CompileErrorException(Location, $"Can't get initial value of {this}");
 }
Ejemplo n.º 26
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            if (!DMObjectTree.TryGetGlobalProc(_name, out _))
            {
                throw new CompileErrorException(Location, $"There is no global proc named \"{_name}\"");
            }

            return(DMReference.CreateGlobalProc(_name), false);
        }
Ejemplo n.º 27
0
 public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
 {
     return(DMReference.CreateLocal(LocalVar.Id), false);
 }
Ejemplo n.º 28
0
 public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
 {
     if ((proc.Attributes & ProcAttributes.IsOverride) != ProcAttributes.IsOverride)
     {
         DMCompiler.Warning(new CompilerWarning(Location, "Calling parents via ..() in a proc definition does nothing"));
     }
     return(DMReference.SuperProc, false);
 }
Ejemplo n.º 29
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     throw new CompileErrorException(Location, "attempt to use proc as value");
 }
Ejemplo n.º 30
0
 public override void EmitPushValue(DMObject dmObject, DMProc proc)
 {
     Expr.EmitPushValue(dmObject, proc);
     proc.Negate();
 }