void Update() { if (importer[0].pipline != null) { //export var _variableName = VariableName.ToString() + "_" + id.ToString(); var _variableType = VariableData.VariableType.float1; exporter[0].exportVariable = new VariableData(_variableName, _variableType); var if_c = string.Empty; if (toggle[0].isOn) { if_c = "<"; } else if (toggle[1].isOn) { if_c = "=="; } else if (toggle[2].isOn) { if_c = ">"; } actionString = exporter[0].exportVariable.VariableType2string(_variableType) + " " + _variableName + " = (" + importer[0].importVariable.variableName + " " + if_c + " " + importer[1].importVariable.variableName + "); \n"; } }
public UndefinedVariable(VariableName varName) : base("Variable " + varName.ToString() + " is undefined in this context") { }
/// <summary> /// Emits IL instructions that unset an instance field. /// </summary> /// <remarks> /// Nothing is expected on the evaluation stack. Nothing is left on the evaluation stack. /// </remarks> private void EmitUnsetField(CodeGenerator /*!*/ codeGenerator) { ILEmitter il = codeGenerator.IL; DirectVarUse direct_instance = isMemberOf as DirectVarUse; if (direct_instance != null && direct_instance.VarName.IsThisVariableName) { // $this->a switch (codeGenerator.LocationStack.LocationType) { case LocationTypes.GlobalCode: { // load $this from one of Main's arguments and check for null Label this_non_null = il.DefineLabel(); codeGenerator.EmitLoadSelf(); il.Emit(OpCodes.Brtrue_S, this_non_null); codeGenerator.EmitPhpException(Methods.PhpException.ThisUsedOutOfObjectContext); il.Emit(OpCodes.Br, codeGenerator.ChainBuilder.ErrorLabel); il.MarkLabel(this_non_null, true); // call UnsetProperty codeGenerator.EmitLoadSelf(); il.Emit(OpCodes.Ldstr, varName.ToString()); // TODO codeGenerator.EmitLoadClassContext(); il.EmitCall(OpCodes.Call, Methods.Operators.UnsetProperty, null); return; } case LocationTypes.FunctionDecl: { // always throws error codeGenerator.EmitPhpException(Methods.PhpException.ThisUsedOutOfObjectContext); il.Emit(OpCodes.Br, codeGenerator.ChainBuilder.ErrorLabel); break; } case LocationTypes.MethodDecl: { CompilerLocationStack.MethodDeclContext context = codeGenerator.LocationStack.PeekMethodDecl(); if (context.Method.IsStatic) { // always throws error codeGenerator.EmitPhpException(Methods.PhpException.ThisUsedOutOfObjectContext); il.Emit(OpCodes.Br, codeGenerator.ChainBuilder.ErrorLabel); } else { DProperty property; if (context.Type.GetProperty(varName, context.Type, out property) == GetMemberResult.OK && !property.IsStatic) { // ask the DProperty to emit its unsetting code property.EmitUnset(codeGenerator, IndexedPlace.ThisArg, null, false); } else { // unable to resolve the field -> call UnsetProperty codeGenerator.EmitLoadSelf(); il.Emit(OpCodes.Ldstr, varName.ToString()); codeGenerator.EmitLoadClassContext(); il.EmitCall(OpCodes.Call, Methods.Operators.UnsetProperty, null); } } } break; } } else { // call UnsetProperty isMemberOf.Emit(codeGenerator); il.Emit(OpCodes.Ldstr, varName.ToString()); codeGenerator.EmitLoadClassContext(); il.EmitCall(OpCodes.Call, Methods.Operators.UnsetProperty, null); } }
/// <summary> /// Creates the snapshot entry for the given variable name. /// </summary> /// <param name="name">The name of control variable.</param> /// <param name="global">Determines whether variable is global or local.</param> /// <param name="callLevel">The call level.</param> /// <returns>New snapshot entry for the given variable name.</returns> internal static ReadWriteSnapshotEntryBase CreateControlEntry(VariableName name, GlobalContext global, int callLevel) { MemoryPath path = MemoryPath.MakePathControl(new string[] { name.ToString() }, global, callLevel); return(new SnapshotEntry(path)); }
/// <summary> /// Returns 'FieldInfo' representing field in AutoGlobals for given global variable name. /// </summary> internal static FieldInfo GetFieldForVariable(VariableName name) { switch (name.ToString()) { case AutoGlobals.CookieName: return Fields.AutoGlobals.Cookie; case AutoGlobals.EnvName: return Fields.AutoGlobals.Env; case AutoGlobals.FilesName: return Fields.AutoGlobals.Files; case AutoGlobals.GetName: return Fields.AutoGlobals.Get; case AutoGlobals.GlobalsName: return Fields.AutoGlobals.Globals; case AutoGlobals.PostName: return Fields.AutoGlobals.Post; case AutoGlobals.RequestName: return Fields.AutoGlobals.Request; case AutoGlobals.ServerName: return Fields.AutoGlobals.Server; case AutoGlobals.SessionName: return Fields.AutoGlobals.Session; case AutoGlobals.HttpRawPostDataName: return Fields.AutoGlobals.HttpRawPostData; default: return null; } }
/// <summary> /// Returns 'FieldInfo' representing field in AutoGlobals for given global variable name. /// </summary> internal static FieldInfo GetFieldForVariable(VariableName name) { switch (name.ToString()) { case AutoGlobals.GlobalsName: return Fields.AutoGlobals.Globals; case AutoGlobals.CanvasName: return Fields.AutoGlobals.Canvas; case AutoGlobals.AddrName: return Fields.AutoGlobals.Addr; default: return null; } }
void Update() { if (importer.TrueForAll(x => x.pipline != null) && exporter[0].pipline != null) { //export var variableType = VariableData.VariableType.float1; exporter[0].exportVariable = new VariableData(VariableName.ToString() + "_" + id.ToString(), variableType); actionString = exporter[0].exportVariable.VariableType2string(variableType) + " " + VariableName.ToString() + "_" + id.ToString() + " = distance(" + importer[0].importVariable.variableName + "," + importer[1].importVariable.variableName + "); \n"; } }