示例#1
0
void freeObject(Object* obj) {
  switch (obj->kind) {
  case OBJ_CONSTANT:
    free(obj->constAttrs->value);
    free(obj->constAttrs);
    break;
  case OBJ_TYPE:
    free(obj->typeAttrs->actualType);
    free(obj->typeAttrs);
    break;
  case OBJ_VARIABLE:
    free(obj->varAttrs->type);
    free(obj->varAttrs);
    break;
  case OBJ_FUNCTION:
    freeReferenceList(obj->funcAttrs->paramList);
    freeType(obj->funcAttrs->returnType);
    freeScope(obj->funcAttrs->scope);
    free(obj->funcAttrs);
    break;
  case OBJ_PROCEDURE:
    freeReferenceList(obj->procAttrs->paramList);
    freeScope(obj->procAttrs->scope);
    free(obj->procAttrs);
    break;
  case OBJ_PROGRAM:
    freeScope(obj->progAttrs->scope);
    free(obj->progAttrs);
    break;
  case OBJ_PARAMETER:
    freeType(obj->paramAttrs->type);
    free(obj->paramAttrs);
  }
  free(obj);
}
示例#2
0
void freeAll(struct Scope *scope)
{
	/* Walk up scopes freeing all tokens */
	while (scope->parent != NULL) {
		freeScope(scope, &scope);
	}

	/* Free root scope */
	freeScope(scope, &scope);
}
示例#3
0
void freeScope(scope *scope) {
  if (scope == NULL) return;

  debug(DEBUG_TDS, "\033[01;36mfreeScope\033[0m");

  freeScope(scope->children);
  freeScope(scope->brother);

  freeEntity(scope->entities);

  free(scope);
}
void freeObject(Object* obj) {
    if (obj != NULL) {
        if (obj->constAttrs != NULL) {
            switch (obj->kind) {
            case OBJ_CONSTANT:
                if (obj->constAttrs->value != NULL) {
                    free(obj->constAttrs->value);
                    obj->constAttrs->value = NULL;
                }
                break;
            case OBJ_VARIABLE:
                if (obj->varAttrs->type != NULL) {
                    free(obj->varAttrs->type);
                    obj->varAttrs->type = NULL;
                }
                break;
            case OBJ_TYPE:
                if (obj->typeAttrs->actualType != NULL) {
                    free(obj->typeAttrs->actualType);
                    obj->typeAttrs->actualType = NULL;
                }
                break;
            case OBJ_PROGRAM:
                if (obj->progAttrs->scope != NULL) {
                    freeScope(obj->progAttrs->scope);
                    obj->progAttrs->scope = NULL;
                }
                break;
            case OBJ_FUNCTION:
                freeScope(obj->funcAttrs->scope); // Free scope also free the param list
                break;
            case OBJ_PROCEDURE:
                freeScope(obj->procAttrs->scope); // Free scope also free the param list
                break;
            case OBJ_PARAMETER:
                if (obj->paramAttrs->type != NULL) {
                    free(obj->paramAttrs->type);
                    obj->paramAttrs->type = NULL;
                }
                break;
            default:
                break;
            }

            free(obj->constAttrs);
            obj->constAttrs = NULL;
        }
        free(obj);
        obj = NULL;
    }
}
示例#5
0
void AudioScope::reallocateScope(int frames) {
    if (_framesPerScope != frames) {
        _framesPerScope = frames;
        _samplesPerScope = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * _framesPerScope;
        freeScope();
        allocateScope();
    }
}
示例#6
0
void AudioScope::toggle() {
    _isEnabled = !_isEnabled;
    if (_isEnabled) {
        allocateScope();
    } else {
        freeScope();
    }
}
示例#7
0
double evaluateScope(struct Scope *scope, struct Scope **currentScope)
{
	double total;

	/* Evaluate */
	findOperations("^", 1, scope); //bOdmas
	findOperations("*/", 2, scope); //boDMas
	findOperations("+-", 2, scope); //bodmAS

	/* Get total */
	total = scope->first == NULL ? 0 : scope->first->intVal;

	/* Cleanup */
	freeScope(scope, currentScope);

	return total;
}