public override void EmitPushValue(DMObject dmObject, DMProc proc) { Expr.EmitPushValue(dmObject, proc); proc.BinaryNot(); }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { return(DMReference.Args, false); }
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}\""); }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { return(DMReference.CreateSrcField(Variable.Name), false); }
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); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { proc.PushPath(Value); }
public override void EmitPushInitial(DMObject dmObject, DMProc proc) { proc.PushReferenceValue(DMReference.Src); proc.Initial(Variable.Name); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { P.EmitPushValue(dmObject, proc); proc.Prob(); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); proc.PushPath(_path); proc.IsType(); }
public void EmitPushIsSaved(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); proc.IsSaved(PropertyName); }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); return(DMReference.CreateField(PropertyName), _conditional); }
public override void EmitPushInitial(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); proc.Initial(PropertyName); }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); _index.EmitPushValue(dmObject, proc); return(DMReference.ListIndex, _conditional); }
public abstract void EmitOp(DMObject dmObject, DMProc proc, DMReference reference);
public override void EmitPushValue(DMObject dmObject, DMProc proc) { proc.PushNull(); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { throw new CompileErrorException(Location, "invalid use of arglist"); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { proc.PushResource(Value); }
public void EmitPushArglist(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); proc.PushArgumentList(); }
internal DMVisitorExpression(DMObject dmObject, DMProc proc, DreamPath?inferredPath) { _dmObject = dmObject; _proc = proc; _inferredPath = inferredPath; }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { Expr.EmitPushValue(dmObject, proc); Arguments.EmitPushArguments(dmObject, proc); proc.CreateObject(); }
public void EmitPushIsSaved(DMProc proc) { proc.PushReferenceValue(DMReference.Src); proc.IsSaved(Variable.Name); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { proc.PushPath(TargetPath); Arguments.EmitPushArguments(dmObject, proc); proc.CreateObject(); }
public void EmitPushIsSaved(DMProc proc) { throw new CompileErrorException(Location, "issaved() on globals is unimplemented"); }
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); } }
public virtual void EmitPushInitial(DMObject dmObject, DMProc proc) { throw new CompileErrorException(Location, $"Can't get initial value of {this}"); }
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); }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { return(DMReference.CreateLocal(LocalVar.Id), false); }
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); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { throw new CompileErrorException(Location, "attempt to use proc as value"); }
public override void EmitPushValue(DMObject dmObject, DMProc proc) { Expr.EmitPushValue(dmObject, proc); proc.Negate(); }